From 53b098ce6a66f902f20662f79a0ea3c2eb2a9d7e Mon Sep 17 00:00:00 2001 From: Mark Henderson Date: Fri, 6 Mar 2026 11:23:31 -0800 Subject: [PATCH] Fix Lock In 42P18: cast id::text to resolve parameter type ambiguity PostgreSQL could not determine the type of $2 in 'WHERE id = $2' when id column type is UUID. Casting the column (id::text = $1) sidesteps the extended-protocol type inference issue. Also moves projectId to $1 to match the proven working pattern in other routes. Made-with: Cursor --- app/api/projects/[projectId]/design-surfaces/route.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/api/projects/[projectId]/design-surfaces/route.ts b/app/api/projects/[projectId]/design-surfaces/route.ts index c507813..709ce11 100644 --- a/app/api/projects/[projectId]/design-surfaces/route.ts +++ b/app/api/projects/[projectId]/design-surfaces/route.ts @@ -83,9 +83,11 @@ export async function PATCH( return NextResponse.json({ error: 'Invalid body' }, { status: 400 }); } + // Put projectId as $1 (matches known-working pattern in other routes) + // and cast id::text to avoid "could not determine data type of parameter" (42P18) await query( - `UPDATE fs_projects SET data = $1::jsonb WHERE id = $2`, - [JSON.stringify(updated), projectId] + `UPDATE fs_projects SET data = $2::jsonb WHERE id::text = $1`, + [projectId, JSON.stringify(updated)] ); return NextResponse.json({ success: true });