Permalink
Browse files

Fix null handling

1 parent 1a1b7f4 commit 300f88d9c5e7d5dd65ef688eec582a3e00d3b41c @timowest timowest committed Jul 16, 2016
@@ -195,7 +195,7 @@ public static int getYearWeek(Date date) {
}
public static <T> Collection<T> leftJoin(Collection<T> coll) {
- if (coll.isEmpty()) {
+ if (coll == null || coll.isEmpty()) {
@SuppressWarnings("unchecked") // List only contains null
Collection<T> rv = (Collection<T>) nullList;
return rv;
@@ -10,6 +10,15 @@
public class CollectionAnyTest extends AbstractQueryTest {
@Test
+ public void any_null() {
+ Cat a = new Cat("a");
+ a.setKittens(null);
+
+ assertEquals(0, CollQueryFactory.from(cat, Arrays.asList(a))
+ .where(cat.kittens.any().name.startsWith("a")).fetchCount());
+ }
+
+ @Test
public void any_in_projection() {
Cat a = new Cat("a");
Cat aa = new Cat("aa");

0 comments on commit 300f88d

Please sign in to comment.