We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parser should parse negative numbers as is, rather than into a unary_op neg, wrapping an inner value, to be consistent with Postgres.
Postgres behaviour using (pglast):
[nix-shell:~/projects/risingwave-nix]$ ./query_parser.py "select -(-(-(9223372036854775808)))" {'@': 'SelectStmt', 'all': False, 'limitOption': {'#': 'LimitOption', 'name': 'LIMIT_OPTION_DEFAULT', 'value': 0}, 'op': {'#': 'SetOperation', 'name': 'SETOP_NONE', 'value': 0}, 'targetList': ({'@': 'ResTarget', 'location': 7, 'val': {'@': 'A_Const', 'location': 7, 'val': {'@': 'Float', 'val': Decimal('-9223372036854775808')}}},)}
The text was updated successfully, but these errors were encountered:
To reproduce:
use sqlparser::dialect::PostgreSqlDialect; use sqlparser::parser::Parser; fn main() { let sql = "SELECT -9223372036854775808;"; let dialect = PostgreSqlDialect {}; let ast = Parser::parse_sql(&dialect, sql).unwrap(); println!("AST: {:#?}", ast); }
Output:
AST: [ Query( Query { with: None, body: Select( Select { distinct: false, top: None, projection: [ UnnamedExpr( UnaryOp { op: Minus, expr: Value( Number( "9223372036854775808", false, ), ), }, ), ], into: None, from: [], lateral_views: [], selection: None, group_by: [], cluster_by: [], distribute_by: [], sort_by: [], having: None, qualify: None, }, ), order_by: [], limit: None, offset: None, fetch: None, lock: None, }, ), ]
Sorry, something went wrong.
No branches or pull requests
Parser should parse negative numbers as is, rather than into a unary_op neg, wrapping an inner value, to be consistent with Postgres.
Postgres behaviour using (pglast):
The text was updated successfully, but these errors were encountered: