-
Notifications
You must be signed in to change notification settings - Fork 1.4k
PHPORM-211 Fix unsetting property in embedded model #3052
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
Conversation
if (str_starts_with($key, '$')) { | ||
assert(is_array($value), 'Update operator value must be an array.'); | ||
$results[$key] = static::getUpdateValues($value, $prepend); | ||
} else { | ||
$results[$prepend . $key] = $value; | ||
} |
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.
Before, the incorrect update was:
{
$set: {
"address.$.updated_at": Date(...),
"address.$.$unset": {
"city": true,
}
}
}
After, it becomes:
{
"$unset": {
"address.$.city": true,
},
"$set": {
"address.$.updated_at": Date(...),
}
}
Field names starting with a $
are not supported, that's why we are sure there will not be 2 levels of recursion.
Book::truncate(); | ||
Item::truncate(); | ||
Role::truncate(); | ||
Client::truncate(); | ||
Group::truncate(); | ||
Photo::truncate(); |
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.
Side change: This models are not used in this test class.
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.
Nit about the assertion method, but LGTM other than that!
Co-authored-by: Andreas Braun <git@alcaeus.org>
Fix PHPORM-211
Checklist