mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Add filterManyRaw() and Deprecate filterMany( <string expressions> )
The filterMany( <string expressions> ) uses the language parser which ultimately will we probably remove in ebean 15.x Code can migrate to filterManyRaw() instead or better yet change to use the improved query beans filterMany( <closure> ) option that will be included in this same ebean release.
This commit is contained in:
@@ -280,6 +280,41 @@ public class QCustomerTest {
|
||||
assertThat(q.getGeneratedSql()).isEqualTo("select t0.id, t0.name, t1.id, t1.first_name, t1.last_name from be_customer t0 left join be_contact t1 on t1.customer_id = t0.id where t1.first_name like ? escape'|' order by t0.id");
|
||||
}
|
||||
|
||||
@Test
|
||||
void filterManySeparateQuery() {
|
||||
Customer cust = new Customer();
|
||||
cust.setName("filterManySeparateQuery");
|
||||
cust.setStatus(Customer.Status.GOOD);
|
||||
cust.save();
|
||||
|
||||
var q = new QCustomer()
|
||||
.select(FGCustomerContacts)
|
||||
.contacts.filterManyRaw("firstName like ?", "R%")
|
||||
.contacts.filterMany(c -> c.firstName.startsWith("R")) // same as filterManyRaw() expression
|
||||
.setMaxRows(10) // force the ToMany path to be in a separate secondary query
|
||||
.query();
|
||||
|
||||
q.findList();
|
||||
assertThat(q.getGeneratedSql()).isEqualTo("select t0.id, t0.name from be_customer t0 limit 10");
|
||||
}
|
||||
|
||||
@Test
|
||||
void filterManySingleQuery() {
|
||||
Customer cust = new Customer();
|
||||
cust.setName("filterManySingleQuery");
|
||||
cust.setStatus(Customer.Status.GOOD);
|
||||
cust.save();
|
||||
|
||||
var q = new QCustomer()
|
||||
.select(FGCustomerContacts)
|
||||
.contacts.filterManyRaw("firstName like ?", "R%")
|
||||
.contacts.filterMany(c -> c.firstName.startsWith("R")) // same as filterManyRaw() expression
|
||||
.query();
|
||||
|
||||
q.findList();
|
||||
assertThat(q.getGeneratedSql()).isEqualTo("select t0.id, t0.name from be_customer t0 limit 10");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIdIn() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user