From 72d2ad22ebf6ed55a8bac2ee5f15d86c3e6004b9 Mon Sep 17 00:00:00 2001 From: Esa Puttonen Date: Thu, 3 Oct 2024 17:20:13 +0300 Subject: [PATCH] Fix action filling in query workflows from archive --- .../engine/internal/dao/WorkflowInstanceDao.java | 2 +- .../engine/internal/dao/MaintenanceDaoTest.java | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/nflow-engine/src/main/java/io/nflow/engine/internal/dao/WorkflowInstanceDao.java b/nflow-engine/src/main/java/io/nflow/engine/internal/dao/WorkflowInstanceDao.java index afacf6a77..cb1ccf592 100644 --- a/nflow-engine/src/main/java/io/nflow/engine/internal/dao/WorkflowInstanceDao.java +++ b/nflow-engine/src/main/java/io/nflow/engine/internal/dao/WorkflowInstanceDao.java @@ -809,7 +809,7 @@ private void fillActions(WorkflowInstance instance, boolean includeStateVariable long maxActions = getMaxActions(requestedMaxActions); String tableName = ACTION.tableFor(instance); String sql = sqlVariants - .limit("select nflow_workflow_action.* from " + tableName + " where workflow_id = ? order by id desc", maxActions); + .limit("select * from " + tableName + " where workflow_id = ? order by id desc", maxActions); List actionBuilders = jdbc.query(sql, workflowInstanceActionRowMapper, instance.id); if (includeStateVariables) { diff --git a/nflow-engine/src/test/java/io/nflow/engine/internal/dao/MaintenanceDaoTest.java b/nflow-engine/src/test/java/io/nflow/engine/internal/dao/MaintenanceDaoTest.java index 37de1e9fc..96d30364e 100644 --- a/nflow-engine/src/test/java/io/nflow/engine/internal/dao/MaintenanceDaoTest.java +++ b/nflow-engine/src/test/java/io/nflow/engine/internal/dao/MaintenanceDaoTest.java @@ -29,6 +29,7 @@ import io.nflow.engine.model.ModelObject; import io.nflow.engine.service.WorkflowInstanceInclude; +import io.nflow.engine.workflow.instance.QueryWorkflowInstances; import io.nflow.engine.workflow.instance.WorkflowInstance; import io.nflow.engine.workflow.instance.WorkflowInstanceAction; @@ -177,6 +178,9 @@ public void archiveWorkflowsWithActionsWorks() { assertEquals(actionIds.size(), getArchiveActionCount()); assertEquals(actionCountAfter, actionCountBefore - actionIds.size()); + + assertWorkflowActionsThroughQuery(archivable1, 1); + assertWorkflowActionsThroughQuery(archivable2, 3); } @Test @@ -476,6 +480,15 @@ private void assertArchivedWorkflowsDoNotExist(List workflowIds) { } } + private void assertWorkflowActionsThroughQuery(Long workflowId, int expectedActions) { + List archivedWorkflow = workflowInstanceDao.queryWorkflowInstances(new QueryWorkflowInstances.Builder() + .setQueryArchive(true) + .setIncludeActions(true) + .addIds(workflowId) + .build()); + assertEquals(archivedWorkflow.get(0).actions.size(), expectedActions); + } + private void assertActiveActionsRemoved(List actionIds) { for (long actionId : actionIds) { int found = rowCount("select 1 from nflow_workflow_action where id = ?", actionId);