From 9f16794010f9225daa97cd06fa5bc15b25451180 Mon Sep 17 00:00:00 2001 From: Julien Corny Date: Fri, 5 Apr 2024 12:10:49 +0200 Subject: [PATCH] fix bug negative limit --- src/utils_flask_sqla/generic.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/utils_flask_sqla/generic.py b/src/utils_flask_sqla/generic.py index 301f147..b020b3c 100644 --- a/src/utils_flask_sqla/generic.py +++ b/src/utils_flask_sqla/generic.py @@ -240,11 +240,10 @@ def build_query_order(self, query, parameters): def set_limit(self, q): return q.limit(self.limit).offset(self.offset * self.limit) - def raw_query(self, process_filter=True, with_limit=True): + def raw_query(self, process_filter=True): """ Renvoie la requete 'brute' (sans .all) - process_filter: application des filtres (et du sort) - - with_limit: application de la limite sur la query """ q = self.DB.session.query(self.view.tableDef) @@ -255,7 +254,7 @@ def raw_query(self, process_filter=True, with_limit=True): unordered_q = self.build_query_filters(q, self.filters) q = self.build_query_order(unordered_q, self.filters) - if self.limit != -1 and with_limit: + if self.limit != -1: q = self.set_limit(q) return q @@ -267,10 +266,10 @@ def query(self): q = self.DB.session.query(self.view.tableDef) nb_result_without_filter = q.count() - q = self.raw_query(process_filter=True, with_limit=False) + q = self.raw_query(process_filter=True) total_filtered = q.count() if self.filters else nb_result_without_filter - data = self.set_limit(q).all() + data = q.all() return data, nb_result_without_filter, total_filtered