mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-23 07:24:10 +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
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct SQLOrderByExpr {
|
||||
pub expr: Box<ASTNode>,
|
||||
pub expr: ASTNode,
|
||||
pub asc: Option<bool>,
|
||||
}
|
||||
|
||||
impl SQLOrderByExpr {
|
||||
pub fn new(expr: Box<ASTNode>, asc: Option<bool>) -> Self {
|
||||
SQLOrderByExpr { expr, asc }
|
||||
}
|
||||
}
|
||||
|
||||
impl ToString for SQLOrderByExpr {
|
||||
fn to_string(&self) -> String {
|
||||
match self.asc {
|
||||
|
|
|
@ -1362,7 +1362,7 @@ impl Parser {
|
|||
None
|
||||
};
|
||||
|
||||
expr_list.push(SQLOrderByExpr::new(Box::new(expr), asc));
|
||||
expr_list.push(SQLOrderByExpr { expr, asc });
|
||||
|
||||
if let Some(Token::Comma) = self.peek_token() {
|
||||
self.next_token();
|
||||
|
|
|
@ -242,15 +242,15 @@ fn parse_select_order_by() {
|
|||
assert_eq!(
|
||||
Some(vec![
|
||||
SQLOrderByExpr {
|
||||
expr: Box::new(ASTNode::SQLIdentifier("lname".to_string())),
|
||||
expr: ASTNode::SQLIdentifier("lname".to_string()),
|
||||
asc: Some(true),
|
||||
},
|
||||
SQLOrderByExpr {
|
||||
expr: Box::new(ASTNode::SQLIdentifier("fname".to_string())),
|
||||
expr: ASTNode::SQLIdentifier("fname".to_string()),
|
||||
asc: Some(false),
|
||||
},
|
||||
SQLOrderByExpr {
|
||||
expr: Box::new(ASTNode::SQLIdentifier("id".to_string())),
|
||||
expr: ASTNode::SQLIdentifier("id".to_string()),
|
||||
asc: None,
|
||||
},
|
||||
]),
|
||||
|
@ -277,11 +277,11 @@ fn parse_select_order_by_limit() {
|
|||
assert_eq!(
|
||||
Some(vec![
|
||||
SQLOrderByExpr {
|
||||
expr: Box::new(ASTNode::SQLIdentifier("lname".to_string())),
|
||||
expr: ASTNode::SQLIdentifier("lname".to_string()),
|
||||
asc: Some(true),
|
||||
},
|
||||
SQLOrderByExpr {
|
||||
expr: Box::new(ASTNode::SQLIdentifier("fname".to_string())),
|
||||
expr: ASTNode::SQLIdentifier("fname".to_string()),
|
||||
asc: Some(false),
|
||||
},
|
||||
]),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue