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

Parsing RENAME TABLE statment returns wrong tokens #779

Open
youthug opened this issue Jul 4, 2024 · 0 comments
Open

Parsing RENAME TABLE statment returns wrong tokens #779

youthug opened this issue Jul 4, 2024 · 0 comments

Comments

@youthug
Copy link

youthug commented Jul 4, 2024

Describe the bug
When parsing the RENAME TABLE sql statement by sqlparse.parse with this content:

rename table `db`.`test1` to test2, `db`.`test3` to test4

the result of ret[0].tokens:

[
00 = {Token} <Keyword 'rename' at 0x7F0B52882A00>
01 = {Token} <Whitespace ' ' at 0x7F0B52882A60>
02 = {Token} <Keyword 'table' at 0x7F0B52882AC0>
03 = {Token} <Whitespace ' ' at 0x7F0B52882B20>
04 = {Identifier} <Identifier '`db`.`...' at 0x7F0B47A030B0>  # value: '`db`.`test1`'
05 = {Token} <Whitespace ' ' at 0x7F0B52882CA0>
06 = {Token} <Keyword 'to' at 0x7F0B52882D00>
07 = {Token} <Whitespace ' ' at 0x7F0B52882D60>
08 = {IdentifierList} <IdentifierList 'test2,...' at 0x7F0B47A03890>  # value: 'test2, `db`.`test3`'
09 = {Token} <Whitespace ' ' at 0x7F0B52897040>
10 = {Token} <Keyword 'to' at 0x7F0B528970A0>
11 = {Token} <Whitespace ' ' at 0x7F0B52897100>
12 = {Identifier} <Identifier 'test4' at 0x7F0B47A03DD0>
]

Is this as expected? Should't the db`.`test3 be an Identifier too?

To Reproduce

import sqlparse

sqlparse.parse("rename table `db`.`test1` to test2, `db`.`test3` to test4")

Expected behavior
the db`.`test3 should be an Identifier too.

Versions (please complete the following information):

  • Python: 3.8.10
  • sqlparse: 0.4.2
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