Merge pull request #1971 from querydsl/i1969

Fix null handling
This commit is contained in:
Timo Westkämper 2016-07-22 18:42:38 +03:00 committed by GitHub
commit bb3fed6609
2 changed files with 10 additions and 1 deletions

View File

@ -195,7 +195,7 @@ public final class CollQueryFunctions {
}
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;

View File

@ -9,6 +9,15 @@ import org.junit.Test;
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");