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

Proper support for the SQLAlchemy Enum type #78

Merged
merged 2 commits into from
Nov 22, 2017

Conversation

Cito
Copy link
Member

@Cito Cito commented Sep 1, 2017

SQLAlchemy Enums were converted to Graphene Strings by graphene-sqlalchemy so far. This is a proposed patch to convert them into Graphene Enums instead. Note that postgresql.ENUM does not need special casing since it is a subtype of the generic SQLAlchemy Enum. Also note that the patch supports the two variants of defining an SQLAlchemy Enum, namely by using a sequence and by using a Python Enum.

@coveralls
Copy link

coveralls commented Sep 1, 2017

Coverage Status

Coverage increased (+0.2%) to 90.972% when pulling ea98709 on Cito:convert_enums into 08a0072 on graphql-python:master.

@coveralls
Copy link

coveralls commented Sep 1, 2017

Coverage Status

Coverage increased (+0.2%) to 90.972% when pulling 2fac056 on Cito:convert_enums into 08a0072 on graphql-python:master.

@syrusakbary syrusakbary merged commit 4827ce2 into graphql-python:master Nov 22, 2017
@Cito Cito deleted the convert_enums branch November 22, 2017 07:14
@sboisson
Copy link

It seems there is a problem if the same Enum is used in several classes, the code attempt to recreate the Enum with the same name..

Also there should be a way to reference the generated graphene.Enum so it can be used in queries and mutation..

@Cito
Copy link
Member Author

Cito commented Nov 28, 2017

@sboisson Thanks for the heads up - I will look into these issues this week.

@Cito
Copy link
Member Author

Cito commented Dec 1, 2017

@sboisson I have now addressed these two problems in #98.

It should now be possible to use the same enum, and you can refer to the enum either using the registry or using sqlalchemy_object_type._meta.fields[column_name].type. You can see how this works in the test_should_query_well unit test.

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.

4 participants