-
Notifications
You must be signed in to change notification settings - Fork 276
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
Issue-1611 Fix in updating relations with ids #1612
Issue-1611 Fix in updating relations with ids #1612
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1612 +/- ##
=========================================
Coverage ? 94.02%
=========================================
Files ? 126
Lines ? 5721
Branches ? 0
=========================================
Hits ? 5379
Misses ? 342
Partials ? 0
Continue to review full report at Codecov.
|
end.compact | ||
end | ||
|
||
def delete_rels_for_nodes(ids) | ||
def delete_rels_for_nodes(original_ids, node_or_nodes) |
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.
Method delete_rels_for_nodes
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Code Climate has analyzed commit 30171e9 and detected 0 issues on this pull request. View more on Code Climate. |
@@ -49,31 +49,20 @@ def delete_all_rels | |||
# Deletes the relationships between all nodes for the last step in the QueryProxy chain and replaces them with relationships to the given nodes. | |||
# Executed in the database, callbacks will not be run. | |||
def replace_with(node_or_nodes) | |||
node_hash = idify_hash(node_or_nodes) | |||
node_or_nodes = Array(node_or_nodes).map { |arg| arg.is_a?(ActiveGraph::Node) ? arg : @model.find(arg) } |
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.
node_or_nodes = Array(node_or_nodes).map { |arg| arg.is_a?(ActiveGraph::Node) ? arg : @model.find(arg) } | |
nodes = Array(node_or_nodes).map { |arg| arg.is_a?(ActiveGraph::Node) ? arg : @model.find(arg) } |
This is guaranteed to be an array
Fixes #1611
This pull introduces/changes:
In case there was a string ID property, the
to_i
on passed id parameter would cause it be inconsistent with IDs of existing relations and we would end up with deleting all existing relations.