-
Notifications
You must be signed in to change notification settings - Fork 2.1k
P2023 error when using push on String[] fields with @prisma/adapter-pg in 7.4.0 #29212
Description
Bug description
Using push on a String[] field throws a P2023 error when using @prisma/adapter-pg in Prisma 7.4.0:
P2023: Expected a string in column 'tags[0]', got object: foo,bar
The push operation works correctly with Prisma 7.3.0 + @prisma/adapter-pg. This is a regression introduced in 7.4.0, likely related to the new query compilation caching layer which normalizes queries by extracting values and replacing them with typed placeholders — it appears the push array values are being wrapped as objects instead of passed as strings.
Severity
Reproduction
- Create a Prisma schema with a model containing a
String[]field - Use
@prisma/adapter-pgwithPrismaPgand apg.Pool - Create a record with
tags: [] - Attempt
prisma.item.update({ where: { id }, data: { tags: { push: ['foo', 'bar'] } } }) - Observe P2023 error
Full reproduction script:
import pg from 'pg';
import { PrismaPg } from '@prisma/adapter-pg';
import { PrismaClient } from '@prisma/client';
const DATABASE_URL = 'postgresql://postgres:postgres@localhost:5432/repro';
async function main() {
const pool = new pg.Pool({ connectionString: DATABASE_URL });
const adapter = new PrismaPg(pool);
const prisma = new PrismaClient({ adapter } as any);
// Create a record with an empty String[] field
const item = await prisma.item.create({
data: { name: 'test', tags: [] },
});
console.log('Created item:', item.id, '— tags:', item.tags);
// Try to push values into the String[] field
console.log('\nAttempting: tags: { push: ["foo", "bar"] }');
try {
const updated = await prisma.item.update({
where: { id: item.id },
data: { tags: { push: ['foo', 'bar'] } },
});
console.log('SUCCESS — tags:', updated.tags);
} catch (e: any) {
console.error('FAILED —', e.code, ':', e.message.split('\n').slice(-1)[0]);
}
// Cleanup via raw SQL to avoid the same bug affecting delete
await pool.query('DELETE FROM "Item" WHERE id = $1', [item.id]);
await prisma.$disconnect();
await pool.end();
}
main().catch((e) => {
console.error(e);
process.exit(1);
});Expected vs. Actual Behavior
Expected: push appends values to the array and returns the updated record.
Created item: <id> — tags: []
Attempting: tags: { push: ["foo", "bar"] }
SUCCESS — tags: [ 'foo', 'bar' ]
Actual: Throws P2023 error.
Created item: <id> — tags: []
Attempting: tags: { push: ["foo", "bar"] }
FAILED — P2023 : Expected a string in column 'tags[0]', got object: foo,bar
Frequency
Consistently reproducible
Does this occur in development or production?
Both development and production
Is this a regression?
Yes. Last worked in Prisma 7.3.0, broke in 7.4.0.
Workaround
Downgrading to Prisma 7.3.0 (prisma@7.3.0, @prisma/client@7.3.0, @prisma/adapter-pg@7.3.0) fixes it.
Alternatively, replace push with a read-then-set pattern (fetch current array, concatenate, then set), though this introduces race conditions under concurrency.
Prisma Schema & Queries
datasource db {
provider = "postgresql"
}
generator client {
provider = "prisma-client-js"
}
model Item {
id String @id @default(cuid())
name String
tags String[]
}// The failing query
const updated = await prisma.item.update({
where: { id: item.id },
data: { tags: { push: ['foo', 'bar'] } },
});Prisma Config
import { defineConfig } from 'prisma/config';
export default defineConfig({
schema: './prisma/schema.prisma',
datasource: {
url: process.env.DATABASE_URL ?? 'postgresql://postgres:postgres@localhost:5432/repro',
},
});Logs & Debug Info
P2023: Expected a string in column 'tags[0]', got object: foo,bar
code: 'P2023',
meta: { modelName: 'Item' },
clientVersion: '7.4.0'
Environment & Setup
- OS: macOS (Darwin 25.3.0, arm64)
- Database: PostgreSQL 16
- Node.js version: v22.14.0
Prisma Version
prisma : 7.4.0
@prisma/client : 7.4.0
@prisma/adapter-pg : 7.4.0
Operating System : darwin
Architecture : arm64
Node.js : v22.14.0
Query Compiler : enabled