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 nested validations #442

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

carlobeltrame
Copy link

@carlobeltrame carlobeltrame commented Dec 20, 2022

Nested validation errors on update operations are currently broken.
ActiveRecord objects are compared for equality by id only. The |= operator would ignore any children which are only updated, i.e. whose id has not changed. By reversing the target = target | [child] logic to target = [child] | target, we elect to keep the child with its updated attributes. This is relevant for detecting validation errors in the child later.

Let me know if you generally approve of this change, so I can start investing time into writing tests for it.

ActiveRecord objects are compared by id only. The |= operator would ignore any children which are only updated, i.e. whose id has not changed. By reversing the `target = target | [child]` logic to `target = [child] | target`, we elect to keep the child with its updated attributes. This is relevant for detecting validation errors in the child later.
@jkeen
Copy link
Collaborator

jkeen commented Feb 27, 2024

@carlobeltrame I just hopped in the ring to help here and am getting up to speed and sorting through these PRs and issues

I haven't personally run into this problem and I'm not sure if I'm fully understanding what's going on, but getting the tests running and new ones added to illustrate the issue you're solving would be great.

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.

None yet

2 participants