Skip to content

Commit

Permalink
Add missing double arguments to jdbc union
Browse files Browse the repository at this point in the history
  • Loading branch information
gmokki committed Apr 27, 2020
1 parent 4c1dbad commit 10dc0d4
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -514,10 +514,12 @@ public WorkflowInstance getWorkflowInstance(long id, Set<WorkflowInstanceInclude

public WorkflowInstance getWorkflowInstance(long id, Set<WorkflowInstanceInclude> includes, Long maxActions, boolean queryArchive) {
String sql = "select *, 0 as archived from " + MAIN.nameOf("workflow") + " where id = ?";
Object[] args = new Object[]{id};
if (queryArchive) {
sql += " union all select *, 1 as archived from " + ARCHIVE.nameOf("workflow") + " where id = ?";
args = new Object[]{id, id};
}
WorkflowInstance instance = jdbc.queryForObject(sql, new WorkflowInstanceRowMapper(), id).build();
WorkflowInstance instance = jdbc.queryForObject(sql, args, new WorkflowInstanceRowMapper()).build();
if (includes.contains(WorkflowInstanceInclude.CURRENT_STATE_VARIABLES)) {
fillState(instance);
}
Expand Down Expand Up @@ -710,12 +712,13 @@ private void fillChildWorkflowIds(final WorkflowInstance instance, boolean query
Stream<TablePrefix> tables = queryArchive ? Stream.of(MAIN, ARCHIVE) : Stream.of(MAIN);
String sql = tables.map(tablePrefix -> "select parent_action_id, id from " + tablePrefix.nameOf("workflow") + " where parent_workflow_id = ?")
.collect(joining(" union all "));
jdbc.query(sql, rs -> {
Object[] args = queryArchive ? new Object[]{instance.id, instance.id} : new Object[]{instance.id};
jdbc.query(sql, args, rs -> {
long parentActionId = rs.getLong(1);
long childWorkflowInstanceId = rs.getLong(2);
List<Long> children = instance.childWorkflows.computeIfAbsent(parentActionId, k -> new ArrayList<>());
children.add(childWorkflowInstanceId);
}, instance.id);
});
}

private long getMaxResults(Long maxResults) {
Expand Down

0 comments on commit 10dc0d4

Please sign in to comment.