From 07a9125f9ca6a5c43e729a3f237f0b6b00d51dd7 Mon Sep 17 00:00:00 2001 From: Jacob Fletcher Date: Wed, 20 Nov 2024 15:02:08 -0500 Subject: [PATCH] fix(next): properly sets doc id types when using postgres (#9381) Fixes #9351. When using Postgres, doc ids were being treated as a string as opposed to a number within the admin panel. This led to issues for anything relying on the `docID` from context, such as the join field not properly populating initial data when creating new documents, etc. --- packages/next/src/utilities/initPage/handleAdminPage.ts | 4 ++-- test/joins/payload-types.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/next/src/utilities/initPage/handleAdminPage.ts b/packages/next/src/utilities/initPage/handleAdminPage.ts index 77c1da15a28..9ad1a8eb7ce 100644 --- a/packages/next/src/utilities/initPage/handleAdminPage.ts +++ b/packages/next/src/utilities/initPage/handleAdminPage.ts @@ -51,9 +51,9 @@ export function getRouteInfo({ globalConfig = config.globals.find((global) => global.slug === globalSlug) } - // If the collection has an ID field, we need to determine the type of the ID field + // If the collection is using a custom ID, we need to determine it's type if (collectionConfig && payload) { - if (payload.collections?.[collectionSlug]) { + if (payload.collections?.[collectionSlug]?.customIDType) { idType = payload.collections?.[collectionSlug].customIDType } } diff --git a/test/joins/payload-types.ts b/test/joins/payload-types.ts index 0ce8f77f7ba..7218bad040a 100644 --- a/test/joins/payload-types.ts +++ b/test/joins/payload-types.ts @@ -74,9 +74,9 @@ export interface Config { user: User & { collection: 'users'; }; - jobs?: { + jobs: { tasks: unknown; - workflows?: unknown; + workflows: unknown; }; } export interface UserAuthOperations {