Permalink
Browse files

Collection concatenation handles types better

  • Loading branch information...
1 parent a60fe3e commit 466aec689b064a7ed015bfa995e65fb49cb8a750 @systay committed with jexp Aug 23, 2012
@@ -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)
@@ -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 466aec6

Please sign in to comment.