Not compatible with SQLAlchemy >= 1.4.
Apteryks opened this issue · comments
When attempting to run the test suite, I get:
self = <gourmet.backends.db.RecData object at 0x7f991c503af0>
table = Table('keylookup', MetaData(bind=Engine(sqlite:////home/maxim/.gourmet/recipes.db)), Column('id', Integer(), table=<ke...=<keylookup>), Column('ingkey', Text(), table=<keylookup>), Column('count', Integer(), table=<keylookup>), schema=None)
criteria = {}
def fetch_len (self, table, **criteria):
"""Return the number of rows in table that match criteria
"""
if criteria:
return table.count(*make_simple_select_arg(criteria,table)).execute().fetchone()[0]
else:
> return table.count().execute().fetchone()[0]
E AttributeError: 'Table' object has no attribute 'count'
gourmet/backends/db.py:778: AttributeError
Steps to Reproduce
- Run the tests as the CI, making sure SQLAlchemy is at >= 1.4.
Expected Behavior
Tests should pass.
Current Behavior
Test fails with AttributeError: 'Table' object has no attribute 'count'
errors.
Possible Solution
Update code to not use the deprecated 'count' SQLAlchemy Table attribute.
Environment
Guix System with Python 3.9.9, using the latest commit of Gourmet.
Note: a similar issue exists for gourmand: GourmandRecipeManager/gourmand#79.
The solution is provided here: sqlalchemy/sqlalchemy#6053 (comment)
the Table.count() method has been deprecated since 2016 and has been removed in 1.4, so rdf-alchemy will need to adjust this code to use an explicit select(func.count()).select_from(table) instead.