mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-12 22:41:35 +00:00
#2436 - SQL Update doesn't handle named parameters for array types in Postgres
This commit is contained in:
1 parent
9af64f61f7
commit
07f9bf98c3
10 files changed
+80
-5
No files matched your search
@@ -223,6 +223,15 @@ public final class BindParams implements Serializable {
|
||||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a named In parameter that is multi-valued.
|
||||
*/
|
||||
public Param setArrayParameter(String name, Collection<?> value) {
|
||||
Param p = getParam(name);
|
||||
p.setInValue(new MultiValueWrapper(value));
|
||||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an encryption key as a bind value.
|
||||
* <p>
|
||||
|
||||
@@ -24,6 +24,7 @@ import io.ebeaninternal.server.querydefn.OrmUpdateProperties;
|
||||
import io.ebeaninternal.server.rawsql.SpiRawSql;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -399,6 +400,11 @@ public interface SpiQuery<T> extends Query<T>, SpiQueryFetch, TxnProfileEventCod
|
||||
|
||||
List<String> getSoftDeletePredicates();
|
||||
|
||||
/**
|
||||
* Bind the named multi-value array parameter which we would use with Postgres ANY.
|
||||
*/
|
||||
void setArrayParameter(String name, Collection<?> values);
|
||||
|
||||
/**
|
||||
* Return a copy of the query.
|
||||
*/
|
||||
|
||||
@@ -331,6 +331,12 @@ public final class DefaultSqlUpdate implements Serializable, SpiSqlUpdate {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlUpdate setArrayParameter(String name, Collection<?> values) {
|
||||
bindParams.setArrayParameter(name, values);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlUpdate setNull(String name, int jdbcType) {
|
||||
bindParams.setNullParameter(name, jdbcType);
|
||||
|
||||
@@ -14,6 +14,7 @@ import io.ebeaninternal.server.dto.DtoMappingRequest;
|
||||
import io.ebeaninternal.server.dto.DtoQueryPlan;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
@@ -148,6 +149,16 @@ public final class DefaultDtoQuery<T> extends AbstractQuery implements SpiDtoQue
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DtoQuery<T> setArrayParameter(String paramName, Collection<?> values) {
|
||||
if (ormQuery != null) {
|
||||
ormQuery.setArrayParameter(paramName, values);
|
||||
} else {
|
||||
bindParams.setArrayParameter(paramName, values);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DtoQuery<T> setParameters(Object... values) {
|
||||
if (ormQuery != null) {
|
||||
|
||||
@@ -1586,6 +1586,17 @@ public final class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setArrayParameter(String name, Collection<?> values) {
|
||||
if (namedParams != null) {
|
||||
throw new IllegalStateException("setArrayParameter() not supported when EQL parsed query");
|
||||
}
|
||||
if (bindParams == null) {
|
||||
bindParams = new BindParams();
|
||||
}
|
||||
bindParams.setArrayParameter(name, values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkPagingOrderBy() {
|
||||
return orderById && !useDocStore;
|
||||
|
||||
Reference in new issue
Block a user