Skip to content

Parsing RENAME TABLE statment returns wrong tokens #779

Open

Description

@youthug

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions