From a16aff6bfda87d707042710580981cf04b6f3217 Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Fri, 18 Feb 2022 17:12:58 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D1=83=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=B8=20=D1=81=D0=BE=D1=80=D1=82=D0=B8=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../haiti/filter/quarkus/QuarkusFilter.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/dev/struchkov/haiti/filter/quarkus/QuarkusFilter.java b/src/main/java/dev/struchkov/haiti/filter/quarkus/QuarkusFilter.java index aa85aac..e770360 100644 --- a/src/main/java/dev/struchkov/haiti/filter/quarkus/QuarkusFilter.java +++ b/src/main/java/dev/struchkov/haiti/filter/quarkus/QuarkusFilter.java @@ -14,6 +14,7 @@ import org.jooq.DSLContext; import org.jooq.Query; import org.jooq.conf.ParamType; +import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.function.Consumer; @@ -29,6 +30,7 @@ public class QuarkusFilter { private final PgPool pgPool; private final CriteriaJooqFilter jooqFilter; private PageableOffset offset; + private final List sortFieldNames = new ArrayList<>(); private QuarkusFilter(PgPool pgPool, String table, DSLContext dslContext) { dslContext.settings().withParamType(ParamType.NAMED_OR_INLINED); @@ -79,17 +81,26 @@ public class QuarkusFilter { } public QuarkusFilter sort(SortContainer container) { - jooqFilter.sort(container); + if (container != null && container.getFieldName() != null) { + jooqFilter.sort(container); + sortFieldNames.add(container.getFieldName()); + } return this; } public QuarkusFilter sort(String field, SortType sortType) { - jooqFilter.sort(field, sortType); + if (field != null) { + jooqFilter.sort(field, sortType); + sortFieldNames.add(field); + } return this; } public QuarkusFilter sort(String field) { - jooqFilter.sort(field); + if (field != null) { + jooqFilter.sort(field); + sortFieldNames.add(field); + } return this; } @@ -125,6 +136,7 @@ public class QuarkusFilter { public Uni> filterResult(Class idType, String idField) { jooqFilter.groupBy(idField); + jooqFilter.groupBy(sortFieldNames); distinctCount = true; final Uni count = count(); final Uni> content = build(idType, idField);