andialbrecht / sqlparse

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

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

Open palash247 opened 1 year ago

palash247 commented 1 year 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 1 year ago

Please assign the issue to me if accepted.