Skip to content
Browse files

Collection concatenation handles types better

  • Loading branch information...
1 parent 9e3eaf0 commit 3ea24dea28fdee806612631f4f845240edd65c94 @systay committed Aug 23, 2012
View
9 cypher/src/main/scala/org/neo4j/cypher/internal/commands/Expression.scala
@@ -64,7 +64,14 @@ case class Null() extends Expression {
}
case class Add(a: Expression, b: Expression) extends Expression {
- val identifier = Identifier(a.identifier.name + " + " + b.identifier.name, ScalarType())
+ val identifier = Identifier("%s + %s".format(a.identifier.name, b.identifier.name), myType)
+
+ private def myType = if(a.identifier.typ.isAssignableFrom(b.identifier.typ))
+ a.identifier.typ
+ else if(b.identifier.typ.isAssignableFrom(a.identifier.typ))
+ b.identifier.typ
+ else ScalarType()
+
def compute(m: Map[String, Any]) = {
val aVal = a(m)
View
6 cypher/src/test/scala/org/neo4j/cypher/ExecutionEngineTest.scala
@@ -2212,4 +2212,10 @@ RETURN x0.name?
assert(result.startNode() === b)
assert(result.endNode() === a)
}
+
+ @Test
+ def literal_collection() {
+ val result = parseAndExecute("START a=node(0) return length([[],[]]+[[]]) as l").toList
+ assert(result === List(Map("l" -> 3)))
+ }
}

0 comments on commit 3ea24de

Please sign in to comment.
Something went wrong with that request. Please try again.