#1333 - ENH: Support "dynamic formula" with findSingleAttributeList() ... e.g. .select("concat(lastName,', ',firstName)")

Concat automatically maps to String ScalarType
This commit is contained in:
Rob Bygrave
2018-03-06 17:35:26 +13:00
parent c1c85b67c2
commit e1af7c29eb
2 changed files with 35 additions and 7 deletions
@@ -402,4 +402,25 @@ public class TestAggregationCount extends BaseTestCase {
assertThat(sql.get(0)).contains("select concat(t0.last_name,', ',t0.first_name) from contact t0 where t0.phone is null order by t0.last_name");
}
@Test
public void concat_expectString() {
ResetBasicData.reset();
LoggedSqlCollector.start();
List<String> names =
Ebean.find(Contact.class)
.select("concat(updtime,', ',firstName)")
.where().isNull("phone")
.orderBy().asc("lastName")
.findSingleAttributeList();
assertThat(names).isNotEmpty();
List<String> sql = LoggedSqlCollector.stop();
assertThat(sql.get(0)).contains("select concat(t0.updtime,', ',t0.first_name) from contact t0");
}
}