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 afterOperation hooks in one-to-one relationships with foreign keys #9525

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lushkovsky-s
Copy link
Contributor

Description

This PR fixes an issue where afterOperation hooks weren't properly triggered on both sides of one-to-one relationships with db: { foreignKey: true }. Previously, when updating a relationship from the side without the foreign key, only the hooks for that list were triggered, while the actual database change occurred on the list with the foreign key.

Related Issues

Issue #9433

@dcousens dcousens requested review from dcousens and emmatown March 3, 2025 21:56
Copy link
Member

@emmatown emmatown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this makes sense to do. While the behaviour of relationships only running hooks on the local list (with the exception of nested creates going through the normal create flow) can certainly be a bit confusing, I think it's clearer for the behaviour to be exactly that rather than adding more exceptions like running only afterOperation and only for one-to-one relationships. Also, the performance impact of fetching the related items to pass into the hooks when it will often be unnecessary doesn't seem worth it.

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