sqlparse
sqlparse copied to clipboard
Table name being parsed as a Function
Hi,
There is an issue when I try to parse this SQL statement:
INSERT INTO XYZ (ID, TYPE, DATA, TRANSACTION_ID, ENQUEUING_TIME, AVAILABILITY_TIME, LAST_RETRY_TIME, ATTEMPTS_COUNT, DEPENDENCY_INDICATOR, REJECT_QUEUE_INDICATOR, PEAK_TOKEN, LOGICAL_TRANSACTION_TIME) VALUES (?, ?, ?, ?, SYSDATE, SYSDATE + ? / 86400, NULL, ?, ?, ?, ?, ?)
When I parse it, I have this tag:
DML 'INSERT' at 0x06dc050>, Whitespace ' ' at 0x06dc0a8>, Keyword 'INTO' at 0x06dc100>, Whitespace ' ' at 0x06dc158>, Function 'XYZ ...' at 0x05f8f30>, Whitespace ' ' at 0x077ed08>, Keyword 'VALUES' at 0x077e9f0>, Whitespace ' ' at 0x077eb50>, Parenthesis '( ?, ?...' at 0x05f8ea8>
So the table name XYZ is being tagged as a Function.
Thank you for looking into it.
I see this also in situations where a table name is followed by parentheses:
>>> sqlparse.parse('create table asdf.pants (id serial);')[0].tokens[4].tokens
[<Name 'asdf' at 0x1066ad9a8>,
<Punctuation '.' at 0x1066ad9f8>,
<Function 'pants ...' at 0x10669de48>]
The column_defs_lowlevel.py in examples runs error due to the same problem...
Caused by create table
not in uppercase. Workaround is to format
first. Please fix.
any one solve it?