Skip to content

Commit 8b70275

Browse files
author
Bartek Ogryczak
committed
unittest for another scenario for issue julien-duponchelle#118. PR julien-duponchelle#117 does not fix that one
1 parent 783e5a5 commit 8b70275

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

pymysqlreplication/tests/test_basic.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,27 @@ def test_drop_column(self):
585585
finally:
586586
self.resetBinLog()
587587

588+
def test_alter_column(self):
589+
self.stream.close()
590+
self.execute("CREATE TABLE test_drop_column (id INTEGER(11), data VARCHAR(50))")
591+
self.execute("INSERT INTO test_drop_column VALUES (1, 'A value')")
592+
self.execute("COMMIT")
593+
# this is a problem only when column is added in position other than at the end
594+
self.execute("ALTER TABLE test_drop_column ADD COLUMN another_data VARCHAR(50) AFTER id")
595+
self.execute("INSERT INTO test_drop_column VALUES (2, 'Another value', 'A value')")
596+
self.execute("COMMIT")
597+
598+
self.stream = BinLogStreamReader(
599+
self.database,
600+
server_id=1024,
601+
only_events=(WriteRowsEvent,),
602+
)
603+
event = self.stream.fetchone() # insert with two values
604+
# both of these asserts fail because of issue underlying proble described in issue #118
605+
self.assertEqual(event.rows[0]["values"]["data"], 'A value')
606+
self.assertNotEqual(event.rows[0]["values"]["another_data"], 'A value')
607+
self.stream.fetchone() # insert with three values
608+
588609

589610
class TestGtidBinLogStreamReader(base.PyMySQLReplicationTestCase):
590611
def setUp(self):

0 commit comments

Comments
 (0)