-
Notifications
You must be signed in to change notification settings - Fork 900
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 "Multiple Parents Found" issue when moving a relationship. #14060
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -522,7 +522,7 @@ def child_types(*args) | |
Relationship.resource_types(child_rels(*args)) | ||
end | ||
|
||
def parent=(parent) | ||
def add_parent(parent) | ||
parent.with_relationship_type(relationship_type) { parent.add_child(self) } | ||
end | ||
|
||
|
@@ -560,25 +560,28 @@ def add_children(*child_objs) | |
end | ||
alias_method :add_child, :add_children | ||
|
||
# | ||
# Backward compatibility methods | ||
# | ||
|
||
alias_method :set_parent, :parent= | ||
alias_method :set_child, :add_children | ||
|
||
def replace_parent(parent) | ||
def parent=(parent) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but now this method does not use the parameter There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what? it does...not sure what you mean. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. my bad. was reading GitHub diffs incorrectly. |
||
if parent.nil? | ||
remove_all_parents | ||
else | ||
parent.with_relationship_type(relationship_type) do | ||
parent_rel = parent.init_relationship | ||
init_relationship(parent_rel) # TODO: Deal with any multi-instances | ||
|
||
parent.clear_relationships_cache | ||
end | ||
end | ||
|
||
clear_relationships_cache | ||
end | ||
alias_method :replace_parent, :parent= | ||
|
||
# | ||
# Backward compatibility methods | ||
# | ||
|
||
alias_method :set_parent, :parent= | ||
alias_method :set_child, :add_children | ||
|
||
def replace_children(*child_objs) | ||
child_objs = child_objs.flatten | ||
|
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.
Am I reading this correctly that these two places are the only ones where we want might want to have multiple children/parents?
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.
Doh, I just read the comment above. So anyway, it makes sense, but to your point, there is probably untested code that might need to be changed. It's such a hard regex to find bad uses of
parent=
. 😢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.
Yeah, those are some of the intentional "multiple parents", so having a method that is specifically designed for that seems clearer.