Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion graphene_sqlalchemy/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def convert_column_to_float(type, column, registry=None):

@convert_sqlalchemy_type.register(types.Enum)
def convert_enum_to_enum(type, column, registry=None):
return lambda: enum_for_sa_enum(type, registry or get_global_registry())
return lambda: enum_for_sa_enum(type, registry or get_global_registry(), fallback_name=column.key)


# TODO Make ChoiceType conversion consistent with other enums
Expand Down
4 changes: 2 additions & 2 deletions graphene_sqlalchemy/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ def _convert_sa_to_graphene_enum(sa_enum, fallback_name=None):
return Enum(name, members)


def enum_for_sa_enum(sa_enum, registry):
def enum_for_sa_enum(sa_enum, registry, fallback_name=None):
"""Return the Graphene Enum type for the specified SQLAlchemy Enum type."""
if not isinstance(sa_enum, SQLAlchemyEnumType):
raise TypeError(
"Expected sqlalchemy.types.Enum, but got: {!r}".format(sa_enum)
)
enum = registry.get_graphene_enum_for_sa_enum(sa_enum)
if not enum:
enum = _convert_sa_to_graphene_enum(sa_enum)
enum = _convert_sa_to_graphene_enum(sa_enum, fallback_name=fallback_name)
registry.register_enum(sa_enum, enum)
return enum

Expand Down