#2196 - SQLException:Column "T0.ID" must be in the GROUP BY list - when findCount with having clause

This commit is contained in:
Robin Bygrave
2021-03-15 22:43:25 +13:00
parent 733886c70b
commit c2a87a0c88
2 changed files with 18 additions and 1 deletions
@@ -3,6 +3,7 @@ package org.tests.query.aggregation;
import io.ebean.BaseTestCase;
import io.ebean.Ebean;
import io.ebean.Query;
import io.ebeantest.LoggedSql;
import org.ebeantest.LoggedSqlCollector;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -91,6 +92,22 @@ public class TestAggregationCount extends BaseTestCase {
}
}
@Test
public void findCount_withHaving() {
Query<TEventOne> query = Ebean.find(TEventOne.class)
//.select("id, totalUnits")
.having()
.ge("totalUnits", 1)
.query();
LoggedSql.start();
int count = query.findCount();
List<String> sql = LoggedSql.stop();
assertThat(sql).hasSize(1);
assertThat(sql.get(0)).contains("group by t0.id");
assertThat(count).isGreaterThan(0);
}
@Test
public void testFull() {