From a697ffb52408dfab43bf0c3f2e65a61c720d7f3f Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Mon, 7 Jul 2025 23:30:44 +0200 Subject: [PATCH] Fix `?with=studios` invalid date formats --- api/src/controllers/shows/logic.ts | 11 +++++++++-- front/src/query/query.tsx | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/api/src/controllers/shows/logic.ts b/api/src/controllers/shows/logic.ts index eb09ee8a..4fb3acf7 100644 --- a/api/src/controllers/shows/logic.ts +++ b/api/src/controllers/shows/logic.ts @@ -121,7 +121,7 @@ const showRelations = { .as("translations"); }, studios: ({ languages }: { languages: string[] }) => { - const { pk: _, ...studioCol } = getColumns(studios); + const { pk: _, createdAt, updatedAt, ...studioCol } = getColumns(studios); const studioTransQ = db .selectDistinctOn([studioTranslations.pk]) .from(studioTranslations) @@ -135,7 +135,14 @@ const showRelations = { return db .select({ json: coalesce( - jsonbAgg(jsonbBuildObject({ ...studioTrans, ...studioCol })), + jsonbAgg( + jsonbBuildObject({ + ...studioTrans, + ...studioCol, + createdAt: sql`to_char(${createdAt}, 'YYYY-MM-DD"T"HH24:MI:SS"Z"')`, + updatedAt: sql`to_char(${updatedAt}, 'YYYY-MM-DD"T"HH24:MI:SS"Z"')`, + }), + ), sql`'[]'::jsonb`, ).as("json"), }) diff --git a/front/src/query/query.tsx b/front/src/query/query.tsx index 97895b44..fc0dc5cf 100644 --- a/front/src/query/query.tsx +++ b/front/src/query/query.tsx @@ -109,6 +109,7 @@ export const queryFn = async (context: { " Parse error: ", parsed.error, ); + console.log(parsed.error.issues); throw { status: "parse", message: