mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-10-23 23:28:55 +00:00
No effective change - add test for @Aggregation with order by clause
This commit is contained in:
@@ -3,10 +3,10 @@ package org.tests.query.aggregation;
|
||||
import io.ebean.BaseTestCase;
|
||||
import io.ebean.Ebean;
|
||||
import io.ebean.Query;
|
||||
import org.tests.model.tevent.TEventMany;
|
||||
import org.tests.model.tevent.TEventOne;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.tests.model.tevent.TEventMany;
|
||||
import org.tests.model.tevent.TEventOne;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -90,6 +90,23 @@ public class TestAggregationCount extends BaseTestCase {
|
||||
assertThat(version).isNotNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOrderByTotal() {
|
||||
|
||||
Query<TEventOne> query = Ebean.find(TEventOne.class)
|
||||
.select("name, count, totalUnits, totalAmount")
|
||||
.orderBy().asc("totalUnits").order().asc("name");
|
||||
|
||||
List<TEventOne> list = query.findList();
|
||||
assertThat(list).isNotEmpty();
|
||||
|
||||
String sql = sqlOf(query, 5);
|
||||
assertThat(sql).contains("select distinct t0.id, t0.name, count(u1.id), sum(u1.units), sum(u1.units * u1.amount), sum(u1.units), t0.name from tevent_one t0 ");
|
||||
assertThat(sql).contains("from tevent_one t0 join tevent_many u1 on u1.event_id = t0.id ");
|
||||
assertThat(sql).contains(" group by t0.id, t0.name ");
|
||||
assertThat(sql).contains(" order by sum(u1.units), t0.name");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSelectOnly() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user