Repository navigation
Render the expressions of expression indexes - #493
Open
jayhemnani9910 wants to merge 1 commit into
Open
jayhemnani9910 wants to merge 1 commit into
jayhemnani9910 wants to merge 1 commit into
Conversation
jayhemnani9910
force-pushed
the
fix/render-expression-indexes
branch
from
November 19, 2026 06:02
1013761 to
0bee308
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Expression indexes lose their expressions. From a Postgres table with
sqlacodegen writes
Index('users_email_lower', unique=True)andIndex('users_mixed', 'id').metadata.create_all()then fails (CREATE UNIQUE INDEX users_email_lower ON users ()), and the mixed index silently becomes a plain index onid, so a case-insensitive unique rule is lost.render_indexrendered onlyindex.columns. It now rendersindex.expressions, which SQLAlchemy reflects in order: column names as before, other expressions astext(...);textis imported when an index has one.Checklist
tests/) which would fail without your patch:test_expression_indexesCHANGES.rst). (PR link to be added once the PR exists)pytest: 159 passed; the 6tests/test_cli.pyfailures here (thesqlacodegenscript isn't on PATH in my venv) are the same without this change. Reflected the schema above from Postgres 16: the generated models nowcreate_allon an empty database, and both indexes come back withlower(email).