@@ -2607,3 +2607,49 @@ def test_ignore_deletes():
26072607 finally :
26082608 # Clean up the temporary config file
26092609 os .unlink (config_file )
2610+
2611+ def test_issue_160_unknown_mysql_type_bug ():
2612+ """
2613+ Test to reproduce the bug from issue #160.
2614+
2615+ Bug Description: Replication fails when adding a new table during realtime replication
2616+ with Exception: unknown mysql type ""
2617+
2618+ This test should FAIL until the bug is fixed.
2619+ When the bug is present: parsing will fail with unknown mysql type and the test will FAIL
2620+ When the bug is fixed: parsing will succeed and the test will PASS
2621+ """
2622+ # The exact CREATE TABLE statement from the bug report
2623+ create_table_query = """create table test_table
2624+ (
2625+ id bigint not null,
2626+ col_a datetime(6) not null,
2627+ col_b datetime(6) null,
2628+ col_c varchar(255) not null,
2629+ col_d varchar(255) not null,
2630+ col_e int not null,
2631+ col_f decimal(20, 10) not null,
2632+ col_g decimal(20, 10) not null,
2633+ col_h datetime(6) not null,
2634+ col_i date not null,
2635+ col_j varchar(255) not null,
2636+ col_k varchar(255) not null,
2637+ col_l bigint not null,
2638+ col_m varchar(50) not null,
2639+ col_n bigint null,
2640+ col_o decimal(20, 1) null,
2641+ col_p date null,
2642+ primary key (id, col_e)
2643+ );"""
2644+
2645+ # Create a converter instance
2646+ converter = MysqlToClickhouseConverter ()
2647+
2648+ # This should succeed when the bug is fixed
2649+ # When the bug is present, this will raise "unknown mysql type """ and the test will FAIL
2650+ mysql_structure , ch_structure = converter .parse_create_table_query (create_table_query )
2651+
2652+ # Verify the parsing worked correctly
2653+ assert mysql_structure .table_name == 'test_table'
2654+ assert len (mysql_structure .fields ) == 17 # All columns should be parsed
2655+ assert mysql_structure .primary_keys == ['id' , 'col_e' ]
0 commit comments