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
This commit is contained in:
2026-03-06 11:23:31 -08:00
parent 69eb3b989c
commit 53b098ce6a

View File

@@ -83,9 +83,11 @@ export async function PATCH(
return NextResponse.json({ error: 'Invalid body' }, { status: 400 }); 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( await query(
`UPDATE fs_projects SET data = $1::jsonb WHERE id = $2`, `UPDATE fs_projects SET data = $2::jsonb WHERE id::text = $1`,
[JSON.stringify(updated), projectId] [projectId, JSON.stringify(updated)]
); );
return NextResponse.json({ success: true }); return NextResponse.json({ success: true });