Skip to content

Commit aa7a4ce

Browse files
authored
Support binary type (bakwc#35)
1 parent 0a71b25 commit aa7a4ce

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

mysql_ch_replicator/converter.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ def convert_type(self, mysql_type, parameters):
194194
return 'String'
195195
if 'varbinary' in mysql_type:
196196
return 'String'
197+
if 'binary' in mysql_type:
198+
return 'String'
197199
raise Exception(f'unknown mysql type "{mysql_type}"')
198200

199201
def convert_field_type(self, mysql_type, mysql_parameters):

test_mysql_ch_replicator.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,13 +717,14 @@ def test_different_types_2():
717717
`id` int unsigned NOT NULL AUTO_INCREMENT,
718718
test1 bit(1),
719719
test2 point,
720+
test3 binary(16),
720721
PRIMARY KEY (id)
721722
);
722723
''')
723724

724725
mysql.execute(
725-
f"INSERT INTO {TEST_TABLE_NAME} (test1, test2) VALUES "
726-
f"(0, POINT(10.0, 20.0));",
726+
f"INSERT INTO {TEST_TABLE_NAME} (test1, test2, test3) VALUES "
727+
f"(0, POINT(10.0, 20.0), 'azaza');",
727728
commit=True,
728729
)
729730

@@ -749,6 +750,7 @@ def test_different_types_2():
749750

750751
assert ch.select(TEST_TABLE_NAME, 'test1=True')[0]['test2']['x'] == 15.0
751752
assert ch.select(TEST_TABLE_NAME, 'test1=False')[0]['test2']['y'] == 20.0
753+
assert ch.select(TEST_TABLE_NAME, 'test1=False')[0]['test3'] == 'azaza\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
752754

753755
mysql.execute(
754756
f"INSERT INTO {TEST_TABLE_NAME} (test1, test2) VALUES "

0 commit comments

Comments
 (0)