Skip to content
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

Fix #19 by using choice keys as enum keys, not choice descriptions #23

Merged
merged 1 commit into from Oct 15, 2016

Conversation

morgante
Copy link
Contributor

This fixes #19 so that only the keys (as used in the database) for choice enums. This is superior because descriptions might change over time but you don't want the underlying keys to change.

It also auto-prefixes the keys with "A_" if they would otherwise violate ENUM rule names.

@syrusakbary
Copy link
Member

Good point! I will merge and then fix the tests 👍

try:
assert_valid_name(name)
except AssertionError:
name = "A_%s" % name

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could break badly if python is run with optimisations on (python -O) because that disables assert statements, as used in assert_valid_name. The possible fixes are to update assert_valid_name to raise a different exception (ValueError probably) or to add a parallel function to assert_valid_name for use like this.

Hispar added a commit to Hispar/graphene-django that referenced this pull request May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use choice keys, not descriptions, for enums
3 participants