-
Notifications
You must be signed in to change notification settings - Fork 282
WIP: Fix ignoring kwargs and ensure deterministic output (#439) #440
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
base: master
Are you sure you want to change the base?
Conversation
|
@luliangce very nice, very nice 👏 Please add an entry to |
Should be good now, please take another look |
|
@agronholm wdyt? |
agronholm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with this, but I do wonder about the claim about randomness. Is this something that was actually observed to happen?
@luliangce can you elaborate more about random re-ordering? |
|
@sheinbergon @agronholm Sorry — as I continued looking into how SQLAlchemy retrieves index kwargs during reflection and what kinds of parameters it can actually obtain, I ran into a few special cases. Some index options like the ones below may not be simple data types, and the current approach would generate code that doesn’t work. I’ll need a few days to experiment with this and try to find a proper solution. https://github.com/sqlalchemy/sqlalchemy/blob/259636fabb81289fb01fb3322638544a06cf3222/lib/sqlalchemy/dialects/sqlite/base.py#L2956-L2959 |
Great. We'll be waiting for your revised PR. Bear in mind, this work doesn't need to support every use case to begin with. You can always support common cases and just open new issues to be taken care of at a later time |
|
Hello again @luliangce Were you able to make any progress with your work? |
Changes
Fixes #439.
This PR fixes an issue where
Indexkwargs (such aspostgresql_using,mysql_length, etc.) were being ignored during code generation.Key changes:
render_indexinsrc/sqlacodegen/generators.pyto includekwargsin the generatedIndexdefinition.kwargskeys usingsorted()to ensure deterministic output (avoiding random reordering of arguments in generated code).test_index_with_kwargsintests/test_generator_declarative.py.tests/test_generator_declarative.py. These tests previously passed because the generator ignored thepostgresql_using='gist'argument present in the metadata.Checklist
If this is a user-facing code change, like a bugfix or a new feature, please ensure that
you've fulfilled the following conditions (where applicable):
tests/) which would fail without your patchCHANGES.rst).If this is a trivial change, like a typo fix or a code reformatting, then you can ignore
these instructions.
Updating the changelog
If there are no entries after the last release, use
**UNRELEASED**as the version.If, say, your patch fixes issue #123, the entry should look like this:
If there's no issue linked, just link to your pull request instead by updating the
changelog after you've created the PR.