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

Not compatible with SQLAlchemy >= 1.4. #1035

Open
Apteryks opened this issue May 4, 2022 · 2 comments · May be fixed by #1036
Open

Not compatible with SQLAlchemy >= 1.4. #1035

Apteryks opened this issue May 4, 2022 · 2 comments · May be fixed by #1036

Comments

@Apteryks
Copy link

Apteryks commented May 4, 2022

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

  1. 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.

@Apteryks
Copy link
Author

Apteryks commented May 4, 2022

Note: a similar issue exists for gourmand: GourmandRecipeManager/gourmand#79.

@Apteryks
Copy link
Author

Apteryks commented May 4, 2022

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.

Apteryks added a commit to Apteryks/gourmet that referenced this issue May 4, 2022
Fixes thinkle#1035.

* gourmet/backends/db.py (RecData.fetch_len): Use
the sqlalchemy.func.count selector to return the table length.
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 a pull request may close this issue.

1 participant