@@ -68,6 +68,16 @@ public void compareTable(Table table) throws Exception {
6868 pkColumnsTuple + "=(" + removedSlaveOneRaw .getPk () + ")" ));
6969 }
7070 }
71+ //remove all master rows if required
72+ if (masterRows .size () > 0 ) {
73+ for (OneRow unmatchedMasterOneRow :masterRows ) {
74+ dataDifferences .add (new SchemaDifference (Criticality .ERROR ,
75+ table .getTableName (),
76+ DifferenceType .DATA_ROW_MISSING_IN_SLAVE_TABLE ,
77+ pkColumnsTuple + "=(" + unmatchedMasterOneRow .getPk () + ")" ));
78+ }
79+ masterRows = new ArrayList <OneRow >();
80+ }
7181 }
7282 else {
7383 //no matching PK, so add to masterRows
@@ -103,6 +113,16 @@ public void compareTable(Table table) throws Exception {
103113 pkColumnsTuple + "=(" + removedMasterOneRaw .getPk () + ")" ));
104114 }
105115 }
116+ //remove all slave rows if required
117+ if (slaveRows .size () > 0 ) {
118+ for (OneRow unmatchedSlaveOneRow :slaveRows ) {
119+ dataDifferences .add (new SchemaDifference (Criticality .ERROR ,
120+ table .getTableName (),
121+ DifferenceType .DATA_ROW_EXCESS_IN_SLAVE_TABLE ,
122+ pkColumnsTuple + "=(" + unmatchedSlaveOneRow .getPk () + ")" ));
123+ }
124+ slaveRows = new ArrayList <OneRow >();
125+ }
106126 }
107127 else {
108128 //no matching PK, so add to slaveRows
@@ -115,18 +135,18 @@ public void compareTable(Table table) throws Exception {
115135 }
116136
117137 //rows not found in slave table
118- for (OneRow masterOneRow :masterRows ) {
138+ for (OneRow unmatchedMasterOneRow :masterRows ) {
119139 dataDifferences .add (new SchemaDifference (Criticality .ERROR ,
120140 table .getTableName (),
121141 DifferenceType .DATA_ROW_MISSING_IN_SLAVE_TABLE ,
122- pkColumnsTuple + "=(" + masterOneRow .getPk () + ")" ));
142+ pkColumnsTuple + "=(" + unmatchedMasterOneRow .getPk () + ")" ));
123143 }
124144 //rows not found in master table
125- for (OneRow slaveOneRow :slaveRows ) {
145+ for (OneRow unmatchedSlaveOneRow :slaveRows ) {
126146 dataDifferences .add (new SchemaDifference (Criticality .ERROR ,
127147 table .getTableName (),
128148 DifferenceType .DATA_ROW_EXCESS_IN_SLAVE_TABLE ,
129- pkColumnsTuple + "=(" + slaveOneRow .getPk () + ")" ));
149+ pkColumnsTuple + "=(" + unmatchedSlaveOneRow .getPk () + ")" ));
130150 }
131151 slaveResultSet .close ();
132152 slaveStatement .close ();
0 commit comments