diff --git a/src/lib/pg-ff-client.ts b/src/lib/pg-ff-client.ts index 86f2b54..d4f20dc 100644 --- a/src/lib/pg-ff-client.ts +++ b/src/lib/pg-ff-client.ts @@ -753,6 +753,10 @@ export interface StockBySite { export async function pgGetStockForCodeins(codeins: string[]): Promise> { if (codeins.length === 0) return new Map(); + // Drizzle expands JS arrays into individual $1,$2,... params regardless of syntax, + // hitting PostgreSQL's 1664-entry ROW expression limit. Use sql.raw() with an escaped + // literal array instead — codeins come from the DB so single-quote escaping is sufficient. + const arrayLiteral = codeins.map(c => `'${String(c).replace(/'/g, "''")}'`).join(","); const result = await pgNoParallel(sql` SELECT a.codein, @@ -760,7 +764,7 @@ export async function pgGetStockForCodeins(codeins: string[]): Promise();