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
823 stars 184 forks source link

Cannot parse queries with 'partition' or 'type' as a table column in SQLite #2143

Closed hugonoro closed 1 month ago

hugonoro commented 2 months ago

Describe the bug When parsing a query that has a table column named partition or type it blows up the parser. I'm suspecting because these are most likely reserved words in SQLite.

I heavily suspect this would be happening with other reserved words.

ERROR: Expected "#", "(", "--", ".", "/*", ":=", or [ \t\n\r] but "f" found.

The problem surfaces when the column name partition is used both in the SELECT portion and in the WHERE portion of a query.

Database Engine SQLite

To Reproduce -the SQL that be parsed SELECT partition from where partition like '%' SELECT from where type= -the node-sql-parser version "node-sql-parser": "5.3.2", -the node version 20.12.2

Expected behaviour Reserved words as column names should be treated as a possible value and allow the parsing to be successful. It should be possible to be used both in the 'SELECTportion and in theWHERE` portion of a query.