From e99d9c27242848b042ac6d3ffe99a55fcf1b7ceb Mon Sep 17 00:00:00 2001 From: Davide D'Alto Date: Sat, 9 Jul 2022 13:42:39 +0100 Subject: [PATCH] [#26284] Test select-distinct with .project --- .../main/java/io/quarkus/it/panache/TestEndpoint.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/TestEndpoint.java b/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/TestEndpoint.java index 336bfa6798f4c..a694e37098f4a 100644 --- a/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/TestEndpoint.java +++ b/integration-tests/hibernate-orm-panache/src/main/java/io/quarkus/it/panache/TestEndpoint.java @@ -1236,6 +1236,16 @@ public String testProjection() { Assertions.assertNull(aggregationProjection.getOwnerName()); Assertions.assertEquals(bubulle.weight, aggregationProjection.getWeight()); + PanacheQuery projectionDistinctQuery = Cat + // The spaces at the beginning are intentional + .find(" SELECT disTINct c.name, cast(null as string), SUM(c.weight) from Cat c where name = :name group by name ", + Parameters.with("name", bubulle.name)) + .project(CatProjectionBean.class); + CatProjectionBean aggregationDistinctProjection = projectionDistinctQuery.singleResult(); + Assertions.assertEquals(bubulle.name, aggregationDistinctProjection.getName()); + Assertions.assertNull(aggregationDistinctProjection.getOwnerName()); + Assertions.assertEquals(bubulle.weight, aggregationDistinctProjection.getWeight()); + long count = projectionQuery.count(); Assertions.assertEquals(1L, count);