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

Problem with Enum field #27

Closed
GingerTe opened this issue Aug 25, 2020 · 2 comments
Closed

Problem with Enum field #27

GingerTe opened this issue Aug 25, 2020 · 2 comments
Assignees

Comments

@GingerTe
Copy link

Hi

I'm trying to use Enum in filter but get a problem

models

class IssueCommentType(Enum):
    default = 'Not defined'
    author = 'Response from author'

class IssueComment(db.Model):
    comment_id = db.Column(db.INT, primary_key=True)
    issue_id = db.Column(db.ForeignKey('issue.issue_id'), nullable=False)

    comment = db.Column(db.TEXT, nullable=False)
    date = db.Column(db.DateTime, nullable=False)

    type = db.Column(db.Enum(IssueCommentType), nullable=False, default=IssueCommentType.default)

filter

class IssueCommentFilter(FilterSet):
    class Meta:
        model = IssueComment
        fields = {
            'type': ['eq', 'ne'],
        }

class MyFilterableConnectionField(FilterableConnectionField):
    filters = {
        Issue: IssueFilter(),
        IssueComment: IssueCommentFilter(),
        IssueExtraFields: ExtraFieldsFilter(),
    }

query

{
  issues(first: 10) {
    totalCount
    edges {
      node {
        comments(filters: {type:AUTHOR}) {
          edges {
            node {
              comment
              date
              type
            }
          }
        }
      }
    }
  }
}

error

graphql.error.located_error.GraphQLLocatedError: (psycopg2.errors.InvalidTextRepresentation) 
ERROR:  incorrect value for enum issuecommenttype: "Response from author"
LINE 4: WHERE issue_comment.type = 'Response from author') AS anon_1...
                                   ^

enum in database created with enum names but filter trying to use enum values

@art1415926535 art1415926535 self-assigned this Aug 28, 2020
@art1415926535 art1415926535 changed the title Problew with Enum field Problem with Enum field Aug 29, 2020
@art1415926535
Copy link
Owner

Fixed! New release.

@GingerTe
Copy link
Author

Thanks! It's working

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

No branches or pull requests

2 participants