#2754 - Adjust test query for oneToMany_notNull()

This commit is contained in:
Rob Bygrave
2022-07-29 17:29:56 +12:00
parent 6c1a3647f9
commit eb14531b66
@@ -779,30 +779,22 @@ public class TestQuerySingleAttribute extends BaseTestCase {
}
@Test
public void oneToMany_notNull() {
void oneToMany_notNull() {
ResetBasicData.reset();
Query<Customer> query = DB.find(Customer.class)
.setDistinct(true)
.fetch("orders", "status")
.where()
.isNotNull("orders.status")
.filterMany("orders").isNotNull("status")
.query();
List<Order.Status> statusList = query
.findSingleAttributeList();
List<Order.Status> 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