Permalink
Browse files

Merge pull request #817 from systay/751

Fixes #751: Better error message for some type errors
  • Loading branch information...
2 parents 15f03c5 + 8419f5e commit ba0bbb12836e7e26d5cd44b8dd719bd877486635 @jexp jexp committed Aug 24, 2012
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)
--------------------
@@ -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
}
@@ -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)

0 comments on commit ba0bbb1

Please sign in to comment.