Skip to content

Commit

Permalink
locking node while Assigning rel (#1710)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrhardikjoshi authored Dec 24, 2023
1 parent 4ffc7f1 commit 752b486
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def delete_all_rels
def replace_with(node_or_nodes)
node_or_nodes = Array(node_or_nodes).map { |arg| arg.is_a?(ActiveGraph::Node) ? arg : @model.find(arg) }
original_ids = self.pluck(:id)
ActiveGraph::Base.lock_node(start_object) unless start_object.new_record?
delete_rels_for_nodes(original_ids, node_or_nodes.collect(&:id))
add_rels(node_or_nodes, original_ids)
end
Expand Down
4 changes: 4 additions & 0 deletions lib/active_graph/transactions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def read_transaction(**config, &block)

alias transaction write_transaction

def lock_node(node)
node.as(:n).query.remove('n._AGLOCK_').exec if tx&.open?
end

private

def send_transaction(method, **config, &block)
Expand Down

0 comments on commit 752b486

Please sign in to comment.