prisma: Prisma Client upsert returns count instead of data
Bug description
When using the upsert
method to do a findOrCreate
implementation, count: { 1 }
is returned rather than the data itself.
How to reproduce
Using the following code returns count
rather than the user
object
const user = await prisma.user.upsert({
where: { email: emails[0].value },
update: { lastLoggedIn: new Date() },
create: {
email: emails[0].value,
name: displayName,
avi: photos[0].value,
profile: {
create: {
name: displayName,
avi: photos[0].value,
email: emails[0].value,
},
},
},
});
console.log({ user });
Expected behavior
I expect the user’s data to be returned.
Prisma information
model User {
id String @id @default(uuid())
email String @unique
name String
avi String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
lastLoggedIn DateTime @default(now())
log Log[]
items Item[]
rsvps Rsvp[] @relation("rsvp_user")
createdEvents Event[] @relation(name: "created_event")
profile Profile? @relation("profile_user")
}
Environment & setup
- OS: Mac OS
- Database: MySQL
- Node.js version: v14.17.3
Prisma Version
prisma : 3.6.0
@prisma/client : 3.7.0
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 7
- Comments: 42 (17 by maintainers)
yup!
Yes
We’re also experiencing this issue in production with
v3.8.1
. It was working fine onv3.5.0
.I can share my schema privately if it would help.
Can also confirm this; using PlanetScale on production but also happens locally with MySQL Returns fine if the identifier doesn’t exist, but if it does it just returns
{"count": number}
@janpio, I can confirm that the reproduction reproduces. Is it helpful?
Oh sorry, I missed that it was you who posted that - this way my message of course does not make a lot of sense. We did not have the time to appraoch that reproduction yet unfortunately. If anyone else can confirm the reproduction reproduces, that would be helpful.
Sorry, I missed this comment one week ago. I’ll try to create a reproducible repo or something
Also using Planetscale
Can confirm, I am using PlanetScale as well
@pantharshit00 this is on PlanetScale and it looks like they’re using mysql version 8.0.23