@@ -1677,4 +1677,44 @@ public void testAddAndRemoveRefilter() {
1677
1677
1678
1678
assertTableEquals (source .where ("FV in `A`, `B`" ), result );
1679
1679
}
1680
+
1681
+ @ Test
1682
+ public void testWhereFilterEquality () {
1683
+ final Table x = TableTools .newTable (intCol ("A" , 1 , 2 , 3 ), intCol ("B" , 4 , 2 , 1 ), stringCol ("S" , "A" , "B" , "C" ));
1684
+
1685
+ final WhereFilter f1 = WhereFilterFactory .getExpression ("A in 7" );
1686
+ final WhereFilter f2 = WhereFilterFactory .getExpression ("A in 8" );
1687
+ final WhereFilter f3 = WhereFilterFactory .getExpression ("A in 7" );
1688
+
1689
+ final Table ignored = x .where (Filter .and (f1 , f2 , f3 ));
1690
+
1691
+ assertEquals (f1 , f3 );
1692
+ assertNotEquals (f1 , f2 );
1693
+ assertNotEquals (f2 , f3 );
1694
+
1695
+ final WhereFilter fa = WhereFilterFactory .getExpression ("A in 7" );
1696
+ final WhereFilter fb = WhereFilterFactory .getExpression ("B in 7" );
1697
+ final WhereFilter fap = WhereFilterFactory .getExpression ("A not in 7" );
1698
+
1699
+ final Table ignored2 = x .where (Filter .and (fa , fb , fap ));
1700
+
1701
+ assertNotEquals (fa , fb );
1702
+ assertNotEquals (fa , fap );
1703
+ assertNotEquals (fb , fap );
1704
+
1705
+ final WhereFilter fs = WhereFilterFactory .getExpression ("S icase in `A`" );
1706
+ final WhereFilter fs2 = WhereFilterFactory .getExpression ("S icase in `A`, `B`, `C`" );
1707
+ final WhereFilter fs3 = WhereFilterFactory .getExpression ("S icase in `A`, `B`, `C`" );
1708
+ final Table ignored3 = x .where (Filter .and (fs , fs2 , fs3 ));
1709
+ assertNotEquals (fs , fs2 );
1710
+ assertNotEquals (fs , fs3 );
1711
+ assertEquals (fs2 , fs3 );
1712
+
1713
+ final WhereFilter fof1 = WhereFilterFactory .getExpression ("A = B" );
1714
+ final WhereFilter fof2 = WhereFilterFactory .getExpression ("A = B" );
1715
+ final Table ignored4 = x .where (fof1 );
1716
+ final Table ignored5 = x .where (fof2 );
1717
+ // the ConditionFilters do not compare as equal, so this is unfortunate, but expected behavior
1718
+ assertNotEquals (fof1 , fof2 );
1719
+ }
1680
1720
}
0 commit comments