-
-
Notifications
You must be signed in to change notification settings - Fork 4k
EntityWorldMut
methods do not automatically overwrite Relationship
components
#19601
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
EntityWorldMut
methods do not automatically overwrite Relationship
components
#19601
Conversation
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.
Okay, this fix makes sense to me, the code is good, the migration guide is good and there are tests. I have a couple small suggestions, but nothing blocking.
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.
Only got a final nitpick, otherwise I couldn't see anything that stood out to me.
(Got pleasantly surprised I was asked to review, hope I'm doing this properly.)
It's much appreciated! |
Objective
Some methods and commands carelessly overwrite
Relationship
components. This may overwrite additional data stored at them which is undesired.Part of #19589
Solution
A new private method will be used instead of insert:
modify_or_insert_relation_with_relationship_hook_mode
.This method behaves different to
insert
ifRelationship
is a larger type thanEntity
and already contains this component. It will then use themodify_component
API and a newRelationship::set_risky
method to set the related entity, keeping all other data untouched.For the
replace_related
(_with_difference
) methods this also required aInsertHookMode
parameter for efficient modifications of multiple children. The changes here are limited to the non-public methods.I would appreciate feedback if this is all good.
Testing
Added tests of all methods that previously could reset
Relationship
data.