mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#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:
@@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user