apoc icon indicating copy to clipboard operation
apoc copied to clipboard

APOC conditional procedures don't yield results if

Open neo-technology-build-agent opened this issue 2 years ago • 0 comments

Issue by InverseFalcon Wednesday Dec 04, 2019 at 23:49 GMT Originally opened as https://github.com/neo4j-contrib/neo4j-apoc-procedures/issues/1365


Expected Behavior

When using apoc.when(), apoc.do.when(), apoc.case(), and apoc.do.case(), we would expect that we would always have a row present after the call so we can continue working in the query.

Actual Behavior

For a non-empty query string, when RETURN isn't present in that string that end up being executed, nothing is YIELDed in the query, effectively wiping out the row and shortcircuiting any further operations.

(note that empty query strings, such as a '' for the else part, behaves as expected...the YIELDed value is present for the row, it is just an empty map)

How to Reproduce the Problem

Provided there as at least one node in the graph:

MATCH (n) 
WITH n 
LIMIT 1
CALL apoc.do.when(true, 'REMOVE n.nonExistent', '', {n:n}) YIELD value
RETURN value

Because the query string executed is non-empty and does not RETURN anything, nothing is YIELDed, so the row is wiped out and the query doesn't return anything.

This seems like unexpected and unwanted behavior. We do not want this to act as a filter, if that's needed then it can be handled outside of the procedure call.