#2436 - SQL Update doesn't handle named parameters for array types in Postgres

This commit is contained in:
Rob Bygrave committed 2021-11-26 14:46:06 +13:00
1 parent 9af64f61f7
commit 07f9bf98c3
10 files changed
+80 -5

No files matched your search

@@ -208,19 +208,33 @@ public class DtoQueryTest extends BaseTestCase {
ResetBasicData.reset();
LoggedSql.start();
List<Integer> ids = Arrays.asList(1, 2);
List<DCust> list = server().findDto(DCust.class, "select id, name from o_customer where id = any(?)")
List<DCust> list = DB.findDto(DCust.class, "select id, name from o_customer where id = any(?)")
.setParameter(ids)
.findList();
assertThat(list).isNotEmpty();
list = server().findDto(DCust.class, "select id, name from o_customer where id in (:idList)")
List<DCust> list1 = DB.findDto(DCust.class, "select id, name from o_customer where id in (:idList)")
.setParameter("idList", ids)
.findList();
assertThat(list).isNotEmpty();
assertThat(list1).isNotEmpty();
List<DCust> list2 = DB.findDto(DCust.class, "select id, name from o_customer where id = any(:idList)")
.setArrayParameter("idList", ids)
.findList();
assertThat(list2).isNotEmpty();
List<String> sql = LoggedSql.stop();
assertThat(sql).hasSize(3);
assertThat(sql.get(0)).contains(" id = any(?)");
assertThat(sql.get(1)).contains(" id in (?,?)");
assertThat(sql.get(2)).contains(" id = any(?)");
}
@ForPlatform(Platform.POSTGRES)
@@ -335,7 +335,7 @@ public class TestDbArray_basic extends BaseTestCase {
// javax.persistence.PersistenceException:
// ERROR: syntax error at or near "$2"
SqlUpdate update2 = DB.sqlUpdate("UPDATE earray_bean SET phone_numbers = :pns")
.setParameter("pns", phNumbers);
.setArrayParameter("pns", phNumbers);
update2.execute();
found = DB.find(EArrayBean.class, bean.getId());
@@ -22,7 +22,7 @@ ebean.ddl.generate=true
ebean.ddl.run=true
ebean.ddl.header=-- Generated by ebean ${version} at ${timestamp}
ebean.packages=org.tests,org.etest
datasource.default=h2
datasource.default=pg
#datasource.h2.capturestacktrace=true
ebean.dumpMetricsOnShutdown=true