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
820 stars 183 forks source link

Issue using EXCEPT on noql #2148

Closed eXigentCoder closed 1 month ago

eXigentCoder commented 1 month ago

Describe the bug

I'm currently having a similar issue to the one in #1747 that was fixed by #1748. The INTERSECT keyword is working as expected, but when using EXCEPT without a WHERE clause, I'm getting a parser error.

Expected "(", ",", "--", "/*", ";", "CROSS", "EXCEPT", "FULL", "GROUP", "HAVING", "INNER", "INTERSECT", "INTO", "JOIN", "LEFT", "LIMIT", "OFFSET", "ORDER", "RIGHT", "UNION", "WHERE", "WINDOW", [ \t\n\r], or end of input but "S" found.

Database Engine which database engine does your SQL running on? such as MySQL, PostgreSQL.

noql

To Reproduce

-the SQL that be parsed

SELECT *
FROM "top-rated-films"
EXCEPT
SELECT *
FROM "most-popular-films"
ORDER BY name

-the node-sql-parser version 5.2.0 -the node version v16.20.2

Expected behavior A clear and concise description of what you expected to happen. It should build the AST correctly

Screenshots If applicable, add screenshots to help explain your problem. N/A

Additional context Add any other context about the problem here.

If I provide a where statement as follows, it does parse successfully:

SELECT *
FROM "top-rated-films"
WHERE 1=1
EXCEPT
SELECT *
FROM "most-popular-films"
ORDER BY name