From 60d6604eff19fe210b15fd4b5c65eb50b80c9953 Mon Sep 17 00:00:00 2001 From: Avgustin Marinov Date: Tue, 28 Oct 2025 11:27:06 +0200 Subject: [PATCH] Fix limited DS complete filtering when and becomes comparison (#2780) Signed-off-by: Avgustin Marinov --- .../rest/resource/MgmtDistributionSetResourceTest.java | 9 ++++++++- .../jpa/management/JpaDistributionSetManagement.java | 7 +++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java index 11de5c9f5..4110159d4 100644 --- a/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java +++ b/hawkbit-mgmt/hawkbit-mgmt-resource/src/test/java/org/eclipse/hawkbit/mgmt/rest/resource/MgmtDistributionSetResourceTest.java @@ -1344,7 +1344,14 @@ class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegrationTe .andExpect(jsonPath("size", equalTo(10))) .andExpect(jsonPath("total", equalTo(10))); - // and more complex (case insensitive) query + // and more complex (logical and to comparison conversion) query + mvc.perform(get("/rest/v1/distributionsets?q=complete==true;valid==true")) + .andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("size", equalTo(10))) + .andExpect(jsonPath("total", equalTo(10))); + + // and more complex (case-insensitive) query mvc.perform(get("/rest/v1/distributionsets?q=complete==true;valid==true;id=IN=(" + String.join(",", dsIds) + ")")) .andDo(MockMvcResultPrinter.print()) .andExpect(status().isOk()) diff --git a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetManagement.java b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetManagement.java index 139477bd1..8f23eba10 100644 --- a/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetManagement.java +++ b/hawkbit-repository/hawkbit-repository-jpa/src/main/java/org/eclipse/hawkbit/repository/jpa/management/JpaDistributionSetManagement.java @@ -135,8 +135,11 @@ public class JpaDistributionSetManagement sanitizedChildren.add(child); } }); - specList.add(QLSupport.getInstance() - .buildSpec(new Node.Logical(Node.Logical.Operator.AND, sanitizedChildren), DistributionSetFields.class)); + specList.add(QLSupport.getInstance().buildSpec( + sanitizedChildren.size() == 1 + ? sanitizedChildren.get(0) + : new Node.Logical(Node.Logical.Operator.AND, sanitizedChildren), + DistributionSetFields.class)); } if (completedComparison.get() != null) { // really a comparison log.warn("Usage of 'complete' in RSQL is deprecated and will be removed in future: {}", node);