Open ameshkin opened 1 year ago
I was able to fix a similar issue before but am having this issue again.
This time I am trying to set publicData in the Session table manually. I have to do this without $ctx or the blitz auth since it's in a webhook. I want to change a user session.
I can use ts-ignore and get past it, and the site functions and works well after I change publicData.
I have tried publicData: any
in types.ts but it's not working. However, this is what fixed my issue with the userId field.
// <html>TS2345: Argument of type 'PrismaClient<PrismaClientOptions, unknown, Args> & EnhancedPrismaClientAddedMethods' is not assignable to parameter of type 'PrismaClientWithSession'.<br/>The types of 'session.update' are incompatible between these types.<br/>Type '<T extends SessionUpdateArgs<Args>>(args: SelectSubset<T, SessionUpdateArgs<Args>>) => Prisma__SessionClient<GetFindResult<SessionPayload<Args>, T>, never, Args>' is not assignable to type '(args: { data: Partial<SessionModel>; where: { handle?: string | undefined; }; }) => Promise<SessionModel>'.<br/>Types of parameters 'args' and 'args' are incompatible.<br/>Type '{ data: Partial<SessionModel>; where: { handle?: string | undefined; }; }' is not assignable to type '{ select?: SessionSelect<Args> | null | undefined; include?: SessionInclude<Args> | null | undefined; data: (Without<SessionUpdateInput, SessionUncheckedUpdateInput> & SessionUncheckedUpdateInput) | (Without<...> & SessionUpdateInput); where: SessionWhereUniqueInput; }'.<br/>Types of property 'where' are incompatible.<br/>Type '{ handle?: string | undefined; }' is not assignable to type 'SessionWhereUniqueInput'.<br/>Type '{ handle?: string | undefined; }' is not assignable to type '{ id: string | number; handle: string | number; userId: string | number; } & { id?: number | undefined; handle?: string | undefined; userId?: number | undefined; AND?: SessionWhereInput | SessionWhereInput[] | undefined; ... 9 more ...; user?: (Without<...> & UserWhereInput) | ... 1 more ... | undefined; }'.<br/>Type '{ handle?: string | undefined; }' is missing the following properties from type '{ id: string | number; handle: string | number; userId: string | number; }': id, userId
> prisma -v
Environment variables loaded from .env
prisma : 5.0.0
@prisma/client : 5.0.0
Current platform : darwin-arm64
Query Engine (Node-API) : libquery-engine 6b0aef69b7cdfc787f822ecd7cdc76d5f1991584 (at node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Schema Engine : schema-engine-cli 6b0aef69b7cdfc787f822ecd7cdc76d5f1991584 (at node_modules/@prisma/engines/schema-engine-darwin-arm64)
Schema Wasm : @prisma/prisma-schema-wasm 4.17.0-26.6b0aef69b7cdfc787f822ecd7cdc76d5f1991584
Default Engines Hash : 6b0aef69b7cdfc787f822ecd7cdc76d5f1991584
Studio : 0.487.0
I also want to add, that this is the code that started this issue publicDataNew is a json string, since publicData is set to string.
Perhaps it should just be a JSON type. To reiterate, the query does work and update the table and session. Just gives a build error.
const updateUserSession = await db.session.update({
where: { userId: user.id },
data: { publicData: publicDataNew },
})
Bug description
Hello everyone, I was asked to report this bug, I was able to fix by manually overriding my models that are generated.
I wanted to change the id of the User model from a number to a string, and also add a username that will be used in other tables.
The fix was applying was updating types.ts, but this is a bug since we shouldn't have to manually correct. I also removed the username I was trying to put into sessions, and turned the userId back into a number instead of a string.
There is someone else having the same issue, but put his bug report into the blitz page. I believe this is a prisma issue. https://github.com/blitz-js/blitz/issues/3883
Also, I am using
provider = "mysql"
and not sqlite. Perhaps this makes a difference.These are some of the types of errors I receive on mutations. I have tried different types to get this working, but am pretty new to typescript.
This is the error I am getting on build.
How to reproduce
Expected behavior
Expected behavior would be for prisma to generate and update models correctly.
Prisma information
My models
Environment & setup
Prisma Version
PRISMA VERSIONS THAT WERE TRIED 4.13.0
4.12.0
4.11.0
I made sure prisma and prisma client matched.