apache / datafusion-sqlparser-rs

Extensible SQL Lexer and Parser for Rust
Apache License 2.0
2.8k stars 543 forks source link

parse true and false as column names, not booleans in Microsoft SQL server #1508

Closed lovasoa closed 1 week ago

lovasoa commented 1 week ago

mssql does not have a boolean type: true and false are not special keywords and they are valid column names. However, sqlparser always parses them as boolean literals, regardless of the dialect.

In the mssql dialect, in

select true from table;

true should be parsed as an Identifier, not a Value.

Parsing true and false as booleans in mssql causes the following confusing behavior in SQLPage: https://github.com/sqlpage/SQLPage/discussions/679