From ac97444ad1aa5a2a791e9009d171e43fbe3e8940 Mon Sep 17 00:00:00 2001 From: Rob Bygrave Date: Wed, 27 Dec 2017 13:49:46 +1300 Subject: [PATCH] No effective change - add test for @Aggregation with order by clause --- .../aggregation/TestAggregationCount.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/tests/query/aggregation/TestAggregationCount.java b/src/test/java/org/tests/query/aggregation/TestAggregationCount.java index 12d05c37b..8d9bb5705 100644 --- a/src/test/java/org/tests/query/aggregation/TestAggregationCount.java +++ b/src/test/java/org/tests/query/aggregation/TestAggregationCount.java @@ -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 query = Ebean.find(TEventOne.class) + .select("name, count, totalUnits, totalAmount") + .orderBy().asc("totalUnits").order().asc("name"); + + List 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() {