-
Notifications
You must be signed in to change notification settings - Fork 229
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
Enum name for sort fields should be taken from Column.key instead of Column.name #301
Conversation
Codecov Report
@@ Coverage Diff @@
## master #301 +/- ##
=======================================
Coverage 96.39% 96.39%
=======================================
Files 9 9
Lines 721 721
=======================================
Hits 695 695
Misses 26 26
Continue to review full report at Codecov.
|
Thanks for the PR; I just checked it out! I've also found another case where graphene-sqlalchemy/graphene_sqlalchemy/converter.py Lines 241 to 249 in a47dbb3
It looks like that could cause the same errors, so it might be worth fixing as well. Although this is a breaking change, I think merging this is the way to go. My comments from above might be worth discussing, but I don't believe changing something is a hard requirement. Can you add a test case for this? |
Added to #353, thank you for the PR! |
Erik, |
Hey David, no worries! I added your changes to #353, including unit tests, so everything is done 🙂 If you find the time, maybe check out the changes in the corresponding commit and let me know if that works for you. Thanks again for bringing this up! |
Commit in PR is: dccbe22 |
I'm working with an external Microsoft SQL database and some field names contain invalid characters such as
%
. Fortunately, the parameterkey
of SQLAlchemy Column allows you to specify a different name for a field to be used everywhere except in the SQL code:Usually the
key
attribute in the orm column is the same as thename
attribute. But, as in this instance, if you specify the key parameter when defining the column:...
sort_enum_for_object_type
function will generate the name of the sort enum from the original SQL field name instead of from the providedkey
alternative as it would be expected. As a result, the generated enum name is wrong and an exception is thrown:This PR just makes the name to be taken from the
key
attribute which is usually identical except if an alternative field name is specified. Everything seems to work fine in my tests and I can't find any side effects resulting from the change.tox -e pre-commit
: