Skip to content

Commit

Permalink
Fixed #787: Issue when comparing array properties with literal collec…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
systay committed Aug 24, 2012
1 parent 1a5830b commit 3fb253b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions cypher/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ o Renamed iterable to collection
o Fixed #795: so that WITH keeps parameters also for empty aggregation results
o Fixed #772: Creating nodes/relationships goes before SET, so SET can run on already created elements
o Added error when using != instead of <>
o Fixed #787: Issue when comparing array properties with literal collections

1.8.M07 (2012-08-08)
--------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ case class Equals(a: Expression, b: Expression) extends Predicate with Comparer
def isMatch(m: Map[String, Any]): Boolean = {
val a1 = a(m)
val b1 = b(m)
a1 == b1

(a1, b1) match {
case (IsIterable(l), IsIterable(r)) => l == r
case _ => a1 == b1
}
}
def atoms = Seq(this)
def exists(f: (Expression) => Boolean) = a.exists(f) || b.exists(f)
Expand Down
18 changes: 18 additions & 0 deletions cypher/src/test/scala/org/neo4j/cypher/ExecutionEngineTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2218,4 +2218,22 @@ RETURN x0.name?
val result = parseAndExecute("START a=node(0) return length([[],[]]+[[]]) as l").toList
assert(result === List(Map("l" -> 3)))
}

@Test
def shouldAllowArrayComparison() {
val node = createNode("lotteryNumbers" -> Array(42, 87))

val result = parseAndExecute("start n=node(1) where n.lotteryNumbers = [42, 87] return n")

assert(result.toList === List(Map("n" -> node)))
}

@Test
def shouldSupportArrayOfArrayOfPrimitivesAsParameterForInKeyword() {
val node = createNode("lotteryNumbers" -> Array(42, 87))

val result = parseAndExecute("start n=node(1) where n.lotteryNumbers in [[42, 87], [13], [42]] return n")

assert(result.toList === List(Map("n" -> node)))
}
}

0 comments on commit 3fb253b

Please sign in to comment.