Planetscale not able to upsert with Prisma
See original GitHub issueBug description
It seems like the upsert command will yield HY000
code 1105
error.
const response = await prisma.user.update({
data: {
profile: {
upsert: {
update: {
firstName: req.body.profile.firstName,
lastName: req.body.profile.lastName,
},
create: {
firstName: 'GG',
lastName: 'lala',
}
}
}
},
where: {
id: token.sub
}
})
model Profile {
id String @id @default(cuid())
// BUG: https://github.com/prisma/prisma/issues/10758#issuecomment-1001139677
// Need to use onUpdate: Noaction according to 10758
user User @relation(fields: [userId], references: [id], onUpdate: Cascade, onDelete: Cascade)
userId String @unique
timezone String?
company String?
jobTitle String?
firstName String?
lastName String?
}
prisma:info Starting a mysql pool with 3 connections.
prisma:query BEGIN
prisma:query SELECT `silkroad-db`.`User`.`id` FROM `silkroad-db`.`User` WHERE `silkroad-db`.`User`.`id` = ?
prisma:query SELECT `silkroad-db`.`StakeholdersOnIssues`.`userId`, `silkroad-db`.`StakeholdersOnIssues`.`issueId` FROM `silkroad-db`.`StakeholdersOnIssues` WHERE (1=1 AND `silkroad-db`.`StakeholdersOnIssues`.`userId` IN (?))
prisma:query SELECT `silkroad-db`.`User`.`id`, `silkroad-db`.`StakeholdersOnIssues`.`userId`, `silkroad-db`.`StakeholdersOnIssues`.`issueId` FROM `silkroad-db`.`StakeholdersOnIssues` WHERE 1=0
prisma:query ROLLBACK
error - Error:
Invalid `prisma.user.update()` invocation:
Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Server(ServerError { code: 1105, message: "symbol `silkroad-db`.`User`.id not found", state: "HY000" })) })
wait - compiling /_error (client and server)...
How to reproduce
Expected behavior
Prisma information
Environment & setup
- OS:
- Database:
- Node.js version:
Prisma Version
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Using Prisma with PlanetScale
Prisma recommends not using prisma migrate when making schema changes with PlanetScale. Instead, we recommend that you use the prisma db push command....
Read more >Prisma with PlanetScale quickstart
Overview. This guide will show you how to: Create a database with PlanetScale; Integrate into a Next.js + Prisma application. Prerequisites.
Read more >PlanetScale and Prisma Data Platform integration
Overview. The following guide will show you how to integrate PlanetScale with a Prisma application using the Prisma Data Platform integration.
Read more >How to set up Next.js with Prisma and PlanetScale
On the free plan, you receive one database at no cost to you. Create a new database and select the closest region to...
Read more >Automatic Prisma migrations
Also, you previously needed to turn on the ability to automatically copy the Prisma migration metadata. You no longer need to do this....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The workaround works for now! @janpio thank you.
So for now - the rule of thumb is all the relations to the model that you update should have
onUpdate:NoAction
andonDelete:NoAction
.And the impact will be there will be if “parent ID” updates or get deleted, the related model will not cascade automatically.
I’m running into this as well but the workaround has not worked for me.
This what my schema looks like:
As you can see I have a many to many relations and have set the referrential actions to no actions.
This is the query I’m trying to run for reference.
ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Server(ServerError { code: 1105, message: "symbol views_game.Video.id not found", state: "HY000" })) })
as well as the error.