FIX for filterMany with raw expression with single SQL query

Fix for the case where the filterMany is not executed on a separate
query but instead part of the origin query.

The fix is to use the appropriate DeployParser and also fix the path
alias like ${} -> ${contacts}
This commit is contained in:
Rob Bygrave
2023-08-19 13:54:38 +12:00
parent 9756c9133e
commit 8a4024ecfc
3 changed files with 64 additions and 2 deletions
@@ -152,6 +152,24 @@ public class TestQueryFilterMany extends BaseTestCase {
assertThat(sql.get(1)).contains("from o_order t0 join o_customer t1 on t1.id = t0.kcustomer_id where");
}
@Test
public void test_with_findOne_rawSameQuery() {
ResetBasicData.reset();
LoggedSql.start();
var result = DB.find(Customer.class)
.order().asc("id")
.fetch("orders")
.filterMany("orders").raw("orderDate is not null")
.findList();
assertThat(result).isNotEmpty();
List<String> sql = LoggedSql.stop();
assertThat(sql).hasSize(1);
assertThat(sql.get(0)).contains("from o_customer t0 left join o_order t1");
assertThat(sql.get(0)).contains("where t1.order_date is not null");
}
@Test
public void test_with_findOneOrEmpty() {