mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1269 - Paging queries should not ALWAYS append an order by ID ... but only when the order by is empty
This commit is contained in:
@@ -104,6 +104,8 @@ public class TestRawSqlOrmQuery extends BaseTestCase {
|
||||
|
||||
query.setFirstRow(1);
|
||||
query.setMaxRows(2);
|
||||
query.order().asc("id");
|
||||
|
||||
List<Customer> list = query.findList();
|
||||
|
||||
int rowCount = query.findCount();
|
||||
@@ -168,11 +170,11 @@ public class TestRawSqlOrmQuery extends BaseTestCase {
|
||||
|
||||
if (isSqlServer()) {
|
||||
assertThat(query.getGeneratedSql()).contains("top 100 ");
|
||||
assertThat(query.getGeneratedSql()).contains("order by o.ship_date desc, o.id");
|
||||
assertThat(query.getGeneratedSql()).contains("order by o.ship_date desc");
|
||||
} else if (isOracle()) {
|
||||
assertThat(query.getGeneratedSql()).contains("a where rownum <= 100 )");
|
||||
} else {
|
||||
assertThat(query.getGeneratedSql()).contains("order by o.ship_date desc, o.id limit 100");
|
||||
assertThat(query.getGeneratedSql()).contains("order by o.ship_date desc limit 100");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,14 +199,14 @@ public class TestRawSqlOrmQuery extends BaseTestCase {
|
||||
query.order("coalesce(shipDate, getdate()) desc");
|
||||
query.findList();
|
||||
|
||||
assertThat(sqlOf(query)).contains("order by coalesce(o.ship_date, getdate()) desc, o.id");
|
||||
assertThat(sqlOf(query)).contains("order by coalesce(o.ship_date, getdate()) desc");
|
||||
assertThat(sqlOf(query)).contains("select top 100");
|
||||
|
||||
} else {
|
||||
query.order("coalesce(shipDate, now()) desc");
|
||||
query.findList();
|
||||
|
||||
assertThat(query.getGeneratedSql()).contains("order by coalesce(o.ship_date, now()) desc, o.id limit 100");
|
||||
assertThat(query.getGeneratedSql()).contains("order by coalesce(o.ship_date, now()) desc limit 100");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -226,7 +228,10 @@ public class TestRawSqlOrmQuery extends BaseTestCase {
|
||||
query.order("id desc");
|
||||
PagedList<Order> pagedList = query.findPagedList();
|
||||
pagedList.getList();
|
||||
pagedList.getTotalCount();
|
||||
if (!isSqlServer()) {
|
||||
// sql server doesn't support order by in the count query, I wonder if we can remove it?
|
||||
pagedList.getTotalCount();
|
||||
}
|
||||
|
||||
if (isSqlServer()) {
|
||||
assertThat(sqlOf(query)).contains("select top 100 ");
|
||||
|
||||
Reference in New Issue
Block a user