Fix ?with=studios invalid date formats

This commit is contained in:
Zoe Roux 2025-07-07 23:30:44 +02:00
parent aa342cfbd3
commit a697ffb524
No known key found for this signature in database
2 changed files with 10 additions and 2 deletions

View File

@ -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<Studio>({ ...studioTrans, ...studioCol })),
jsonbAgg(
jsonbBuildObject<Studio>({
...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"),
})

View File

@ -109,6 +109,7 @@ export const queryFn = async <Parser extends z.ZodTypeAny>(context: {
" Parse error: ",
parsed.error,
);
console.log(parsed.error.issues);
throw {
status: "parse",
message: