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

Allow partials to be accesed through client #843

Open
Aplietexe opened this issue Nov 29, 2023 · 0 comments
Open

Allow partials to be accesed through client #843

Aplietexe opened this issue Nov 29, 2023 · 0 comments

Comments

@Aplietexe
Copy link

Aplietexe commented Nov 29, 2023

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.

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

1 participant