Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_type() does not return "SELECT" if a query uses CTEs #227

Closed
andrew-tipton-cgg opened this issue Mar 2, 2016 · 2 comments
Closed

get_type() does not return "SELECT" if a query uses CTEs #227

andrew-tipton-cgg opened this issue Mar 2, 2016 · 2 comments
Milestone

Comments

@andrew-tipton-cgg
Copy link
Contributor

Calling get_type() on a SQL query that uses a CTE (WITH ... SELECT ...) returns UNKNOWN instead of SELECT. Test case:

import sqlparse

select_stmt = sqlparse.parse('SELECT 1, 2, 3 FROM foo;')[0]
assert select_stmt.get_type() == 'SELECT'
with_stmt = sqlparse.parse('WITH foo AS (SELECT 1, 2, 3) SELECT * FROM foo;')[0]
assert with_stmt.get_type() == 'SELECT'  # returns 'UNKNOWN'
@andrew-tipton-cgg
Copy link
Contributor Author

(This issue is present in both 0.1.18 and master.)

andrew-tipton-cgg added a commit to hyphengroup/sqlparse that referenced this issue Mar 2, 2016
andialbrecht added a commit that referenced this issue Mar 7, 2016
Fix for #227 (get_type() doesn't work for queries that use WITH)
@andialbrecht andialbrecht added this to the 0.2.0 milestone Mar 7, 2016
@andialbrecht
Copy link
Owner

Fixed in 8f39d33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants