Describe the bug
When a type contains a enum list, prisma doesn't generate the filters for this enum list. E.g. _every, _some, _none filters.
BTW, I don't know exactly if this is a bug or if it is normal behaviour.
To Reproduce
Here's a simple example that reproduces the bug:
type Basket {
id: ID! @unique
fruits: [Fruit!]!
}
enum Fruit {
BANANA
ORANGE
APPLE
}
Here's the generated "WhereInput" for the "basket" type:
input BasketWhereInput {
"""Logical AND on all given filters."""
AND: [BasketWhereInput!]
"""Logical OR on all given filters."""
OR: [BasketWhereInput!]
"""Logical NOT on all given filters combined by AND."""
NOT: [BasketWhereInput!]
id: ID
"""All values that are not equal to given value."""
id_not: ID
"""All values that are contained in given list."""
id_in: [ID!]
"""All values that are not contained in given list."""
id_not_in: [ID!]
"""All values less than the given value."""
id_lt: ID
"""All values less than or equal the given value."""
id_lte: ID
"""All values greater than the given value."""
id_gt: ID
"""All values greater than or equal the given value."""
id_gte: ID
"""All values containing the given string."""
id_contains: ID
"""All values not containing the given string."""
id_not_contains: ID
"""All values starting with the given string."""
id_starts_with: ID
"""All values not starting with the given string."""
id_not_starts_with: ID
"""All values ending with the given string."""
id_ends_with: ID
"""All values not ending with the given string."""
id_not_ends_with: ID
}
Expected behavior
I would like to query the baskets that contain "APPLE", but I can't, because there's no filter generated for the "fruits" field.
Versions:
Windows 10prisma CLI: prisma/1.14.0 (windows-x64) node-v9.11.1Hey @stefanfuchs, thanks a lot for bringing this up.
This is the expected behaviour and a known limitation. We want to implement this when tackling a better approach for scalar lists in general. This is being discussed here: #1275.
Thanks for the feedback. I hope this can be implemented soon. As an alternative solution for now I'm doing something like this (use type instead of enum):
type Basket {
id: ID! @unique
fruits: [Fruit!]!
}
type Fruit {
id: ID! @unique
name: String!
}
And then I insert into the database the values for Fruit: "Banana", "Orange" and "Apple". This way I can filter what I want.
Would this really be the best solution, or is there a better way I didn't see?
BTW, thank you for being so proactive. You guys are awesome (and so is this project).
Most helpful comment
Thanks for the feedback. I hope this can be implemented soon. As an alternative solution for now I'm doing something like this (use type instead of enum):
And then I insert into the database the values for Fruit: "Banana", "Orange" and "Apple". This way I can filter what I want.
Would this really be the best solution, or is there a better way I didn't see?
BTW, thank you for being so proactive. You guys are awesome (and so is this project).