-
Notifications
You must be signed in to change notification settings - Fork 2.1k
PostgreSQL adapter fails to parse String[] @db.Citext arrays (Error P2023) #28349
Description
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:
- PostgreSQL database with
citextextension enabled:CREATE EXTENSION IF NOT EXISTS citext;
Steps:
- Clone the repository
- Install dependencies:
pnpm install - Start PostgreSQL with Docker:
pnpm run docker:up - Set up
.envwith:DATABASE_URL=postgresql://postgres:postgres@localhost:5432/db?schema=public - Navigate to the reproduction:
cd packages/citext-extension-pg-adapter - 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
- With Rust engine (P2023):
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-pgreturns 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
- Don't use
String[] @db.Citextwith the PostgreSQL adapter - Use regular
String[]without@db.Citext(loses case-insensitive functionality) - Use single
String @db.Citextfields instead of arrays (not always possible) - 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