From 073446dc42a5bad6b65662c32951edbd4609dee0 Mon Sep 17 00:00:00 2001 From: Fred C <42280769+hypsug0@users.noreply.github.com> Date: Wed, 30 Aug 2023 10:46:13 +0200 Subject: [PATCH] fix #40 --- src/utils_flask_sqla/generic.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utils_flask_sqla/generic.py b/src/utils_flask_sqla/generic.py index d98a1b3..169f1ee 100644 --- a/src/utils_flask_sqla/generic.py +++ b/src/utils_flask_sqla/generic.py @@ -237,7 +237,7 @@ def build_query_order(self, query, parameters): return query.order_by(ordel_col) return query - def raw_query(self, process_filter=True): + def raw_query(self, process_filter=True, no_limit=False): """ Renvoie la requete 'brute' (sans .all) - process_filter: application des filtres (et du sort) @@ -251,7 +251,7 @@ def raw_query(self, process_filter=True): unordered_q = self.build_query_filters(q, self.filters) q = self.build_query_order(unordered_q, self.filters) - if self.limit != -1: + if self.limit != -1 and not no_limit: q = q.limit(self.limit).offset(self.offset * self.limit) return q @@ -263,9 +263,10 @@ def query(self): q = self.raw_query(process_filter=False) nb_result_without_filter = q.count() - q = self.raw_query() + q = self.raw_query(no_limit=True) nb_results = q.count() if self.filters else nb_result_without_filter + q = self.raw_query() data = q.all() return data, nb_result_without_filter, nb_results