Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes #751: Better error message for some type errors

  • Loading branch information...
commit 8419f5e0d081965714e29c4e64973e435543a1fa 1 parent 15f03c5
Andres Taylor authored
1  cypher/CHANGES.txt
View
@@ -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)
--------------------
14 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/FilterBuilder.scala
View
@@ -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) = {
@@ -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
}
6 cypher/src/test/scala/org/neo4j/cypher/ErrorMessagesTest.scala
View
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.