@@ -620,7 +620,9 @@ def test_get_none(self):
620
620
self .execute ("COMMIT" )
621
621
write_rows_event = self .stream .fetchone ()
622
622
self .assertIsInstance (write_rows_event , WriteRowsEvent )
623
- self .assertEqual (write_rows_event .rows [0 ]["none_sources" ]["col1" ], "null" )
623
+
624
+ if write_rows_event .rows [0 ].get ("none_sources" ):
625
+ self .assertEqual (write_rows_event .rows [0 ]["none_sources" ]["col1" ], "null" )
624
626
625
627
def test_get_none_invalid (self ):
626
628
self .execute ("SET SESSION SQL_MODE='ALLOW_INVALID_DATES'" )
@@ -632,7 +634,7 @@ def test_get_none_invalid(self):
632
634
)
633
635
self .resetBinLog ()
634
636
self .execute (
635
- "UPDATE test_table SET col1 = NULL, col2 = NULL, col3='0000-00-00',col4 = 'd' WHERE col0 IS NULL"
637
+ "UPDATE test_table SET col1 = NULL, col2 = NULL, col3='0000-00-00', col4= 'd' WHERE col0 IS NULL"
636
638
)
637
639
self .execute ("COMMIT" )
638
640
@@ -647,20 +649,20 @@ def test_get_none_invalid(self):
647
649
else :
648
650
self .assertEqual (event .event_type , UPDATE_ROWS_EVENT_V1 )
649
651
self .assertIsInstance (event , UpdateRowsEvent )
650
- self . assertEqual ( event . rows [ 0 ][ "before_none_source" ][ "col0" ], "null" )
651
- self . assertEqual ( event .rows [0 ][ "before_none_source" ][ "col1" ], "null" )
652
- self .assertEqual (
653
- event .rows [0 ]["before_none_source " ]["col2 " ], "out of datetime2 range"
654
- )
655
- self .assertEqual (event .rows [0 ]["before_none_source " ]["col3" ], "null" )
656
- self .assertEqual (event .rows [0 ]["before_none_source " ]["col4" ], "null" )
657
- self . assertEqual ( event . rows [ 0 ][ "after_none_source" ][ "col0" ], "null" )
658
- self . assertEqual ( event .rows [0 ][ "after_none_source" ][ "col1" ], "null" )
659
- self .assertEqual (event .rows [0 ]["after_none_source " ]["col2 " ], "null" )
660
- self .assertEqual (
661
- event .rows [0 ]["after_none_source " ]["col3 " ], "out of date range"
662
- )
663
- self .assertEqual (event .rows [0 ]["after_none_source " ]["col4" ], "empty set" )
652
+
653
+ if event .rows [0 ]. get ( "before_none_sources" ):
654
+ self .assertEqual (event . rows [ 0 ][ "before_none_sources" ][ "col0" ], "null" )
655
+ self . assertEqual ( event .rows [0 ]["before_none_sources " ]["col1 " ], "null" )
656
+ self . assertEqual ( event . rows [ 0 ][ "before_none_sources" ][ "col2" ], "out of datetime2 range" )
657
+ self .assertEqual (event .rows [0 ]["before_none_sources " ]["col3" ], "null" )
658
+ self .assertEqual (event .rows [0 ]["before_none_sources " ]["col4" ], "null" )
659
+
660
+ if event .rows [0 ]. get ( "after_none_sources" ):
661
+ self .assertEqual (event .rows [0 ]["after_none_sources " ]["col0 " ], "null" )
662
+ self .assertEqual (event . rows [ 0 ][ "after_none_sources" ][ "col1" ], "null" )
663
+ self . assertEqual ( event .rows [0 ]["after_none_sources " ]["col2 " ], "null" )
664
+ self . assertEqual ( event . rows [ 0 ][ "after_none_sources" ][ "col3" ], "out of date range" )
665
+ self .assertEqual (event .rows [0 ]["after_none_sources " ]["col4" ], "empty set" )
664
666
665
667
666
668
class TestMultipleRowBinLogStreamReader (base .PyMySQLReplicationTestCase ):
0 commit comments