#1331 - ENH: Support Aggregation formula with findSingleAttribute() ... max, min, avg, count and count(distinct ..)

This commit is contained in:
Rob Bygrave
2018-03-06 12:58:43 +13:00
parent ec2c3b13d4
commit 3ca4efc818
23 changed files with 783 additions and 51 deletions
@@ -99,6 +99,21 @@ public class TestQuerySingleAttribute extends BaseTestCase {
assertThat(name).isNotNull();
}
@Test
public void findSingleAttribute_with_aggregate() {
ResetBasicData.reset();
Query<Customer> query = Ebean.find(Customer.class)
.select("max(name)")
.where().gt("id", 1).query();
String name = query.findSingleAttribute();
assertThat(sqlOf(query)).contains("select max(t0.name) from o_customer t0");
assertThat(name).isNotNull();
}
@Test
public void findSingleAttribute_viaExpression() {