From 10ca99b18efa78d5ea301813028efc6c38d29198 Mon Sep 17 00:00:00 2001 From: Filipp Ozinov Date: Mon, 20 Jan 2025 19:22:23 +0400 Subject: [PATCH] Fixed crash on keys with comma --- mysql_ch_replicator/converter.py | 8 ++++++++ test_mysql_ch_replicator.py | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/mysql_ch_replicator/converter.py b/mysql_ch_replicator/converter.py index 8e8a841..b8babc5 100644 --- a/mysql_ch_replicator/converter.py +++ b/mysql_ch_replicator/converter.py @@ -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'): diff --git a/test_mysql_ch_replicator.py b/test_mysql_ch_replicator.py index 6c02de2..6c5478a 100644 --- a/test_mysql_ch_replicator.py +++ b/test_mysql_ch_replicator.py @@ -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 ); ''')