Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,12 @@ private From<?,?> join(From<?,?> root, String[] path) {

@SuppressWarnings("rawtypes")
private From<?,?> join(From<?,?> source, String attributeName) {
Optional<Join> existingJoin = source.getJoins().stream().filter(join->join.getAttribute().getName().equals(attributeName)).map(join->(Join)join).findFirst();
return existingJoin.orElseGet(()->source.join(attributeName, currentJoinType));
Optional<Join> existingJoin = source.getJoins().stream()
.map(join -> (Join) join)
.filter(join -> join.getAttribute().getName().equals(attributeName))
.filter(join -> join.getJoinType() == currentJoinType)
.findFirst();
return existingJoin.orElseGet(() -> source.join(attributeName, currentJoinType));
}

private static Class<?> boxed(Class<?> type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,25 @@ void testFilterWithOrConstraintPartialMatch() {
assertEquals(6, dao.count(pf));
}

@Test
void testIsNullConstraintAfterOrDoesNotMatchAbsentCity() {
// Without the OR, city.population IS NULL correctly returns 0:
// persistedPerson has no city, so the INNER JOIN on city excludes them.
PersonFilter baseline = new PersonFilter();
baseline.addConstraint(ConstraintBuilder.of("id").equal(persistedPerson.getId()));
baseline.addConstraint(ConstraintBuilder.of("city", "population").isNull());
assertEquals(0, dao.count(baseline));

// Adding an OR that includes persistedPerson should not change the result:
// the IS NULL constraint still requires city to exist, regardless of the OR.
PersonFilter withOr = new PersonFilter();
withOr.addConstraint(
ConstraintBuilder.of("city", "id").equal(cities.get(0).getId())
.or(ConstraintBuilder.of("id").equal(persistedPerson.getId())));
withOr.addConstraint(ConstraintBuilder.of("city", "population").isNull());
assertEquals(0, dao.count(withOr));
}

@Test
@Disabled
void testDelete() {
Expand Down
Loading