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
818 stars 181 forks source link

Statement after Lateral keyword couldn't be parsed as expected MySql #2188

Closed akramtechspace closed 2 weeks ago

akramtechspace commented 3 weeks ago

Describe the bug I am using this sql statement to parse parser.parse( "SELECT FROM table1, LATERAL (SELECT FROM table2 WHERE table2.id = table1.id) AS subquery" ) it is indeed a valid sql statement , but however it is throwing an exception.

Database Engine MySql V8 +

To Reproduce

https://codesandbox.io/p/sandbox/6xdykq -the SQL that be parsed - "SELECT FROM table1, LATERAL (SELECT FROM table2 WHERE table2.id = table1.id) AS subquery" -the node-sql-parser version - Latest (5.3.3) -the node version - v20

Expected behavior Should've parsed the query without any exception.

Screenshots image

Additional context I provided this as a sample query. My actual use case is different. I raised this issue to understand if the behavior is intentional. If it is, I’ll need to adjust my approach to address my actual problem with the query