SET within FOREACH fails when referring to outside identifiers as part of the expression #630

Closed
jexp opened this Issue Mar 17, 2013 · 4 comments

2 participants

@jexp
Neo4j member
START root=node(1) 
MATCH root -[foo:KNOWS]-> other 
WITH root, COLLECT(foo) AS foos FOREACH(foo in foos : 
                                        SET root = other) 
RETURN root

fails with: unknown identifier other

http://console.neo4j.org/r/9jgk7a

Also the stacktrace no longer allows reasoning about the source of the problem, it comes out of the execution-plan-building and has no nested exception.

Unknown identifier `other`
    at org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl.produceAndThrowException(ExecutionPlanImpl.scala:187)
    at org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl.prepareExecutionPlan(ExecutionPlanImpl.scala:64)
    at org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl.<init>(ExecutionPlanImpl.scala:36)
    at org.neo4j.cypher.ExecutionEngine$$anonfun$prepare$1.apply(ExecutionEngine.scala:80)
    at org.neo4j.cypher.ExecutionEngine$$anonfun$prepare$1.apply(ExecutionEngine.scala:80)
    at org.neo4j.cypher.internal.LRUCache.getOrElseUpdate(LRUCache.scala:37)
    at org.neo4j.cypher.ExecutionEngine.prepare(ExecutionEngine.scala:80)
    at org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:72)
    at org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:67)
    at org.neo4j.cypher.javacompat.ExecutionEngine.execute(ExecutionEngine.java:66)
    at org.neo4j.community.console.CypherQueryExecutor.cypherQuery(CypherQueryExecutor.java:170)
@ghost

Not a bug. You need to list "other" in WITH.

@ghost ghost closed this Mar 3, 2014
@cleishm

@jakub- I assume the error message is better since 2.0?

@ghost

@cleishm It's still:

Error: other not defined (line 5, column 21)
"         SET root = other)"

Are you suggesting the message should say how to fix the error if we can find a variable named other in the upper scopes? I agree that'd be nice.

@cleishm

No, that error is good enough, as it now contains the location information (it was generated from semantic check).

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment