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

Support cast of formula like ... select("max(updtime)::Instant")
This commit is contained in:
Rob Bygrave
2018-03-06 20:58:30 +13:00
parent e1af7c29eb
commit 873c14faaf
8 changed files with 208 additions and 74 deletions
@@ -15,6 +15,7 @@ import org.tests.model.tevent.TEventMany;
import org.tests.model.tevent.TEventOne;
import java.sql.Timestamp;
import java.time.Instant;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
@@ -423,4 +424,24 @@ public class TestAggregationCount extends BaseTestCase {
assertThat(sql.get(0)).contains("select concat(t0.updtime,', ',t0.first_name) from contact t0");
}
@Test
public void explicitCast() {
ResetBasicData.reset();
LoggedSqlCollector.start();
Instant instant =
Ebean.find(Contact.class)
.select("max(updtime)::Instant")
.where().isNull("phone")
.findSingleAttribute();
assertThat(instant).isNotNull();
List<String> sql = LoggedSqlCollector.stop();
assertThat(sql.get(0)).contains("select max(t0.updtime) from contact t0 where t0.phone is null");
}
}