Keep getting a field does not exist or is not a relational field #755
-
Hi there, I've been a user of the JS/TS version of Prisma for quite a while now, so it was a nice surprise to see there was actually a Python implementation also. I'm not sure if I'm doing something incorrectly but I cannot get things to work. I've got the following in my schema is: generator client {
provider = "prisma-client-py"
interface = "asyncio"
enable_experimental_decimal = true
recursive_type_depth = -1
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model strategy {
id String @id
name String
createdOn DateTime @default(now())
} I'm using FastAPI and I've followed the example for the most part to get things set up. After generating the client and executing the following: from prisma.models import strategy
async def get_strategy_id(self, id):
try:
cs = await strategy.prisma().find_unique(
where={"id": {"equals": id}}, include={"id": True}
)
return cs
except Exception as e:
print(e) This results in:
But when I look at the model that's imported I can see: class strategy(bases.Basestrategy):
"""Represents a strategy record"""
id: _str
name: _str
createdOn: datetime.datetime I'm not quite where it is I'm going wrong. Not sure if it's worth mentioning that I'm also not getting any autocomplete in VSCode even though I have
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Just a quick update, I've trimmed my |
Beta Was this translation helpful? Give feedback.
-
I believe my query was actually just incorrect, shouldn't have been using an |
Beta Was this translation helpful? Give feedback.
-
@rtnolan you're getting that error because |
Beta Was this translation helpful? Give feedback.
@rtnolan you're getting that error because
id
is not a relational field. Only relational fields can be used withinclude
, if you want to select fields see this documentation: https://prisma-client-py.readthedocs.io/en/stable/reference/selecting-fields/