New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prisma Client: disconnect: true
does not appear to delete the foreign key in the returned data
#20491
Comments
That is concerning @casey-chow. Can you please turn on logging in your project when running one of these queries? (Instructions see https://pris.ly/d/logging) It would be very interesting to see the query that is being executed under the hood here. If you can downgrade to Prisma 5.0.0 as well and confirm that it correctly works there, and what query you get with that version, that would be amazing. Thank you! To complete the information our bug issue template usually asks for: |
@casey-chow Along with filling more information mentioned in our bug report template, sharing your Prisma schema would also help to reproduce this. |
I could reproduce something, is that what you meant @casey-chow ? import { PrismaClient } from "@prisma/client";
async function main() {
const prisma = new PrismaClient();
// Before (should be empty)
const usersBefore = await prisma.user.findMany();
console.log({ usersBefore });
const devicesBefore = await prisma.device.findMany();
console.log({ devicesBefore });
const newDeviceWithUser = await prisma.device.create({
data: {
user: {
create: {},
},
},
});
console.log({ newDeviceWithUser });
// Disconnect!
const disconnect = await prisma.device.update({
where: { id: newDeviceWithUser.id },
data: { user: { disconnect: true } },
});
console.log({ disconnect });
// After
const usersAfter = await prisma.user.findMany();
console.log({ usersAfter });
const devicesAfter = await prisma.device.findMany();
console.log({ devicesAfter });
// Cleanup
await prisma.device.deleteMany();
await prisma.user.deleteMany();
prisma.$disconnect();
}
main();
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id Int @id @default(autoincrement())
name String?
Device Device[]
}
model Device {
id Int @id @default(autoincrement())
user User? @relation(fields: [userId], references: [id])
userId Int?
} |
So it looks like the data returned by a
returns |
Note that we are looking at this and might issue a patch release once we have a fix, we'll keep you updated, thanks for the report 🙌🏼 |
disconnect: true
does not appear to delete the foreign key in the returned data
Note: we got a fix, more info coming soon. |
What a flurry to wake up to! Apologies for not following bug template, I figured there should be one but for whatever reason it didn't ever pop up for me in GitHub, and it was near the end of the day and wanted to get this information over to your team quickly. Yes, I was able to verify it worked in 5.0.0 as well. Thanks for getting this fix in so quickly, look forward to seeing the patch release! |
Fix released in 5.1.1 |
In Prisma 5.1.0 (Postgres) I noticed that my tests began failing to properly execute with:
The device returned is still connected to the user after this is run.
The text was updated successfully, but these errors were encountered: