Skip to content

PostgreSQL adapter fails to parse String[] @db.Citext arrays (Error P2023) #28349

@mrnvicente7

Description

@mrnvicente7

Bug description

When using Prisma v6 with the PostgreSQL adapter (@prisma/adapter-pg) and PostgreSQL's citext extension for array fields (String[] @db.Citext), Prisma fails to properly parse the database response.

The bug manifests differently depending on the engine used:

  • With Rust engine (default): Error P2023 - "List field did not return an Array from database"
  • Without Rust engine (engineType = "client"): TypeError - "e.map is not a function"

Important: Single String @db.Citext fields work correctly. The bug only affects String[] arrays with citext.

Severity

🚨 Critical: Data loss, app crash, security issue

Reproduction

Repository with full reproduction: https://github.com/mrnvicente7/prisma-bug/tree/main/packages/citext-extension-pg-adapter

Prerequisites:

  1. PostgreSQL database with citext extension enabled:
    CREATE EXTENSION IF NOT EXISTS citext;

Steps:

  1. Clone the repository
  2. Install dependencies: pnpm install
  3. Start PostgreSQL with Docker: pnpm run docker:up
  4. Set up .env with: DATABASE_URL=postgresql://postgres:postgres@localhost:5432/db?schema=public
  5. Navigate to the reproduction: cd packages/citext-extension-pg-adapter
  6. Test the bug:
    • With Rust engine (P2023): cd prisma-v6 && pnpm prisma:generate && pnpm prisma migrate deploy && pnpm dev
    • Without Rust engine (TypeError): cd ../prisma-v6-no-rust && pnpm prisma:generate && pnpm prisma migrate deploy && pnpm dev

Expected vs. Actual Behavior

With Rust engine - Error P2023:

PrismaClientKnownRequestError:
Invalid `PrismaOrm.car.upsert()` invocation

Inconsistent column data: List field did not return an Array from database.
Type identifier was String.
Value was Value { typed: Text(Some("{red,white,black}")), native_column_type: None }.

Code: P2023
Meta: {
  modelName: 'Car',
  message: 'List field did not return an Array from database. Type identifier was String. Value was Value { typed: Text(Some("{red,white,black}")), native_column_type: None }.'
}

Without Rust engine - TypeError:

TypeError: e.map is not a function
    at nf (.../generated/client/runtime/client.js:74:8774)
    at El (.../generated/client/runtime/client.js:74:8471)
    at oo (.../generated/client/runtime/client.js:74:7646)
    ...

Root cause:

  • The @prisma/adapter-pg returns the raw PostgreSQL array string: "{red,white,black}"
  • Prisma expects a JavaScript array: ['red', 'white', 'black']
  • With Rust: Detects the type mismatch and throws P2023 error
  • Without Rust: Tries to call .map() on a string, causing TypeError

Frequency

Consistently reproducible

Does this occur in development or production?

Both development and production

Is this a regression?

This may be a regression introduced when the @prisma/adapter-pg was added, as the issue is specific to the PostgreSQL adapter. The bug does not occur when using the standard Prisma connection (without adapter).

The last known working version would be any Prisma version before the adapter was introduced or made stable.

Workaround

  1. Don't use String[] @db.Citext with the PostgreSQL adapter
  2. Use regular String[] without @db.Citext (loses case-insensitive functionality)
  3. Use single String @db.Citext fields instead of arrays (not always possible)
  4. Don't use @prisma/adapter-pg (use standard Prisma connection)

Prisma Schema & Queries

Schema:

generator client {
  provider = "prisma-client-js"
  output   = "../generated/client"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model Car {
  id     String   @id @default(uuid()) @db.Uuid
  name   String   @db.Citext           // ✅ Works fine
  colors String[] @db.Citext           // ❌ Causes the bug

  carModel CarModel[]
}

Prisma Config

// Add your `prisma.config.ts`

Logs & Debug Info

// Debug logs here

Environment & Setup

  • OS: macOS Tahoe 26.0.1
  • Database: PostgreSQL 16 (but affects all databases)
  • Node.js version: 22.14.0
  • npm version: 10.9.2
  • pnpm version: 10.16.1
  • Package manager: pnpm

Prisma Version

6.17.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