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:
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user