memgraph/mage

Not able to use updating clauses with write procedures

Closed this issue · 2 comments

Two reported instances of not being able to use updating clauses with procedures being a blocker for the user. One related to the previously opened issue about merge.relationship and one related to a recent Discord thread where SET clause can not be used after refactor.clone_subgraph

To replicate, first create any two connected nodes and then run a following query:

MATCH (john:Node {name: 'John'}), (maria:Node {name: 'Maria'})
MATCH (john)-[r1:KNOWS]->(maria)
CALL refactor.clone_subgraph([john, maria], [r1])
YIELD input, output
SET output.clone = 'True'
RETURN input, output;

it throws the following error:
Update clause can't be put after calling a writeable procedure, only RETURN clause can be put after.

So this was a high-level discussion that after the write CALL procedure you can't do any updates. For now, what is possible to do is implement everything inside the procedure.

Hello @matea16! As Antonio said, the behavior you described here is expected from Memgraph and thus I’m closing this issue. Nonetheless, you can get around this issue by implementing a new procedure: adding a few lines of code to refactor.clone_subgraph that set the clone property of nodes should do the trick.