payload
payload copied to clipboard
[v3.0.0-beta.32] Has Many - Polymorphic Relationship Field ID Conflicts Across Collections Using PostgreSQL Adapter
Link to reproduction
No response
Describe the Bug
In a polymorphic relationship field within a 'Posts' collection, selecting an item with a specific ID from one related collection (e.g., Podcasts) causes other items with the same ID from other related collections (e.g., Videos, Images) to disappear from the relationship field options. This behavior occurs even though the items belong to different collections and should not interfere with each other.
To Reproduce
Steps to Reproduce the Behavior:
-
Define collections with a polymorphic relationship field in a
Posts
collection relating toVideos
,Podcasts
, andImages
.{ name: 'linkedContent', type: 'relationship', relationTo: ['videos', 'podcasts', 'images'], // This assumes these collections exist hasMany: true, },
-
Ensure there are items with overlapping IDs across these collections.
-
In the Payload admin UI, create a new post and attempt to link content using the
linkedContent
field. -
Select an item from one collection (e.g., Podcast with ID = 1).
-
Observe that items with the same ID from other collections (e.g., Video ID = 1, Image ID = 1) disappear from the selectable options in the
linkedContent
field.
Expected Behavior: Items from different collections should not affect the availability of items from other collections in a polymorphic relationship field, regardless of shared IDs.
Payload Version
payload-3-0-0-beta-32
Adapters and Plugins
Adapter: @payloadcms/db-postgres, Database: Supabase (PostgreSQL)