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

Unable to parse ALTER statement with ROW_FORMAT into correct tokens #773

Open
jdforde opened this issue May 13, 2024 · 0 comments
Open

Unable to parse ALTER statement with ROW_FORMAT into correct tokens #773

jdforde opened this issue May 13, 2024 · 0 comments

Comments

@jdforde
Copy link

jdforde commented May 13, 2024

Describe the bug
It appears that sqlparse is unable to parse an alter statement that aims to edit the row_format of a particular table. When looking at the tokens, it combines the name of the table and the row_format statement into a single token. Therefore, it is unable to correctly parse the statement.

To Reproduce
Run this code snippet as a sample:

import sqlparse
from sqlparse.sql import TokenList

string = """ALTER TABLE mytable ROW_FORMAT=Dynamic;"""

statement = sqlparse.parse(string)[0]
print(TokenList(statement)[0:])

The output will be as follows:
[<DDL 'ALTER' at 0x7FEC4A7C4F40>, <Whitespace ' ' at 0x7FEC4A6C25E0>, <Keyword 'TABLE' at 0x7FEC4A6C2640>, <Whitespace ' ' at 0x7FEC4A6C26A0>, <Identifier 'mytabl...' at 0x7FEC4A730DD0>, <Comparison '=' at 0x7FEC4A6C2820>, <Keyword 'Dynamic' at 0x7FEC4A6C2880>, <Punctuation ';' at 0x7FEC4A6C28E0>]

Expected behavior
Notice how the Identifier mytabl... also contains the row_format in the same token. I believe that ROW_FORMAT should be its own token.

Versions (please complete the following information):

  • Python: [e.g. 3.8.10]
  • sqlparse: [e.g. 0.5.0]
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

1 participant