From e7541082a6703784525f844c03021ebec0dc2429 Mon Sep 17 00:00:00 2001 From: Filipp Ozinov Date: Thu, 21 Nov 2024 00:55:51 +0400 Subject: [PATCH] Support binary type --- mysql_ch_replicator/converter.py | 2 ++ test_mysql_ch_replicator.py | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mysql_ch_replicator/converter.py b/mysql_ch_replicator/converter.py index bbbb7db..a2dd586 100644 --- a/mysql_ch_replicator/converter.py +++ b/mysql_ch_replicator/converter.py @@ -194,6 +194,8 @@ def convert_type(self, mysql_type, parameters): return 'String' if 'varbinary' in mysql_type: return 'String' + if 'binary' in mysql_type: + return 'String' raise Exception(f'unknown mysql type "{mysql_type}"') def convert_field_type(self, mysql_type, mysql_parameters): diff --git a/test_mysql_ch_replicator.py b/test_mysql_ch_replicator.py index 0d3f0f8..d3cb13f 100644 --- a/test_mysql_ch_replicator.py +++ b/test_mysql_ch_replicator.py @@ -717,13 +717,14 @@ def test_different_types_2(): `id` int unsigned NOT NULL AUTO_INCREMENT, test1 bit(1), test2 point, + test3 binary(16), PRIMARY KEY (id) ); ''') mysql.execute( - f"INSERT INTO {TEST_TABLE_NAME} (test1, test2) VALUES " - f"(0, POINT(10.0, 20.0));", + f"INSERT INTO {TEST_TABLE_NAME} (test1, test2, test3) VALUES " + f"(0, POINT(10.0, 20.0), 'azaza');", commit=True, ) @@ -749,6 +750,7 @@ def test_different_types_2(): assert ch.select(TEST_TABLE_NAME, 'test1=True')[0]['test2']['x'] == 15.0 assert ch.select(TEST_TABLE_NAME, 'test1=False')[0]['test2']['y'] == 20.0 + assert ch.select(TEST_TABLE_NAME, 'test1=False')[0]['test3'] == 'azaza\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' mysql.execute( f"INSERT INTO {TEST_TABLE_NAME} (test1, test2) VALUES "