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:
@@ -124,7 +124,7 @@ public class TestQueryFilterMany extends BaseTestCase {
|
||||
List<String> sqlList = LoggedSql.stop();
|
||||
assertEquals(2, sqlList.size());
|
||||
assertThat(sqlList.get(0)).contains("lower(t0.name) = ?");
|
||||
assertThat(sqlList.get(1)).contains("status = ?");
|
||||
assertThat(sqlList.get(1)).contains("t0.status = ?");
|
||||
|
||||
if (isH2() || isPostgresCompatible()) {
|
||||
assertThat(sqlList.get(0)).doesNotContain("offset");
|
||||
@@ -133,6 +133,51 @@ public class TestQueryFilterMany extends BaseTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterManyRaw_firstMaxRows_expressionFluidStyle() {
|
||||
ResetBasicData.reset();
|
||||
|
||||
LoggedSql.start();
|
||||
|
||||
final Query<Customer> query = DB.find(Customer.class)
|
||||
.where().ieq("name", "Rob")
|
||||
// use expression + fluid style adding maxRows/firstRow to filterMany
|
||||
.filterManyRaw("orders", "status = ?", Order.Status.NEW)
|
||||
.setMaxRows(100).setFirstRow(3).order("orderDate desc, id")
|
||||
.order().asc("id").setMaxRows(5);
|
||||
|
||||
final List<Customer> customers = query.findList();
|
||||
assertThat(customers).isNotEmpty();
|
||||
List<String> sqlList = LoggedSql.stop();
|
||||
assertEquals(2, sqlList.size());
|
||||
assertThat(sqlList.get(0)).contains("lower(t0.name) = ?");
|
||||
assertThat(sqlList.get(1)).contains("t0.status = ?");
|
||||
|
||||
if (isH2() || isPostgresCompatible()) {
|
||||
assertThat(sqlList.get(0)).doesNotContain("offset");
|
||||
assertThat(sqlList.get(0)).contains(" limit 5");
|
||||
assertThat(sqlList.get(1)).contains(" order by t0.order_date desc, t0.id limit 100 offset 3");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterManyRaw_singleQuery() {
|
||||
ResetBasicData.reset();
|
||||
|
||||
LoggedSql.start();
|
||||
|
||||
final Query<Customer> query = DB.find(Customer.class)
|
||||
.where().ieq("name", "Rob")
|
||||
.filterManyRaw("orders", "status = ?", Order.Status.NEW)
|
||||
.order().asc("id");
|
||||
|
||||
final List<Customer> customers = query.findList();
|
||||
assertThat(customers).isNotEmpty();
|
||||
List<String> sqlList = LoggedSql.stop();
|
||||
assertEquals(1, sqlList.size());
|
||||
assertThat(sqlList.get(0)).contains(" where lower(t0.name) = ? and t1.status = ? order by t0.id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_with_findOne_rawSeparateQuery() {
|
||||
ResetBasicData.reset();
|
||||
|
||||
Reference in New Issue
Block a user