fix(api): add UUID type cast in getCfdiById and getXmlById

PostgreSQL requires explicit type cast when comparing UUID columns
with text parameters in raw queries.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Consultoria AS
2026-02-17 02:51:45 +00:00
parent 2bbab12627
commit 5ff5629cd8

View File

@@ -89,7 +89,7 @@ export async function getCfdiById(schema: string, id: string): Promise<Cfdi | nu
xml_original as "xmlOriginal",
created_at as "createdAt"
FROM "${schema}".cfdis
WHERE id = $1
WHERE id = $1::uuid
`, id);
return result[0] || null;
@@ -97,7 +97,7 @@ export async function getCfdiById(schema: string, id: string): Promise<Cfdi | nu
export async function getXmlById(schema: string, id: string): Promise<string | null> {
const result = await prisma.$queryRawUnsafe<[{ xml_original: string | null }]>(`
SELECT xml_original FROM "${schema}".cfdis WHERE id = $1
SELECT xml_original FROM "${schema}".cfdis WHERE id = $1::uuid
`, id);
return result[0]?.xml_original || null;