-
-
Notifications
You must be signed in to change notification settings - Fork 253
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
Attribute type change in Mapped[] not detected #1247
Comments
no reason this wouldn't work other than if you don't have compare_types configured, can you ensure you have that set to True? |
can't reproduce locally, setting up version one, then changing as: class File(Base):
__tablename__ = "file"
id: Mapped[int] = mapped_column(primary_key=True)
# change type from str to int
#size: Mapped[Optional[str]]
size: Mapped[Optional[int]]
the
migration script: def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('file', 'size',
existing_type=sa.VARCHAR(),
type_=sa.Integer(),
existing_nullable=True)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('file', 'size',
existing_type=sa.Integer(),
type_=sa.VARCHAR(),
existing_nullable=True)
# ### end Alembic commands ### note compare_types=True with connectable.connect() as connection:
context.configure(
compare_type=True,
connection=connection, target_metadata=target_metadata
)
with context.begin_transaction():
context.run_migrations() |
Adding I have used Alembic for years, but seldom do changes to my configuration when it is working. I was surprised that Thank you so much @zzzeek for super fast help! |
the type comparison logic was never considered to be that "stable" for many years and we did not want false positives . it was rewritten a few years ago so that false positives are very unlikely. |
do you think it would make sense to flip that to true by default in 1.12? |
seems scary |
aren't false positive very unlikely (cit) now? :) |
you're more the alembic maintainer now, fire at will |
well, I've added #1248 so we can look into it |
Describe the bug
If I change the type of an attribute in my model, only defined by the
Mapped
annotation, then I do not get any changes in the resulting upgrade script:alembic revision -m "Change not detected" --autogenerate
Not expected:
Expected behavior
I expect an alter_column statement a la:
To Reproduce
I am very aware that this may be a problem on my side, and I think it is difficult to provide a complete example setup.
Versions.
Additional context
Doing other changes to my model class, for instance, removing the
Optional
keyword or adding/removing/renaming, results in an expected change (except still no type change).Have a nice day!
The text was updated successfully, but these errors were encountered: