add test for cast() with parameters in numeric expressions

This commit is contained in:
Gavin King 2023-07-25 13:07:48 +02:00
parent b53732d141
commit d3a1b4f33e
1 changed files with 20 additions and 0 deletions

View File

@ -1354,6 +1354,26 @@ public class FunctionTests {
);
}
@Test
public void testAddDurationWithParameter(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
session.createQuery("select 2 * cast(?1 as BigDecimal)")
.setParameter(1, BigDecimal.valueOf(123.446))
.getSingleResult();
session.createQuery("select 2 * cast(?1 as BigDecimal(7,4))")
.setParameter(1, BigDecimal.valueOf(123.446))
.getSingleResult();
session.createQuery("select cast(2 as BigDecimal) * ?1")
.setParameter(1, BigDecimal.valueOf(123.446))
.getSingleResult();
session.createQuery("select cast(:dt as LocalDateTime) + 1 day")
.setParameter("dt", LocalDateTime.now())
.getSingleResult();
}
);
}
@Test
public void testInstantCast(SessionFactoryScope scope) {
scope.inTransaction(