fix parsing of identifiers after % symbol (#927)

This commit is contained in:
Andrew Lamb 2023-07-21 05:55:41 -04:00 committed by GitHub
parent e36b34d8cc
commit 3a412152b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 8 deletions

View file

@ -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::*;