How can I use the generated model correctly with default values? #1037
Unanswered
braindevices
asked this question in
Q&A
Replies: 1 comment
-
I guess the https://prisma-client-py.readthedocs.io/en/stable/getting_started/partial-types/ should be the solution, but no matter what I try I cannot get it to work.
I get:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have following prisma schema:
The tool generated class models.User
I would expect that this model correctly handle all the defaults so I can do:
However, the User(name="some") does not work, because the generated model actual like following:
The id is still required instead of generate with default value. To me this does not really make much sense here.
Because this means I need to manually create extra BaseModel for the post endpoint.
I wonder is the generator created some other mechanism to automatically handle this? At least from the provided examples I see there actually need manually write the BaseModel again. If this is the only way to do it, I am kind of confused about the point of the automatic code generation here. Since with SQLModel I only need to define the model once.
Beta Was this translation helpful? Give feedback.
All reactions