Skip to content

Commit 962acec

Browse files
authored
Fixed add column with decimal type (#105)
1 parent 4d545fa commit 962acec

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

mysql_ch_replicator/converter.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,6 @@ def __convert_alter_table_add_column(self, db_name, table_name, tokens):
465465
if len(tokens) < 2:
466466
raise Exception('wrong tokens count', tokens)
467467

468-
if ',' in ' '.join(tokens):
469-
raise Exception('add multiple columns not implemented', tokens)
470-
471468
column_after = None
472469
column_first = False
473470
if tokens[-2].lower() == 'after':
@@ -522,9 +519,6 @@ def __convert_alter_table_add_column(self, db_name, table_name, tokens):
522519
self.db_replicator.clickhouse_api.execute_command(query)
523520

524521
def __convert_alter_table_drop_column(self, db_name, table_name, tokens):
525-
if ',' in ' '.join(tokens):
526-
raise Exception('add multiple columns not implemented', tokens)
527-
528522
if len(tokens) != 1:
529523
raise Exception('wrong tokens count', tokens)
530524

@@ -547,9 +541,6 @@ def __convert_alter_table_modify_column(self, db_name, table_name, tokens):
547541
if len(tokens) < 2:
548542
raise Exception('wrong tokens count', tokens)
549543

550-
if ',' in ' '.join(tokens):
551-
raise Exception('add multiple columns not implemented', tokens)
552-
553544
column_name = strip_sql_name(tokens[0])
554545
column_type_mysql = tokens[1]
555546
column_type_mysql_parameters = ' '.join(tokens[2:])
@@ -578,9 +569,6 @@ def __convert_alter_table_change_column(self, db_name, table_name, tokens):
578569
if len(tokens) < 3:
579570
raise Exception('wrong tokens count', tokens)
580571

581-
if ',' in ' '.join(tokens):
582-
raise Exception('add multiple columns not implemented', tokens)
583-
584572
column_name = strip_sql_name(tokens[0])
585573
new_column_name = strip_sql_name(tokens[1])
586574
column_type_mysql = tokens[2]

test_mysql_ch_replicator.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ def test_e2e_regular(config_file):
135135

136136

137137
mysql.execute(f"ALTER TABLE `{TEST_TABLE_NAME}` ADD `last_name` varchar(255); ")
138-
mysql.execute(f"INSERT INTO `{TEST_TABLE_NAME}` (name, age, last_name) VALUES ('Mary', 24, 'Smith');", commit=True)
138+
mysql.execute(f"ALTER TABLE `{TEST_TABLE_NAME}` ADD `price` decimal(10,2) DEFAULT NULL; ")
139+
140+
mysql.execute(f"INSERT INTO `{TEST_TABLE_NAME}` (name, age, last_name, price) VALUES ('Mary', 24, 'Smith', 3.2);", commit=True)
139141

140142
assert_wait(lambda: len(ch.select(TEST_TABLE_NAME)) == 4)
141143
assert_wait(lambda: ch.select(TEST_TABLE_NAME, where="name='Mary'")[0]['last_name'] == 'Smith')

0 commit comments

Comments
 (0)