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

GenericQuery: fix bug negative limit #51

Merged
merged 3 commits into from
Apr 18, 2024

Conversation

JulienCorny
Copy link

Il me semble qu'il y a un bug entre la version 0.3.3 et la version 0.4.1 quand on utilise limit=-1 dans la GenericQuery :
{"code": 500, "description": "(psycopg2.errors.InvalidRowCountInLimitClause) LIMIT must not be negative}

J'ai ce bug quand je clique sur le bouton 'générer la liste des espèces' (qui utilise Generic Query) dans le module zones humides (onglet 5) lorsque la version de Utils-Flask-SQLAlchemy est 0.4.1 mais pas lorsque qu'elle est en 0.3.3.

Voici une proposition de correction avec suppression de l'argument with_limit. J'ai peut-être manqué quelque chose mais je ne comprends pas vraiment en quoi cet argument est utile ? Si limit=-1 de toute façon il n'y a pas de limite et sinon on renseigne la limite souhaitée.

Copy link

codecov bot commented Apr 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.72%. Comparing base (f627a16) to head (9f16794).

❗ Current head 9f16794 differs from pull request most recent head 5babc3f. Consider uploading reports for the commit 5babc3f to get more accurate results

Additional details and impacted files
@@           Coverage Diff            @@
##           develop      #51   +/-   ##
========================================
  Coverage    82.72%   82.72%           
========================================
  Files            4        4           
  Lines          272      272           
========================================
  Hits           225      225           
  Misses          47       47           
Flag Coverage Δ
pytest 82.72% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@jacquesfize jacquesfize left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok pour moi. En effet, c'est bizarre comme comportement... Juste une petite modification et je merge 👍

@@ -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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if self.limit != -1:
if self.limit >0:

@jacquesfize
Copy link
Contributor

jacquesfize commented Apr 10, 2024

Tu fais la modification ou je la fais ? Si je la fais, il faudrait que tu me donnes les droits.

@jacquesfize jacquesfize added this to the 0.4.2 milestone Apr 18, 2024
@jacquesfize jacquesfize merged commit e11d81a into PnX-SI:develop Apr 18, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants