mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-23 15:34:09 +00:00
Remove Box<> from SQLOrderByExpr
It was probably copied from somewhere else when most types were variants in ASTNode, and needed Box<> to prevent recursion in the ASTNode definition.
This commit is contained in:
parent
9967031cba
commit
3619e89e9c
3 changed files with 7 additions and 13 deletions
|
@ -170,16 +170,10 @@ pub enum JoinConstraint {
|
||||||
/// SQL ORDER BY expression
|
/// SQL ORDER BY expression
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
pub struct SQLOrderByExpr {
|
pub struct SQLOrderByExpr {
|
||||||
pub expr: Box<ASTNode>,
|
pub expr: ASTNode,
|
||||||
pub asc: Option<bool>,
|
pub asc: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SQLOrderByExpr {
|
|
||||||
pub fn new(expr: Box<ASTNode>, asc: Option<bool>) -> Self {
|
|
||||||
SQLOrderByExpr { expr, asc }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ToString for SQLOrderByExpr {
|
impl ToString for SQLOrderByExpr {
|
||||||
fn to_string(&self) -> String {
|
fn to_string(&self) -> String {
|
||||||
match self.asc {
|
match self.asc {
|
||||||
|
|
|
@ -1362,7 +1362,7 @@ impl Parser {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
expr_list.push(SQLOrderByExpr::new(Box::new(expr), asc));
|
expr_list.push(SQLOrderByExpr { expr, asc });
|
||||||
|
|
||||||
if let Some(Token::Comma) = self.peek_token() {
|
if let Some(Token::Comma) = self.peek_token() {
|
||||||
self.next_token();
|
self.next_token();
|
||||||
|
|
|
@ -242,15 +242,15 @@ fn parse_select_order_by() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Some(vec![
|
Some(vec![
|
||||||
SQLOrderByExpr {
|
SQLOrderByExpr {
|
||||||
expr: Box::new(ASTNode::SQLIdentifier("lname".to_string())),
|
expr: ASTNode::SQLIdentifier("lname".to_string()),
|
||||||
asc: Some(true),
|
asc: Some(true),
|
||||||
},
|
},
|
||||||
SQLOrderByExpr {
|
SQLOrderByExpr {
|
||||||
expr: Box::new(ASTNode::SQLIdentifier("fname".to_string())),
|
expr: ASTNode::SQLIdentifier("fname".to_string()),
|
||||||
asc: Some(false),
|
asc: Some(false),
|
||||||
},
|
},
|
||||||
SQLOrderByExpr {
|
SQLOrderByExpr {
|
||||||
expr: Box::new(ASTNode::SQLIdentifier("id".to_string())),
|
expr: ASTNode::SQLIdentifier("id".to_string()),
|
||||||
asc: None,
|
asc: None,
|
||||||
},
|
},
|
||||||
]),
|
]),
|
||||||
|
@ -277,11 +277,11 @@ fn parse_select_order_by_limit() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
Some(vec![
|
Some(vec![
|
||||||
SQLOrderByExpr {
|
SQLOrderByExpr {
|
||||||
expr: Box::new(ASTNode::SQLIdentifier("lname".to_string())),
|
expr: ASTNode::SQLIdentifier("lname".to_string()),
|
||||||
asc: Some(true),
|
asc: Some(true),
|
||||||
},
|
},
|
||||||
SQLOrderByExpr {
|
SQLOrderByExpr {
|
||||||
expr: Box::new(ASTNode::SQLIdentifier("fname".to_string())),
|
expr: ASTNode::SQLIdentifier("fname".to_string()),
|
||||||
asc: Some(false),
|
asc: Some(false),
|
||||||
},
|
},
|
||||||
]),
|
]),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue