We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
String Enums are not casted to their enum type on relations (with include included entities)
Schema:
datasource db { provider = "postgresql" url = "postgresql://postgres:postgres@localhost:4321/postgres" } generator client { provider = "prisma-client-py" recursive_type_depth = 5 } model Action { id String @id @default(cuid()) executions Execution[] } enum Executor { USER SYSTEM } model Execution { id String @id @default(cuid()) actionId String action Action @relation(fields: [actionId], references: [id]) executor Executor }
Code:
import asyncio import prisma import logging logging.basicConfig() logging.getLogger('prisma').setLevel(logging.DEBUG) db = prisma.Prisma() async def main(): await db.connect() await db.execution.delete_many() await db.action.delete_many() action = await db.action.create( data={"executions": {"create": {"executor": "USER"}}}, include={"executions": True}, ) direct_enum = (await db.execution.find_first(where={"executor": "USER"})).executor print("type(direct_enum)", type(direct_enum)) if not action.executions or not action.executions[0].executor: raise ValueError("No executions found") relation_enum = action.executions[0].executor print("type(relation_enum)", type(relation_enum)) assert isinstance(direct_enum, prisma.enums.Executor) assert isinstance(relation_enum, prisma.enums.Executor) asyncio.run(main())
the second assert fails because relation_enum is a raw string. The same happens with any "include" query, like create, update etc.
enums are always cast to enums, no matter if they are in the "direct" entity or included through a relation
prisma : 5.17.0 prisma client python : 0.15.0 platform : darwin expected engine version : 393aa359c9ad4a4bb28630fb5613f9c281cde053 installed extras : [] install path : /Users/matthias/Dev/tests/.venv/lib/python3.12/site-packages/prisma binary cache dir : /Users/matthias/.cache/prisma-python/binaries/5.17.0/393aa359c9ad4a4bb28630fb5613f9c281cde053
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Bug description
String Enums are not casted to their enum type on relations (with include included entities)
How to reproduce
Schema:
Code:
the second assert fails because relation_enum is a raw string. The same happens with any "include" query, like create, update etc.
Expected behavior
enums are always cast to enums, no matter if they are in the "direct" entity or included through a relation
Prisma information
Environment & setup
The text was updated successfully, but these errors were encountered: