taozhi8833998 / node-sql-parser

Parse simple SQL statements into an abstract syntax tree (AST) with the visited tableList and convert it back to SQL
https://taozhi8833998.github.io/node-sql-parser/
Apache License 2.0
798 stars 180 forks source link

SyntaxError on a valid PostgreSQL query that uses ::text to cast a column to text #1964

Closed ondrej closed 3 months ago

ondrej commented 3 months ago

Describe the bug Node SQL Parser is unable to astify() a valid PostgreSQL statement that uses the :: cast operator.

Database Engine PostgreSQL

To Reproduce -the SQL that be parsed SELECT a FROM b WHERE a::TEXT ILIKE '%x%'

-the node-sql-parser version 5.2.0

-the node version 21.7.2

Expected behavior Parsing succeeds without a SyntaxError, just like it does when the cast is in parenthesis: SELECT a FROM b WHERE (a::TEXT) ILIKE '%x%'

ondrej commented 3 months ago

Thank you!