Skip to content

Commit

Permalink
fix PnX-SI#40
Browse files Browse the repository at this point in the history
  • Loading branch information
hypsug0 committed Aug 30, 2023
1 parent d8f05ee commit 073446d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/utils_flask_sqla/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 073446d

Please sign in to comment.