Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix so identifiers created inside a foreach can be used by other stat…

…ements in the foreach
  • Loading branch information...
commit 58e12d13657b6d60bdedfc9aba2a545ef7f92029 1 parent 88a9e36
@systay authored
View
1  cypher/CHANGES.txt
@@ -5,6 +5,7 @@ o Fixes #946 - HAS(...) fails with ThisShouldNotHappenException for some pattern
o Made Cypher better at keeping a numeric type. Adding two integers now returns an integer, and not a double.
o Major refactoring to make certain Cypher is more lazy
o When asking for the top x rows by some value, Cypher will now only keep a list the size of x
+o Fix so identifiers created inside a foreach can be used by other statements in the foreach
1.9.M01 (2012-10-23)
--------------------
View
5 cypher/src/main/scala/org/neo4j/cypher/internal/mutation/ForeachAction.scala
@@ -42,7 +42,7 @@ case class ForeachAction(collection: Expression, id: String, actions: Seq[Update
})
before match {
- case None => context.remove(id)
+ case None => context.remove(id)
case Some(old) => context.put(id, old)
}
@@ -64,8 +64,9 @@ case class ForeachAction(collection: Expression, id: String, actions: Seq[Update
}
def symbolTableDependencies = {
+ val updateActionIdentifiers: Set[String] = actions.flatMap(_.identifiers.map(_._1)).toSet
val updateActionsDeps = actions.flatMap(_.symbolTableDependencies).filterNot(_ == id).toSet
val collectionDeps = collection.symbolTableDependencies
- updateActionsDeps ++ collectionDeps
+ (updateActionsDeps -- updateActionIdentifiers) ++ collectionDeps
}
}
View
7 cypher/src/test/scala/org/neo4j/cypher/ExecutionEngineTest.scala
@@ -2278,4 +2278,11 @@ RETURN x0.name?
assert(result.toList === List(Map("b" -> b)))
}
+
+ @Test
+ def can_use_identifiers_created_inside_the_foreach() {
+ val result = parseAndExecute("start n=node(0) foreach (x in [1,2,3] : create a= { name: 'foo'} set a.id = x)")
+
+ assert(result.toList === List())
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.