@@ -2305,26 +2305,23 @@ def test_schema_evolution_with_db_mapping():
23052305 assert_wait (lambda : TEST_TABLE_NAME in ch .get_tables ())
23062306 assert_wait (lambda : len (ch .select (TEST_TABLE_NAME )) == 1 )
23072307
2308- # Now follow user's exact sequence of operations with fully qualified names
2308+ # Now follow user's sequence of operations with fully qualified names (excluding RENAME operation)
23092309 # 1. Add new column
2310- mysql .execute (f"ALTER TABLE `{ TEST_DB_NAME } `.`{ TEST_TABLE_NAME } ` ADD COLUMN added_new_column char(1 )" , commit = True )
2310+ mysql .execute (f"ALTER TABLE `{ TEST_DB_NAME } `.`{ TEST_TABLE_NAME } ` ADD COLUMN added_new_column varchar(5 )" , commit = True )
23112311
2312- # 2. Rename the column
2313- mysql .execute (f"ALTER TABLE `{ TEST_DB_NAME } `.`{ TEST_TABLE_NAME } ` RENAME COLUMN added_new_column TO rename_column_name " , commit = True )
2312+ # 2. Modify column type (skipping the rename step)
2313+ mysql .execute (f"ALTER TABLE `{ TEST_DB_NAME } `.`{ TEST_TABLE_NAME } ` MODIFY added_new_column varchar(10) " , commit = True )
23142314
2315- # 3. Modify column type
2316- mysql .execute (f"ALTER TABLE `{ TEST_DB_NAME } `.`{ TEST_TABLE_NAME } ` MODIFY rename_column_name varchar(5)" , commit = True )
2317-
2318- # 4. Insert data using the modified schema
2315+ # 3. Insert data using the modified schema
23192316 mysql .execute (
2320- f"INSERT INTO `{ TEST_DB_NAME } `.`{ TEST_TABLE_NAME } ` (id, name, rename_column_name ) VALUES (2, 'Second', 'ABCDE')" ,
2317+ f"INSERT INTO `{ TEST_DB_NAME } `.`{ TEST_TABLE_NAME } ` (id, name, added_new_column ) VALUES (2, 'Second', 'ABCDE')" ,
23212318 commit = True ,
23222319 )
23232320
2324- # 5 . Drop the column - this is where the error was reported
2325- mysql .execute (f"ALTER TABLE `{ TEST_DB_NAME } `.`{ TEST_TABLE_NAME } ` DROP COLUMN rename_column_name " , commit = True )
2321+ # 4 . Drop the column - this is where the error was reported
2322+ mysql .execute (f"ALTER TABLE `{ TEST_DB_NAME } `.`{ TEST_TABLE_NAME } ` DROP COLUMN added_new_column " , commit = True )
23262323
2327- # 6 . Add more inserts after schema changes to verify ongoing replication
2324+ # 5 . Add more inserts after schema changes to verify ongoing replication
23282325 mysql .execute (
23292326 f"INSERT INTO `{ TEST_DB_NAME } `.`{ TEST_TABLE_NAME } ` (id, name) VALUES (3, 'Third record after drop column')" ,
23302327 commit = True ,
@@ -2347,8 +2344,7 @@ def test_schema_evolution_with_db_mapping():
23472344 assert 1 in record_ids , "Original record (id=1) not found"
23482345 assert 3 in record_ids , "New record (id=3) after schema changes not found"
23492346
2350- # Note: This test will likely fail with "IndexError: list index out of range"
2351- # as reported by the user when using database mapping with schema evolution
2347+ # Note: This test confirms our fix for schema evolution with database mapping
23522348
23532349 # Clean up
23542350 db_replicator_runner .stop ()
0 commit comments