Skip to content

Don't use type(None) as fallback for Computed or Identity #1237

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

Closed
CaselIT opened this issue May 8, 2023 · 3 comments
Closed

Don't use type(None) as fallback for Computed or Identity #1237

CaselIT opened this issue May 8, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@CaselIT
Copy link
Member

CaselIT commented May 8, 2023

In old version of sqlalchemy, that don't have Computed or Identity a fallback in alembic is used.
The current fallback is to set these values to type(None)

This causes issues since checks like isinstance(something, Computed) will pass when something is None, leading to attribute errors.

@hustliyilin
Copy link

One of the examples is as the following:

File "/usr/local/lib/python3.6/site-packages/alembic/ddl/sqlite.py", line 56, in requires_recreate_in_batch
    and col.server_default.persisted
AttributeError: 'NoneType' object has no attribute 'persisted'

@sqla-tester
Copy link
Collaborator

Federico Caselli has proposed a fix for this issue in the main branch:

Fix compat issue with older SQLAlchemy versions. https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/4601

@zzzeek
Copy link
Member

zzzeek commented May 9, 2023

looks like we added "Computed" in 1.3.11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants