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

prevents sync from setting unset attrs to undef #12

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

Conversation

ryan-lang
Copy link

Currently the sync method loops through all attributes in the target object and sets them with the source value for the corresponding attribute. This means that even unset attributes in the source will become set, undef attributes in the resulting object.

It is important to maintain the difference between attrs set to undef (null fields in document) and attrs that are unset (non-existent fields in document), and this commit ensures that distinction is made when using "sync".

I believe this should be the desired behavior, although it could certainly break backwards compatibility if people have adapted to the existing behavior. Thoughts?

@dagolden
Copy link
Collaborator

This seems quite sensible. Could you please add a test of the new behavior? It should fail without the commit you have and pass with it.

Thank you!

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