macbre / sql-metadata

Uses tokenized query returned by python-sqlparse and generates query metadata

Home Page:https://pypi.python.org/pypi/sql-metadata

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can not handle correctly with mysql upsert statement

cardoc-yhbu opened this issue · comments

insert into user (id, name, age) 
  values ('user1', 'john doe', 20) 
  on duplicate key 
  update name='john doe', age=20;

The correct value of Parser(sql).tables is ['user'], but it returns ['user', 'name', 'age'].

I used 0.4.3.

It's broken on the latest sql-metadata as well:

    assert Parser(
        "insert into user (id, name, age) values ('user1', 'john doe', 20) on duplicate key update name='john doe', age=20"
    ).tables == ['user']
Expected :['user']
Actual   :['user', 'name', 'age']