#1645 - ENH: Add expression rawOrEmpty() ... as a convenience for conditionally added a raw expression

This commit is contained in:
rob bygrave
2019-03-05 23:03:22 +13:00
parent 7e8424328f
commit 27f86548a6
5 changed files with 12 additions and 4 deletions
@@ -57,5 +57,11 @@ public class TestSqlRowUUID extends BaseTestCase {
.findList();
assertThat(result).hasSize(1);
List<TUuidEntity> list = Ebean.find(TUuidEntity.class)
.where().rawOrEmpty("id = any(?::uuid[])", ids)
.findList();
assertThat(list).hasSize(1);
}
}
@@ -72,10 +72,12 @@ public class TestWhereRawClause extends BaseTestCase {
ResetBasicData.reset();
List<String> vals = asList("Rob", "Fiona", "Jack");
Query<Customer> query = Ebean.find(Customer.class)
.select("name")
.where()
.rawOrEmpty("id in (select c.id from o_customer c where c.name in (?1))", asList("Rob", "Fiona", "Jack"))
.rawOrEmpty("id in (select c.id from o_customer c where c.name in (?1))", vals)
.query();
List<Customer> list = query.findList();