dannykopping / mysql-utilities

Github clone of BZR library
https://code.launchpad.net/~mysql/mysql-utilities/trunk
GNU General Public License v2.0
13 stars 6 forks source link

_parse_object_name does not expect quoted `db`.`table` #1

Open dzhibas opened 11 years ago

dzhibas commented 11 years ago

_parse_object_name(qualified_name) in utilities/common/table.py does not expect quilified_name in quotes like db.name.

consequence is that mysqldbexport generates:

INSERT INTO `None`.`None` VALUES

regexp:

parts = re.match("`?(\w+)`?(?:\.`?(\w+)`?)?", qualified_name)

fixes it for both cases with and without quotes

want a pull request with test?

dzhibas commented 11 years ago
import re

tests = ['`demo`.`test1`', 'demo.test1']

regz = ["`?(\w+)`?(?:\.`?(\w+)`?)?", "(\w+)(?:\.(\w+))?"]

for reg in regz:
    print reg
    for test in tests:
        print test
        parts = re.match(reg, test)
        if parts:
            print parts.groups()
        else:
            print (None, None)