#2774 - Postgres ANY / MultiValueSupport with byte[]/binary data

Add Postgres specific support for binding an array of byte[] with ANY(?)
which is used as with client side encryption where the bind values are
implicitly converted to byte[].

Fixes Postgres specific failure running TestEncryptClientSide.java
This commit is contained in:
Rob Bygrave
2022-11-07 22:25:32 +13:00
parent 2789d0f97c
commit 14dddb4866
3 changed files with 13 additions and 25 deletions
@@ -95,7 +95,7 @@ public final class InExpression extends AbstractExpression implements IdInCommon
public void prepareExpression(BeanQueryRequest<?> request) {
initBindValues();
if (bindValues.size() > 0) {
multiValueSupported = request.isMultiValueSupported((bindValues.get(0)).getClass());
multiValueSupported = request.isMultiValueSupported(bindValues.get(0).getClass());
}
}
@@ -149,7 +149,6 @@ public final class InExpression extends AbstractExpression implements IdInCommon
// if we have no property, we wrap them in a multi value wrapper.
// later the binder will decide, which bind strategy to use.
request.addBindValue(new MultiValueWrapper(values));
}
@Override
@@ -164,7 +163,6 @@ public final class InExpression extends AbstractExpression implements IdInCommon
}
ElPropertyValue prop = getElProp(request);
if (prop != null) {
if (prop.isAssocId()) {
request.append(prop.assocIdInExpr(propName));
@@ -172,15 +170,13 @@ public final class InExpression extends AbstractExpression implements IdInCommon
return;
}
if (prop.isDbEncrypted()) {
String dsql = prop.beanProperty().decryptProperty(propName);
request.append(dsql);
request.append(prop.beanProperty().decryptProperty(propName));
request.appendInExpression(not, bindValues);
return;
}
}
request.append(propName);
request.appendInExpression(not, bindValues);
}
/**
@@ -7,25 +7,7 @@ import io.ebeaninternal.server.bind.DataBind;
import java.sql.SQLException;
import java.util.Collection;
import static java.sql.Types.BIGINT;
import static java.sql.Types.BIT;
import static java.sql.Types.BOOLEAN;
import static java.sql.Types.CHAR;
import static java.sql.Types.DATE;
import static java.sql.Types.DECIMAL;
import static java.sql.Types.DOUBLE;
import static java.sql.Types.FLOAT;
import static java.sql.Types.INTEGER;
import static java.sql.Types.NCHAR;
import static java.sql.Types.NUMERIC;
import static java.sql.Types.NVARCHAR;
import static java.sql.Types.REAL;
import static java.sql.Types.SMALLINT;
import static java.sql.Types.TIMESTAMP;
import static java.sql.Types.TIMESTAMP_WITH_TIMEZONE;
import static java.sql.Types.TIME_WITH_TIMEZONE;
import static java.sql.Types.TINYINT;
import static java.sql.Types.VARCHAR;
import static java.sql.Types.*;
/**
* Base MultiValueBind for platform specific support.
@@ -86,6 +68,8 @@ abstract class AbstractMultiValueBind extends MultiValueBind {
case ExtraDbTypes.UUID: // Postgres cast to uuid[]
case ExtraDbTypes.INET: // Postgres cast to inet[]
return "varchar";
case VARBINARY:
return "bytea";
default:
return null;
@@ -17,6 +17,14 @@ public class MultiValueBind {
}
Object[] toArray(Collection<?> values, ScalarType<?> type) {
if (type.binary()) {
byte[][] array = new byte[values.size()][];
int i = 0;
for (Object value : values) {
array[i++] = (byte[])type.toJdbcType(value);
}
return array;
}
Object[] array = new Object[values.size()];
int i = 0;
for (Object value : values) {