Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue - media type always gets updated on saving MorphMany relationship #527

Merged

Conversation

m7moudabdel7mid
Copy link
Contributor

Hi,

This pull request addresses a bug with saving a MorphMany relationship where records are not properly filtered by their type before being updated. This causes the type column of some records to be incorrectly overwritten, leading to data inconsistencies and duplicate records.

Steps to Reproduce:

  1. Create two CuratorPicker components with different typeValue attributes for the same relationship:
CuratorPicker::make('media_1')->multiple()->typeValue('t1')->relationship('media_items', 'id'),
CuratorPicker::make('media_2')->multiple()->typeValue('t2')->relationship('media_items', 'id'),
  1. Select the same file in both pickers and save. The first save works correctly.
  2. Save again, and observe that all media_items are incorrectly updated to type 't1', with a new record created for type 't2'.

This fix ensures that records are filtered by typeValue before updates, preventing incorrect modifications and maintaining data integrity.

@awcodes awcodes merged commit 67c448a into awcodes:3.x Aug 24, 2024
4 checks passed
@awcodes
Copy link
Owner

awcodes commented Aug 24, 2024

Thanks. 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants