diff --git a/libs/commcare b/libs/commcare index ba1345886..20946a6a8 160000 --- a/libs/commcare +++ b/libs/commcare @@ -1 +1 @@ -Subproject commit ba13458866b89e015bae8362e1947f456ee03802 +Subproject commit 20946a6a81041467d4c4e31f26b780b483921177 diff --git a/src/main/java/org/commcare/formplayer/sandbox/SqlStorage.java b/src/main/java/org/commcare/formplayer/sandbox/SqlStorage.java index b2cb1d262..7d960b5d2 100644 --- a/src/main/java/org/commcare/formplayer/sandbox/SqlStorage.java +++ b/src/main/java/org/commcare/formplayer/sandbox/SqlStorage.java @@ -607,6 +607,32 @@ public void deleteStorage() { } + @Override + public Vector getBulkIdsForIndex(String indexName, Collection matchingValues) { + Vector ids = new Vector<>(); + String fieldName = TableBuilder.scrubName(indexName); + List> whereParamList = TableBuilder.sqlList(matchingValues, "?"); + try { + for (Pair querySet : whereParamList) { + try (PreparedStatement selectStatement = SqlHelper.prepareTableSelectStatement( + connectionHandler.getConnection(), + tableName, + fieldName + " IN " + querySet.first, + querySet.second)) { + + try (ResultSet resultSet = selectStatement.executeQuery()) { + while (resultSet.next()) { + ids.add(resultSet.getInt(DatabaseHelper.ID_COL)); + } + } + } + } + return ids; + } catch (SQLException e) { + throw new SQLiteRuntimeException(e); + } + } + /** * Retrieves a set of the models in storage based on a list of values matching one if the * indexes of this storage