Open
Description
When parsing a query, if it has more than one statement, the statement of index 1+ has to start with a correct keyword to be correctly identified as an statement and therefore parsed.
For these examples the ExceptionError
listener is turned off.
Ex:
sqlparse("""
ELECT 1; -- wrong
Begin 2; -- correct
ELECT 2; -- wrong
""")
>>> [Statement<ELECT 1>, Statement<Begin>]
sqlparse("""
ELECT 1; -- wrong
Begin 2; -- correct
SELECT 2; -- correct
""")
>>> [Statement<ELECT 1>, Statement<Begin>, Statement<SELECT 2>]
sqlparse("""
ELECT 1; -- wrong
egin 2; -- wrong
SELECT 2; -- correct
""")
>>> [Statement<ELECT 1>]
Note in the last example how it needs a correct first keyword to keep parsing statements, even if the third 'statement' is correct, this only seems to apply from the first statement onward.
Definition of statements: https://github.com/crate/crate/blob/302c91871ca5c6b34dac07c01ef03f6f2e0017ee/libs/sql-parser/src/main/antlr/io/crate/sql/parser/antlr/SqlBaseParser.g4#L26