From eb14531b6684daa79da374e2127955c0283af96b Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Fri, 29 Jul 2022 17:29:56 +1200 Subject: [PATCH] #2754 - Adjust test query for oneToMany_notNull() --- .../query/other/TestQuerySingleAttribute.java | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/ebean-test/src/test/java/org/tests/query/other/TestQuerySingleAttribute.java b/ebean-test/src/test/java/org/tests/query/other/TestQuerySingleAttribute.java index 89356d4fb..bfdf588d5 100644 --- a/ebean-test/src/test/java/org/tests/query/other/TestQuerySingleAttribute.java +++ b/ebean-test/src/test/java/org/tests/query/other/TestQuerySingleAttribute.java @@ -779,30 +779,22 @@ public class TestQuerySingleAttribute extends BaseTestCase { } @Test - public void oneToMany_notNull() { - + void oneToMany_notNull() { ResetBasicData.reset(); Query query = DB.find(Customer.class) + .setDistinct(true) .fetch("orders", "status") - .where() - .isNotNull("orders.status") + .filterMany("orders").isNotNull("status") .query(); - List statusList = query - .findSingleAttributeList(); + List statusList = query.findSingleAttributeList(); assertSql(query) .contains("select distinct t1.status from o_customer t0 " - + "left join o_order t1 on t1.kcustomer_id = t0.id and t1.order_date is not null and t1.status is not null") + + "left join o_order t1 on t1.kcustomer_id = t0.id and t1.order_date is not null where t1.status is not null") .doesNotContain("order by"); - // query was: select distinct t1.status from o_customer t0 - // left join o_order t1 on t1.kcustomer_id = t0.id and t1.order_date is not null - // join o_order u1 on u1.kcustomer_id = t0.id and u1.order_date is not null where u1.status is not null - // order by t0.id - // -> why order by t0.id? and query could be optimized by adding t1.status is not null instead of another join - // Results in JdbcSQLSyntaxErrorException: - // Order by expression "T0.ID" must be in the result list in this case - assertThat(statusList).hasSize(5); + + assertThat(statusList).hasSize(3); } @BeforeEach