Skip to content

Commit

Permalink
Fixed crash on keys with comma (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
bakwc authored Jan 20, 2025
1 parent 55fb9ee commit 752aea1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions mysql_ch_replicator/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,15 @@ def parse_mysql_table_structure(self, create_statement, required_table_name=None
if structure.charset:
structure.charset_python = CHARSET_MYSQL_TO_PYTHON[structure.charset]

prev_line = ''
for line in inner_tokens:
line = prev_line + line
q_count = line.count('`')
if q_count % 2 == 1:
prev_line = line
continue
prev_line = ''

if line.lower().startswith('unique key'):
continue
if line.lower().startswith('key'):
Expand Down
3 changes: 2 additions & 1 deletion test_mysql_ch_replicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,8 @@ def test_different_types_1():
`modified_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`entity` int NOT NULL DEFAULT '0',
`sent_2_tac` char(1) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '0',
PRIMARY KEY (id)
PRIMARY KEY (id),
KEY `name, employee` (`name`,`employee`) USING BTREE
);
''')

Expand Down

0 comments on commit 752aea1

Please sign in to comment.