You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Autogenerate does not support sort options on indexes #1213
Expected behavior
To factor in index ordering in the autogenerate index detection.
Versions.
OS: MacOS
Python: 3.11
Alembic: 1.10.2
SQLAlchemy: 2.0.7
Database: Postgresql 13.8
DBAPI: asyncpg
Additional context
I figured since alembic can generate a multicolumn index with ordering it would compare the indexes properly. Though I don't really see any documentation on the site so it might just be the way I'm generating it is not correct.
I can get around the detection for now by just omitting the ordering in the table definition after applying the migration.
This is a regression of 5c71fd1, since desc('created_at') and desc(literal_column('created_at')) are considered expression indexes while desc(column('created_at')) is not.
@zzzeek it seems that alembic does not detect changes of order at all, I'll restore that behavior also for pg, but maybe we could add support for it?
changed the title [-]Autogenerate unable to properly compare multicolumn index with order clause[/-][+]Autogenerate does not support order on indexes[/+]on Apr 4, 2023
Activity
CaselIT commentedon Apr 4, 2023
Hi,
Thanks for reporting. I think index order is supported, but I'll try looking if we have problem there.
CaselIT commentedon Apr 4, 2023
Using
desc(column('created_at'))is a workaround for now.Using either
desc('created_at')ordesc(literal_column('created_at'))has the above issue insteadCaselIT commentedon Apr 4, 2023
This is a regression of 5c71fd1, since
desc('created_at')anddesc(literal_column('created_at'))are considered expression indexes whiledesc(column('created_at'))is not.@zzzeek it seems that alembic does not detect changes of order at all, I'll restore that behavior also for pg, but maybe we could add support for it?
CaselIT commentedon Apr 4, 2023
seems easier just to support order in the index
[-]Autogenerate unable to properly compare multicolumn index with order clause[/-][+]Autogenerate does not support order on indexes[/+]CaselIT commentedon Apr 4, 2023
the fact that the default sorting is not reported is a bit annoying, but I should have this working.
@zzzeek I think 1.10.3 can be released without this issue, we can target 1.11 for this
[-]Autogenerate does not support order on indexes[/-][+]Autogenerate does not support sort options on indexes[/+]sqla-tester commentedon Apr 6, 2023
CaselIT has proposed a fix for this issue in the main branch:
Use column sort in index compare on postgresql https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/4550
Use column sort in index compare on postgresql