-
Notifications
You must be signed in to change notification settings - Fork 577
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 setting an object with an embedded object property to null
#6295
Conversation
// Asking for the toBinding will create the object and link it to the parent in one operation. | ||
// Thus, no need to actually set the value on the `obj` unless it's an optional null value. | ||
const bindingValue = toBinding(value, { createObj: () => [obj.createAndSetLinkedObject(columnKey), true] }); | ||
// No need to destructure `optional` and check that it's `true` in this condition | ||
// as trying to set a non-optional value to null will fail at an earlier stage. | ||
if (bindingValue === null) { | ||
obj.setAny(columnKey, bindingValue); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The call to toBinding()
will in turn call nullPassthrough(), resulting in toBinding()
returning null
without calling into Core. For other non-null and non-undefined values, the embedded object will be created during that call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's a good catch!
// Asking for the toBinding will create the object and link it to the parent in one operation. | ||
// Thus, no need to actually set the value on the `obj` unless it's an optional null value. | ||
const bindingValue = toBinding(value, { createObj: () => [obj.createAndSetLinkedObject(columnKey), true] }); | ||
// No need to destructure `optional` and check that it's `true` in this condition | ||
// as trying to set a non-optional value to null will fail at an earlier stage. | ||
if (bindingValue === null) { | ||
obj.setAny(columnKey, bindingValue); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's a good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…lm#6295) * Update DB obj when embedded prop is set to null. * Add tests. * Add CHANGELOG entry. * Update inline comment. * Add tests using 'UpdateMode'. * Extract common logic to separate function to make the tests more focused.
What, How & Why?
Updating an object's property whose value was an embedded object did not call into Core to update the underlying object when the new value was
null
orundefined
.This closes #6280
☑️ ToDos