Skip to content

SQLAlchemy Enum with 'nullable=True' doesn't work correctly #117

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

Closed
Lelby opened this issue Feb 28, 2018 · 2 comments
Closed

SQLAlchemy Enum with 'nullable=True' doesn't work correctly #117

Lelby opened this issue Feb 28, 2018 · 2 comments

Comments

@Lelby
Copy link

Lelby commented Feb 28, 2018

I have SQLAlchemy model with some enum:

variants = ('red', 'green', 'yellow')
my_enum_type = sqlalchemy.dialects.postgresql.ENUM(*variants)

class CarModel(Base):
    color = sqlalchemy.Column(my_enum_type)

and graphene Schema which uses SQLAlchemyObjectType:

class Car(SQLAlchemyObjectType):
    class Meta:
       model = CarModel

I want to create a mutation:

class CreateCar(graphene.Mutation):
    class Arguments:
        color = Car._meta.fields['color'].type

    ...
    def mutate(self, info, color):
        db_session.add(CarModel(color=color))
        db_session.commit()
        return ...

There are two issues:

  1. (Minor) I refer to enum in a strange way: .._meta.fields.., but it is known issue: Proper support for the SQLAlchemy Enum type #78
  2. (Major) If I try to execute program with such schema, I get error:
File "contrib/python/graphene/graphene/types/argument.py", line 67, in to_arguments
    raise ValueError('Unknown argument "{}".'.format(default_name))
ValueError: Unknown argument "color"

If I add nullable=False to SQLAlchemy model, everything works fine.

@erikwrede
Copy link
Member

Can't reproduce in v3

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related topics referencing this issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants