prisma-client-py
prisma-client-py copied to clipboard
Support query raw annotations
Problem
Prisma recently changed how raw queries work internally, values are now returned alongside meta information, for example:
{
"count": {"prisma__type": "bigint", "prisma__value": "1"}
}
Suggested solution
We need to figure out how to support this internally as we can't just naively return the results from the raw query anymore, we may have to do some form of parsing using a BaseModel
/ Field
...
Will there be an object.type
attribute?
@TheOnlyWayUp I was planning for this change to be internal only, so everything would stay the same for users.
In the Node client, the raw query annotations are used internally to be able to correctly deserialize the response data, I suspect it will end up being the same solution for us.
The raw query interface could be updated to return an object instead of a dictionary but I'm not sure how I feel about that yet. Example:
record = await client.query_first('SELECT name FROM User')
assert record.name == 'Robert'
I know that this solution would work with Pyright (as it respects a custom __getattr__
and disables type checking) but I'm not sure if mypy plays nicely with this.
Hi Robert, maybe this will help you. To generate dynamic model. https://github.com/carlos-rian/pysqlx-engine/blob/main/sqlx_engine/_core/parser.py