Skip to content

Browser-imported 'Prisma.DBNull' create an empty object #29257

@JoGoFo-

Description

@JoGoFo-

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

Image

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/1-unconfirmedBug should have enough information for reproduction, but confirmation has not happened yet.kind/bugA reported bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions