-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Browser-imported 'Prisma.DBNull' create an empty object #29257
Copy link
Copy link
Closed
Labels
bug/1-unconfirmedBug should have enough information for reproduction, but confirmation has not happened yet.Bug should have enough information for reproduction, but confirmation has not happened yet.kind/bugA reported bug.A reported bug.
Description
Bug description
Using 'prisma-client' (Prisma 7.4.x), using 'Prisma.DBNull' from the browser import results in an empty object {} being persisted into a nullable Json field.
Severity
🔹 Minor: Unexpected behavior, but does not block development
Reproduction
import { Prisma as PrismaClient } from "./generated/prisma/client";
import { Prisma as PrismaBrowser } from "./generated/prisma/browser";
// This works as expected:
async function createClientExample() {
"use server";
await prisma.example.create({
data: {
name: `Client Example`,
json: PrismaClient.DbNull,
},
});
}
// This inserts an empty object {} instead of NULL
async function createBrowserExample() {
"use server";
await prisma.example.create({
data: {
name: `Browser Example`,
json: PrismaBrowser.DbNull,
},
});
}Example repo: https://github.com/JoGoFo-/prisma-dbnull-issue
Expected vs. Actual Behavior
Expected:
Json record is set to NULL
Actual:
Json record is set to {}
Frequency
Consistently reproducible
Does this occur in development or production?
Both development and production
Is this a regression?
Yes, this worked correctly in Prisma 6.x with 'prisma-client-js'
Workaround
Import client version of Prisma instead (server-side only)
Prisma Schema & Queries
generator client {
provider = "prisma-client"
output = "../app/generated/prisma"
}
datasource db {
provider = "postgresql"
}
model Example {
id String @id @default(uuid())
name String
createdAt DateTime @default(now())
json Json?
}import { Prisma } from "./generated/prisma/browser";
await prisma.example.create({
data: {
name: `Browser Example`,
json: Prisma.DbNull,
},
});Prisma Config
import "dotenv/config";
import { defineConfig } from "prisma/config";
export default defineConfig({
schema: "prisma/schema.prisma",
migrations: {
path: "prisma/migrations",
},
datasource: {
url: process.env["DATABASE_URL"],
},
});Logs & Debug Info
No response
Environment & Setup
- OS: macOS + Vercel hosted app
- Database: PostgreSQL
- Node.js version: 22.14
Prisma Version
prisma : 7.4.1
@prisma/client : 7.4.1
Operating System : darwin
Architecture : arm64
Node.js : v22.14.0
TypeScript : 5.9.3
Query Compiler : enabled
PSL : @prisma/prisma-schema-wasm 7.5.0-4.55ae170b1ced7fc6ed07a15f110549408c501bb3
Schema Engine : schema-engine-cli 55ae170b1ced7fc6ed07a15f110549408c501bb3 (at node_modules/@prisma/engines/schema-engine-darwin-arm64)
Default Engines Hash : 55ae170b1ced7fc6ed07a15f110549408c501bb3
Studio : 0.13.1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bug/1-unconfirmedBug should have enough information for reproduction, but confirmation has not happened yet.Bug should have enough information for reproduction, but confirmation has not happened yet.kind/bugA reported bug.A reported bug.