mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
FIX: order by must be added in findEach also (#1163)
This commit is contained in:
committed by
Rob Bygrave
parent
1909ba1557
commit
fb1c7667cc
@@ -12,6 +12,7 @@ import org.ebeantest.LoggedSqlCollector;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -72,6 +73,32 @@ public class TestSecondaryQueries extends BaseTestCase {
|
||||
assertThat(trimSql(sql.get(0), 1)).contains("select t0.id, t0.name from o_customer t0 where t0.id in");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void fetchIterate() {
|
||||
|
||||
ResetBasicData.reset();
|
||||
|
||||
LoggedSqlCollector.start();
|
||||
|
||||
Iterator<Order> orders = Ebean.find(Order.class)
|
||||
.select("status")
|
||||
.setMaxRows(10)
|
||||
.setUseCache(false)
|
||||
.findIterate();
|
||||
while (orders.hasNext()) {
|
||||
orders.next(); // dummy read
|
||||
}
|
||||
List<String> sql = LoggedSqlCollector.stop();
|
||||
|
||||
assertThat(sql).hasSize(1);
|
||||
if (isSqlServer()) {
|
||||
assertThat(trimSql(sql.get(0), 2)).contains("select top 10 t0.id, t0.status from o_order t0 order by t0.id");
|
||||
} else {
|
||||
assertThat(trimSql(sql.get(0), 2)).contains("select t0.id, t0.status from o_order t0");
|
||||
}
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testSecQueryOneToMany() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user