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

Select not recognized if followed by a parenthesis #775

Open
stenci opened this issue Jun 1, 2024 · 1 comment
Open

Select not recognized if followed by a parenthesis #775

stenci opened this issue Jun 1, 2024 · 1 comment

Comments

@stenci
Copy link

stenci commented Jun 1, 2024

The following two sql commands should be equivalent, but the missing space in the second case causes it not to recognize the select.

I am starting now to use sqlparse, so please let me know if this is not a bug and I am setting my expectations wrong.

tokens = sqlparse.parse('select (select 1)')[0]
for n, t in enumerate(tokens):
    print(n, t.ttype, t)

# Output:
# 0 Token.Keyword.DML select
# 1 Token.Text.Whitespace  
# 2 None (select 1)
tokens = sqlparse.parse('select(select 1)')[0]
for n, t in enumerate(tokens):
    print(n, t.ttype, t)

# Output:
# 0 None select(select 1)
@andialbrecht
Copy link
Owner

This is exactly the side effect mentioned here: https://github.com/andialbrecht/sqlparse/blob/master/sqlparse/keywords.py#L56

Fixing this isn't straight forward since it needs some refactoring in the lexer.

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

No branches or pull requests

2 participants