Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mysql_ch_replicator/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ def _strip_comments(self, create_statement):
# Look for COMMENT keyword (case insensitive)
if (i + 7 < len(create_statement) and
create_statement[i:i+7].upper() == 'COMMENT' and
(i == 0 or not create_statement[i-1].isalnum()) and
(i == 0 or (not create_statement[i-1].isalnum() and create_statement[i-1] != '`')) and
(i + 7 >= len(create_statement) or not create_statement[i+7].isalnum())):

# Skip COMMENT keyword
Expand Down
15 changes: 15 additions & 0 deletions test_mysql_ch_replicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3314,6 +3314,21 @@ def test_charset_configuration():
"CREATE TABLE test (id int comment 'lowercase', name varchar(255) Comment 'Mixed case')",
"CREATE TABLE test (id int , name varchar(255) )"
),
# Field named comment
(
"""CREATE TABLE test (
`departments int(11) NOT NULL,
`termine int(11) NOT NULL,
`comment` varchar(120) DEFAULT NULL,
PRIMARY KEY (departments,termine)
)""",
"""CREATE TABLE test (
`departments int(11) NOT NULL,
`termine int(11) NOT NULL,
`comment` varchar(120) DEFAULT NULL,
PRIMARY KEY (departments,termine)
)"""
),
])
def test_strip_comments_function(input_sql, expected_output):
"""
Expand Down