prisma-client-py
prisma-client-py copied to clipboard
Allow partials to be accesed through client
Problem
Currently, the only way to access a partial type to make queries and get it as a return type is to import it from partials directly.
from prisma.partials import PartialUser
res = PartialUser.prisma().find_unique(...)
# res is PartialUser, as we want
however,
from prisma import Prisma
client = Prisma()
await client.connect()
res = client.user.find_unique(...)
# res is User, and there is currently no way to get a PartialUser back
Suggested solution
Allow partials to be accessed through client:
from prisma import Prisma
client = Prisma()
await client.connect()
res = client.partialuser.find_unique(...)
# res is PartialUser
Additional context
This is particularly useful when the prisma client is injected into a function or class for easy testing. It also facilitates the use of the context manager for increased security from errors.