Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 902f330

Browse files
authoredOct 27, 2024··
Handling text and blob data types, #3 (#8)
1 parent d0ba7e6 commit 902f330

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed
 

‎mysql_ch_replicator/converter.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ def convert_type(self, mysql_type):
8989
return 'String'
9090
if 'varchar' in mysql_type:
9191
return 'String'
92+
if 'text' in mysql_type:
93+
return 'String'
94+
if 'blob' in mysql_type:
95+
return 'String'
9296
if 'char' in mysql_type:
9397
return 'String'
9498
if 'json' in mysql_type:

‎test_mysql_ch_replicator.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,16 @@ def test_e2e_regular():
9090
id int NOT NULL AUTO_INCREMENT,
9191
name varchar(255),
9292
age int,
93+
field1 text,
94+
field2 blob,
9395
PRIMARY KEY (id)
9496
);
9597
''')
9698

97-
mysql.execute(f"INSERT INTO {TEST_TABLE_NAME} (name, age) VALUES ('Ivan', 42);", commit=True)
99+
mysql.execute(
100+
f"INSERT INTO {TEST_TABLE_NAME} (name, age, field1, field2) VALUES ('Ivan', 42, 'test1', 'test2');",
101+
commit=True,
102+
)
98103
mysql.execute(f"INSERT INTO {TEST_TABLE_NAME} (name, age) VALUES ('Peter', 33);", commit=True)
99104

100105
binlog_replicator_runner = BinlogReplicatorRunner()
@@ -120,6 +125,9 @@ def test_e2e_regular():
120125
assert_wait(lambda: len(ch.select(TEST_TABLE_NAME)) == 4)
121126
assert_wait(lambda: ch.select(TEST_TABLE_NAME, where="name='Mary'")[0]['last_name'] == 'Smith')
122127

128+
assert_wait(lambda: ch.select(TEST_TABLE_NAME, where="field1='test1'")[0]['name'] == 'Ivan')
129+
assert_wait(lambda: ch.select(TEST_TABLE_NAME, where="field2='test2'")[0]['name'] == 'Ivan')
130+
123131

124132
mysql.execute(
125133
f"ALTER TABLE {TEST_DB_NAME}.{TEST_TABLE_NAME} "

0 commit comments

Comments
 (0)