payload icon indicating copy to clipboard operation
payload copied to clipboard

[v3.0.0-beta.32] Has Many - Polymorphic Relationship Field ID Conflicts Across Collections Using PostgreSQL Adapter

Open jamesryancooper opened this issue 9 months ago • 0 comments

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:

  1. Define collections with a polymorphic relationship field in a Posts collection relating to Videos, Podcasts, and Images.

    	{
    		name:  'linkedContent',
    		type:  'relationship',
    		relationTo:  ['videos',  'podcasts',  'images'],  // This assumes these collections exist
    		hasMany:  true,
    	},
    
  2. Ensure there are items with overlapping IDs across these collections.

  3. In the Payload admin UI, create a new post and attempt to link content using the linkedContent field.

  4. Select an item from one collection (e.g., Podcast with ID = 1).

  5. 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.

Screenshot 2024-05-15 at 9 50 20 AM Screenshot 2024-05-15 at 9 50 37 AM

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)

jamesryancooper avatar May 15 '24 15:05 jamesryancooper