#1694 - findList() with firstRows/maxRows adds "order by id" (even with orderById(false))

This commit is contained in:
rob bygrave
2019-05-03 14:33:42 +12:00
parent e4569f9362
commit 4aa8a0dc63
11 changed files with 98 additions and 22 deletions
@@ -0,0 +1,37 @@
package org.tests.query;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.Query;
import org.junit.Test;
import org.tests.model.basic.Customer;
import static org.assertj.core.api.StrictAssertions.assertThat;
public class TestQueryOrderById extends BaseTestCase {
@Test
public void orderById_default_expectNotOrderById() {
Query<Customer> query = DB.find(Customer.class)
.select("id,name")
.setFirstRow(1)
.setMaxRows(5);
query.findList();
assertThat(sqlOf(query)).isEqualTo("select t0.id, t0.name from o_customer t0 limit 5 offset 1");
}
@Test
public void orderById_whenTrue_expectOrderById() {
Query<Customer> query = DB.find(Customer.class)
.select("id,name")
.setFirstRow(1)
.setMaxRows(5)
.orderById(true);
query.findList();
assertThat(sqlOf(query)).isEqualTo("select t0.id, t0.name from o_customer t0 order by t0.id limit 5 offset 1");
}
}