-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Description
Describe the Bug
Bug: Incorrect relationship field type when id field is defined inside tabs
Description
When a collection defines a custom id field with type text, Payload correctly uses text as the type of the relationship field in referencing (join) collections if the id field is defined at the root level of the collection fields.
However, if the same id field is defined inside tabs, the relationship field generated in the referencing collection is incorrectly typed as number instead of text.
Expected behavior
If a collection has a custom id field of type text, all relationship fields referencing this collection should also use text, regardless of whether the id field is defined at the root level or inside tabs.
Actual behavior
When the id field is defined inside tabs, the generated relationship field in the referencing (join) collection uses type number.
Additional context
I initially encountered this issue while using seo-plugin, but the problem can be reproduced without the plugin, so it does not appear to be plugin-related.
Link to the code that reproduces this issue
https://github.com/ron-tayler/payload-bug-id-type-text-in-tabs
Reproduction Steps
Create a collection (e.g. products).
Define a custom id field with type: 'text' inside a tabs field.
Create another collection (e.g. groups) that references products via a relationship field.
Observe that the generated relationship field (e.g. product_id) in the referencing collection has type number instead of text.
Which area(s) are affected?
db: postgres
Environment Info
PS D:\dev\qls\bug-id-inside-tabs> npx payload info
Binaries:
Node: 22.14.0
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant Packages:
payload: 3.68.4
next: 15.4.10
@payloadcms/db-postgres: 3.68.4
@payloadcms/drizzle: 3.68.4
@payloadcms/graphql: 3.68.4
@payloadcms/next/utilities: 3.68.4
@payloadcms/richtext-lexical: 3.68.4
@payloadcms/translations: 3.68.4
@payloadcms/ui/shared: 3.68.4
react: 19.2.1
react-dom: 19.2.1
Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Pro
Available memory (MB): 48934
Available CPU cores: 12