Updated db.py to comply to sqlalchemy 1.4 #85
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixed Issue #79 by switching table.count() to equivalent calls to func.count().
Description
Ran into Issue #79 trying to install and run gourmand from AUR on Arch Linux.
I switched to func.count() following the sqlalchemy 1.4 API doc. As func.count() needs an attribute to run on, I chose to use the primary key of the table for that (usually just an int and present). Another candidate would have been table.c[0].
How Has This Been Tested?
Looked at the generated Query structure in fetch_len():
yields:
... which I guess is what was the purpose of that. The code returns plausible values for the count() queries ("1" with the criterium above, "1638" without).
Also the fixed code works fine so far with sqlalchemy 1.4, however I could not find out how to get the application to actually call fetch_len() with a set of criteria. Also I didn't dig deeper into esp. make_simple_select_arg(), and this is just a quick fix.
Please verify.
Style (of the changed bits) checks out with pylint / PEP8.
Types of changes
[x] Updated use of library, removed deprecated function
Checklist:
[x] My code follows the code style of this project.
[ ] My change requires a change to the documentation.
[ ] I have updated the documentation accordingly.