DATAJDBC-560 - Fix Criteria mapping when composing a group from top-level criteria.

Using Criteria.from(…) with multiple Criteria objects now uses properly AND combination along with group nesting to render a correct criteria. Previously, the INITIAL combinator in groups caused a mapping exception.
This commit is contained in:
Mark Paluch
2020-06-09 15:31:14 +02:00
parent 81aba29fda
commit eeeb188117
2 changed files with 20 additions and 4 deletions

View File

@@ -126,6 +126,20 @@ public class QueryMapperUnitTests {
.hasToString("person.\"NAME\" = ?[:name] AND (person.\"NAME\" = ?[:name1] OR person.age < ?[:age])");
}
@Test // DATAJDBC-560
public void shouldMapFromConcat() {
Criteria criteria = Criteria.from(Criteria.where("name").is("Foo"), Criteria.where("name").is("Bar") //
.or("age").lessThan(49));
assertThat(criteria.isEmpty()).isFalse();
Condition condition = map(criteria);
assertThat(condition)
.hasToString("(person.\"NAME\" = ?[:name] AND (person.\"NAME\" = ?[:name1] OR person.age < ?[:age]))");
}
@Test // DATAJDBC-318
public void shouldMapSimpleCriteria() {