Merge pull request #2188 from FOCONIS/fix-order-by

FIX: orderBy does not work when used on formula property
This commit is contained in:
Rob Bygrave
2021-07-13 16:41:33 +12:00
committed by GitHub
3 changed files with 55 additions and 2 deletions
@@ -1,10 +1,14 @@
package org.tests.basic;
import io.ebean.BaseTestCase;
import io.ebean.DB;
import io.ebean.Ebean;
import io.ebean.FutureIds;
import io.ebean.Query;
import io.ebeantest.LoggedSql;
import org.tests.model.basic.Order;
import org.tests.model.basic.OrderDetail;
import org.tests.model.basic.ResetBasicData;
import org.junit.Test;
@@ -36,4 +40,36 @@ public class TestFetchId extends BaseTestCase {
List<Object> idList = futureIds.get();
assertThat(idList).isNotEmpty();
}
@Test
public void testFetchIdWithExists() throws InterruptedException, ExecutionException {
ResetBasicData.reset();
Query<OrderDetail> subQuery = Ebean.find(OrderDetail.class)
.alias("sq")
.where().raw("details.id = sq.id").query();
Query<Order> query = Ebean.find(Order.class)
.where().exists(subQuery)
.orderBy("orderDate").query();
List<Object> ids = query.findIds();
// TODO: assert(query.getGeneratedSql())
assertThat(ids).isNotEmpty();
FutureIds<Order> futureIds = query.findFutureIds();
// wait for all the id's to be fetched
List<Object> idList = futureIds.get();
assertThat(idList).isNotEmpty();
}
@Test
public void testFetchIdWithOrderFormula() throws InterruptedException, ExecutionException {
ResetBasicData.reset();
Query<Order> query = DB.find(Order.class).orderBy("totalItems");
query.findIds();
// TODO: assert(query.getGeneratedSql())
}
}