FIX: orderBy does not work when used on formula property or in conjunction with "exists" query

This commit is contained in:
Roland Praml
2021-03-02 15:26:29 +01:00
parent 81e445e386
commit ef1143bb70
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())
}
}