AnandChowdhary
AnandChowdhary
PPrisma
Created by AnandChowdhary on 10/7/2024 in #help-and-questions
Prisma.DbNull doesn't work with Prisma Accelerate
Prisma Accelerate doesn't seem to support Prisma.DbNull. This is unexpected and production-breaking for us since we enabled Accelerate. For example, if you use Accelerate:
import { PrismaClient } from "@prisma/client/edge";
import { withAccelerate } from "@prisma/extension-accelerate";

export const db = new PrismaClient().$extends(withAccelerate());
import { PrismaClient } from "@prisma/client/edge";
import { withAccelerate } from "@prisma/extension-accelerate";

export const db = new PrismaClient().$extends(withAccelerate());
And have a model with an option JSON property:
model User {
id Int @default(autoincrement())
info Json?
}
model User {
id Int @default(autoincrement())
info Json?
}
If you try and update the value to Prisma.DbNull, that value becomes an empty object {} rather than NULL in the database and that's what the .update also responds with.
db.user.update({
where: { id: 1 },
data: { info: Prisma.DbNull }
}); // { id: 1, info: {} }
db.user.update({
where: { id: 1 },
data: { info: Prisma.DbNull }
}); // { id: 1, info: {} }
I can confirm that this is indeed an issue with Accelerate, because when I disable it, it works correctly.
5 replies