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
citext extension 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
.env with: 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
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
- Don't use
String[] @db.Citext with the PostgreSQL adapter
- Use regular
String[] without @db.Citext (loses case-insensitive functionality)
- Use single
String @db.Citext fields 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
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
Bug description
When using Prisma v6 with the PostgreSQL adapter (
@prisma/adapter-pg) and PostgreSQL'scitextextension for array fields (String[] @db.Citext), Prisma fails to properly parse the database response.The bug manifests differently depending on the engine used:
engineType = "client"): TypeError - "e.map is not a function"Important: Single
String @db.Citextfields work correctly. The bug only affectsString[]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:
citextextension enabled:Steps:
pnpm installpnpm run docker:up.envwith:DATABASE_URL=postgresql://postgres:postgres@localhost:5432/db?schema=publiccd packages/citext-extension-pg-adaptercd prisma-v6 && pnpm prisma:generate && pnpm prisma migrate deploy && pnpm devcd ../prisma-v6-no-rust && pnpm prisma:generate && pnpm prisma migrate deploy && pnpm devExpected vs. Actual Behavior
With Rust engine - Error P2023:
Without Rust engine - TypeError:
Root cause:
@prisma/adapter-pgreturns the raw PostgreSQL array string:"{red,white,black}"['red', 'white', 'black'].map()on a string, causing TypeErrorFrequency
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-pgwas 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
String[] @db.Citextwith the PostgreSQL adapterString[]without@db.Citext(loses case-insensitive functionality)String @db.Citextfields instead of arrays (not always possible)@prisma/adapter-pg(use standard Prisma connection)Prisma Schema & Queries
Schema:
Prisma Config
// Add your `prisma.config.ts`Logs & Debug Info
Environment & Setup
Prisma Version