Skip to content

Commit

Permalink
Collection concatenation handles types better
Browse files Browse the repository at this point in the history
  • Loading branch information
systay committed Aug 23, 2012
1 parent 9e3eaf0 commit 3ea24de
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.