memgraph / mage

MAGE - Memgraph Advanced Graph Extensions :crystal_ball:
Apache License 2.0
251 stars 25 forks source link

Not able to use updating clauses with write procedures #419

Closed matea16 closed 10 months ago

matea16 commented 10 months ago

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.

antoniofilipovic commented 10 months ago

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.

antepusic commented 10 months ago

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.