Skip to content

Commit 752aea1

Browse files
authored
Fixed crash on keys with comma (#85)
1 parent 55fb9ee commit 752aea1

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

mysql_ch_replicator/converter.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,15 @@ def parse_mysql_table_structure(self, create_statement, required_table_name=None
672672
if structure.charset:
673673
structure.charset_python = CHARSET_MYSQL_TO_PYTHON[structure.charset]
674674

675+
prev_line = ''
675676
for line in inner_tokens:
677+
line = prev_line + line
678+
q_count = line.count('`')
679+
if q_count % 2 == 1:
680+
prev_line = line
681+
continue
682+
prev_line = ''
683+
676684
if line.lower().startswith('unique key'):
677685
continue
678686
if line.lower().startswith('key'):

test_mysql_ch_replicator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,8 @@ def test_different_types_1():
760760
`modified_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
761761
`entity` int NOT NULL DEFAULT '0',
762762
`sent_2_tac` char(1) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '0',
763-
PRIMARY KEY (id)
763+
PRIMARY KEY (id),
764+
KEY `name, employee` (`name`,`employee`) USING BTREE
764765
);
765766
''')
766767

0 commit comments

Comments
 (0)