Skip to content

Commit

Permalink
Fixes #751: Better error message for some type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
systay committed Aug 24, 2012
1 parent 15f03c5 commit 8419f5e
Show file tree
Hide file tree
Showing 3 changed files with 20 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 @@ -9,6 +9,7 @@ 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
o Fixes #751: Better error message for some type errors

1.8.M07 (2012-08-08)
--------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ package org.neo4j.cypher.internal.executionplan.builders
import org.neo4j.cypher.internal.commands.Predicate
import org.neo4j.cypher.internal.pipes.{FilterPipe, Pipe}
import org.neo4j.cypher.internal.executionplan.{ExecutionPlanInProgress, PlanBuilder}
import org.neo4j.cypher.{CypherException, CypherTypeException, SyntaxException}

class FilterBuilder extends PlanBuilder {
def apply(plan: ExecutionPlanInProgress) = {
Expand Down Expand Up @@ -53,7 +54,18 @@ class FilterBuilder extends PlanBuilder {
}

private def yesOrNo(q: QueryToken[_], p: Pipe) = q match {
case Unsolved(pred: Predicate) => p.symbols.satisfies(pred.dependencies)
case Unsolved(pred: Predicate) => {

val dependencies = pred.dependencies

dependencies.forall(i => try {
p.symbols.assertHas(i)
true
} catch {
case e: CypherTypeException => throw e // If we have a mismatch in identifier type, throw directly
case _: CypherException => false
})
}
case _ => false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,12 @@ class ErrorMessagesTest extends ExecutionEngineHelper with Assertions with Strin
"Cypher does not support != for inequality comparisons. It's used for nullable properties instead.\nYou probably meant <> instead. Read more about this in the operators chapter in the manual.")
}

@Test def warn_about_type_error() {
expectError(
"START p=node(0) MATCH p-[r*]->() WHERE r.foo = 'apa' RETURN r",
"Expected `r` to be a Map but it was a Collection")
}

private def expectError[T <: CypherException](query: String, expectedError: String)(implicit manifest: Manifest[T]): T = {
val error = intercept[T](engine.execute(query).toList)

Expand Down

0 comments on commit 8419f5e

Please sign in to comment.