Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #40 #41

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
TheoLechemia marked this conversation as resolved.
Show resolved Hide resolved
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
Loading