mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1182 - Error when applied disjunction to filterMany
This commit is contained in:
@@ -995,7 +995,7 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
|
||||
return this;
|
||||
}
|
||||
|
||||
private Junction<T> junction(Junction.Type type) {
|
||||
protected Junction<T> junction(Junction.Type type) {
|
||||
Junction<T> junction = expr.junction(type, query, this);
|
||||
add(junction);
|
||||
return junction;
|
||||
|
||||
@@ -5,6 +5,7 @@ import io.ebean.ExpressionList;
|
||||
import io.ebean.FutureIds;
|
||||
import io.ebean.FutureList;
|
||||
import io.ebean.FutureRowCount;
|
||||
import io.ebean.Junction;
|
||||
import io.ebean.OrderBy;
|
||||
import io.ebean.Query;
|
||||
import io.ebeaninternal.api.SpiExpressionList;
|
||||
@@ -36,6 +37,13 @@ public class FilterExpressionList<T> extends DefaultExpressionList<T> {
|
||||
this.rootQuery = rootQuery;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Junction<T> junction(Junction.Type type) {
|
||||
Junction<T> junction = expr.junction(type, rootQuery, this);
|
||||
add(junction);
|
||||
return junction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpiExpressionList<?> trimPath(int prefixTrim) {
|
||||
return new FilterExpressionList<>(pathPrefix.trimPath(prefixTrim), this);
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.tests.model.basic.ResetBasicData;
|
||||
import org.ebeantest.LoggedSqlCollector;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -42,6 +43,25 @@ public class TestQueryFilterMany extends BaseTestCase {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDisjunction() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
LoggedSqlCollector.start();
|
||||
|
||||
Ebean.find(Customer.class)
|
||||
.filterMany("orders")
|
||||
.or()
|
||||
.eq("status", Order.Status.NEW)
|
||||
.eq("orderDate", LocalDate.now())
|
||||
.findList();
|
||||
|
||||
List<String> sql = LoggedSqlCollector.stop();
|
||||
assertEquals(2, sql.size());
|
||||
assertThat(sql.get(1)).contains("and (t0.status = ? or t0.order_date = ?");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNestedFilterMany() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user