mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-09 16:58:00 +00:00
added support for expressions with parentheses
This commit is contained in:
parent
335607f6bb
commit
94df7c22e6
2 changed files with 31 additions and 1 deletions
|
@ -334,6 +334,29 @@ fn parse_select_version() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_parens() {
|
||||
use self::ASTNode::*;
|
||||
use self::SQLOperator::*;
|
||||
let sql = "(a + b) - (c + d)";
|
||||
let ast = parse_sql(&sql);
|
||||
assert_eq!(
|
||||
SQLBinaryExpr {
|
||||
left: Box::new(SQLBinaryExpr {
|
||||
left: Box::new(SQLIdentifier("a".to_string())),
|
||||
op: Plus,
|
||||
right: Box::new(SQLIdentifier("b".to_string()))
|
||||
}),
|
||||
op: Minus,
|
||||
right: Box::new(SQLBinaryExpr {
|
||||
left: Box::new(SQLIdentifier("c".to_string())),
|
||||
op: Plus,
|
||||
right: Box::new(SQLIdentifier("d".to_string()))
|
||||
})
|
||||
}
|
||||
, ast);
|
||||
}
|
||||
|
||||
fn parse_sql(sql: &str) -> ASTNode {
|
||||
let dialect = GenericSqlDialect {};
|
||||
let mut tokenizer = Tokenizer::new(&dialect,&sql, );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue