Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1122,9 +1122,7 @@ private void executeUpdate(
for (Object param : params) {
ps.setObject(idx++, param);
}
for (Object param : filterParams.getObjectParams().values()) {
ps.setObject(idx++, param);
}
filterParams.bindTo(connection, ps, idx);
int rowsUpdated = ps.executeUpdate();
LOGGER.debug("Rows updated: {}", rowsUpdated);
} catch (SQLException e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package org.hypertrace.core.documentstore.postgres;

import java.sql.Array;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import lombok.Getter;
Expand All @@ -26,6 +30,21 @@ public Map<Integer, Object> getObjectParams() {
return objectParams;
}

public int bindTo(Connection connection, PreparedStatement ps, int startIndex)
throws SQLException {
int idx = startIndex;
for (Object value : objectParams.values()) {
if (value instanceof ArrayParam) {
ArrayParam arrayParam = (ArrayParam) value;
Array sqlArray = connection.createArrayOf(arrayParam.getSqlType(), arrayParam.getValues());
ps.setArray(idx++, sqlArray);
} else {
ps.setObject(idx++, value);
}
}
return idx;
}

public static Builder newBuilder() {
return new Builder();
}
Expand Down
Loading