andialbrecht / sqlparse

A non-validating SQL parser module for Python
BSD 3-Clause "New" or "Revised" License
3.63k stars 685 forks source link

`get_type` returns UNKNOWN if first token is Parenthesis #727

Open palash247 opened 12 months ago

palash247 commented 12 months ago

The issue:

q1 = '(select 1 as "a") UNION (select 2 as "a")' q2 = 'select 1 as "a" UNION select 2 as "a"' sqlparse.parse(q1)[0].get_type() 'UNKNOWN' sqlparse.parse(q2)[0].get_type() 'SELECT'

palash247 commented 12 months ago

Please assign the issue to me if accepted.