mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-30 10:47:22 +00:00
fix parsing of identifiers after %
symbol (#927)
This commit is contained in:
parent
e36b34d8cc
commit
3a412152b9
3 changed files with 48 additions and 8 deletions
|
@ -1143,6 +1143,20 @@ fn parse_unary_math_with_multiply() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_mod() {
|
||||
use self::Expr::*;
|
||||
let sql = "a % b";
|
||||
assert_eq!(
|
||||
BinaryOp {
|
||||
left: Box::new(Identifier(Ident::new("a"))),
|
||||
op: BinaryOperator::Modulo,
|
||||
right: Box::new(Identifier(Ident::new("b"))),
|
||||
},
|
||||
verified_expr(sql)
|
||||
);
|
||||
}
|
||||
|
||||
fn pg_and_generic() -> TestedDialects {
|
||||
TestedDialects {
|
||||
dialects: vec![Box::new(PostgreSqlDialect {}), Box::new(GenericDialect {})],
|
||||
|
@ -1178,6 +1192,24 @@ fn parse_json_ops_without_colon() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_mod_no_spaces() {
|
||||
use self::Expr::*;
|
||||
let canonical = "a1 % b1";
|
||||
let sqls = ["a1 % b1", "a1% b1", "a1 %b1", "a1%b1"];
|
||||
for sql in sqls {
|
||||
println!("Parsing {sql}");
|
||||
assert_eq!(
|
||||
BinaryOp {
|
||||
left: Box::new(Identifier(Ident::new("a1"))),
|
||||
op: BinaryOperator::Modulo,
|
||||
right: Box::new(Identifier(Ident::new("b1"))),
|
||||
},
|
||||
pg_and_generic().expr_parses_to(sql, canonical)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_is_null() {
|
||||
use self::Expr::*;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue