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