sqlparse icon indicating copy to clipboard operation
sqlparse copied to clipboard

Table name being parsed as a Function

Open JalalMiftah opened this issue 9 years ago • 4 comments

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.

JalalMiftah avatar Dec 18 '15 11:12 JalalMiftah

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>]

jiffyclub avatar Jan 05 '16 00:01 jiffyclub

The column_defs_lowlevel.py in examples runs error due to the same problem...

xueyumusic avatar Mar 06 '16 11:03 xueyumusic

Caused by create table not in uppercase. Workaround is to format first. Please fix.

lichray avatar Feb 08 '17 05:02 lichray

any one solve it?

LY1806620741 avatar Dec 21 '23 03:12 LY1806620741