@@ -745,3 +745,47 @@ def test_info_tree_root(self):
745745 assert info_tree .info .is_diff
746746 assert info_tree .info .diff_count == 1000
747747 self .assertEqual (info_tree .info .rowcounts , {1 : 1000 , 2 : 2000 })
748+
749+
750+ class TestDuplicateTables (DiffTestCase ):
751+ db_cls = db .MySQL
752+
753+ src_schema = {"id" : int , "data" : str }
754+ dst_schema = {"id" : int , "data" : str }
755+
756+ def setUp (self ):
757+ """
758+ table 1:
759+ (12, 'ABCDE'),
760+ (12, 'ABCDE');
761+ table 2:
762+ (4,'ABCDEF'),
763+ (4,'ABCDE'),
764+ (4,'ABCDE'),
765+ (6,'ABCDE'),
766+ (6,'ABCDE'),
767+ (6,'ABCDE');
768+ """
769+
770+ super ().setUp ()
771+
772+ src_values = [(12 , "ABCDE" ), (12 , "ABCDE" )]
773+ dst_values = [(4 , "ABCDEF" ), (4 , "ABCDE" ), (4 , "ABCDE" ), (6 , "ABCDE" ), (6 , "ABCDE" ), (6 , "ABCDE" )]
774+
775+ self .diffs = [("-" , (str (r [0 ]), r [1 ])) for r in src_values ] + [("+" , (str (r [0 ]), r [1 ])) for r in dst_values ]
776+
777+ self .connection .query ([self .src_table .insert_rows (src_values ), self .dst_table .insert_rows (dst_values ), commit ])
778+
779+ self .a = _table_segment (
780+ self .connection , self .table_src_path , "id" , extra_columns = ("data" ,), case_sensitive = False
781+ )
782+ self .b = _table_segment (
783+ self .connection , self .table_dst_path , "id" , extra_columns = ("data" ,), case_sensitive = False
784+ )
785+
786+ def test_duplicates (self ):
787+ """If there are duplicates in data, we want to return them as well"""
788+
789+ differ = HashDiffer (bisection_factor = 2 , bisection_threshold = 4 )
790+ diff = list (differ .diff_tables (self .a , self .b ))
791+ self .assertEqual (diff , self .diffs )
0 commit comments