Permalink
Browse files

Merge pull request #616 from systay/update-dependecies

fixes #613: Missing dependencies not reported correctly for queries with RELATE/SET/DELETE
  • Loading branch information...
2 parents d8d963b + 6372ca6 commit 25a2e91dd7d16d15d8da9edd59cdfc1f8ae4c202 @jexp jexp committed Jun 19, 2012
View
@@ -1,6 +1,8 @@
-1.8 (2012-06-21)
+1.8.M05 (2012-06-21)
--------------------
+o CREATE and RELATE can now introduce path identifiers
o Fixes #600: Double optional with no matching relationships returns too many rows
+o Fixes #613: Missing dependencies not reported correctly for queries with RELATE/SET/DELETE
1.8.M04 (2012-06-07)
--------------------
@@ -100,7 +100,8 @@ case class PartiallySolvedQuery(returns: Seq[QueryToken[ReturnColumn]],
def readyToAggregate = !(start.exists(_.unsolved) ||
patterns.exists(_.unsolved) ||
where.exists(_.unsolved) ||
- namedPaths.exists(_.unsolved))
+ namedPaths.exists(_.unsolved) ||
+ updates.exists(_.unsolved))
def rewrite(f: Expression => Expression):PartiallySolvedQuery = {
this.copy(
@@ -24,7 +24,10 @@ import org.neo4j.cypher.internal.commands.{CachedExpression, Expression}
import org.neo4j.cypher.internal.executionplan.{ExecutionPlanInProgress, PlanBuilder}
class ExtractBuilder extends PlanBuilder {
- def apply(plan: ExecutionPlanInProgress) = ExtractBuilder.extractIfNecessary(plan, plan.query.returns.flatMap(_.token.expressions(plan.pipe.symbols)))
+ def apply(plan: ExecutionPlanInProgress) = {
+ val expressions = plan.query.returns.flatMap(_.token.expressions(plan.pipe.symbols)).distinct
+ ExtractBuilder.extractIfNecessary(plan, expressions)
+ }
def canWorkWith(plan: ExecutionPlanInProgress) = {
val q = plan.query
@@ -45,4 +45,9 @@ class UpdateActionBuilder(db: GraphDatabaseService) extends PlanBuilder {
def canWorkWith(plan: ExecutionPlanInProgress) = plan.query.updates.exists(cmd => cmd.unsolved && plan.pipe.symbols.satisfies(cmd.token.dependencies))
def priority = PlanBuilder.Mutation
+
+ override def missingDependencies(plan: ExecutionPlanInProgress): Seq[String] = plan.query.updates.flatMap {
+ case Unsolved(cmd) => plan.pipe.symbols.missingDependencies(cmd.dependencies).map(_.name)
+ case _ => None
+ }
}
@@ -178,11 +178,37 @@ class ErrorMessagesTest extends ExecutionEngineHelper with Assertions with Strin
"These columns can't be listen in the WITH statement without renaming: count(*)")
}
+ @Test def missing_relate_dependency_correctly_reported() {
+ expectError(
+ "START a=node(0) RELATE a-[:KNOWS]->(b {name:missing}) RETURN b",
+ "Unknown identifier `missing`")
+ }
+
+ @Test def missing_create_dependency_correctly_reported() {
+ expectError(
+ "START a=node(0) CREATE a-[:KNOWS]->(b {name:missing}) RETURN b",
+ "Unknown identifier `missing`")
+ }
+
+ @Test def missing_set_dependency_correctly_reported() {
+ expectError(
+ "START a=node(0) SET a.name = missing RETURN a",
+ "Unknown identifier `missing`")
+ }
+
private def expectError[T <: CypherException](query: String, expectedError: String)(implicit manifest: Manifest[T]): T = {
val error = intercept[T](engine.execute(query).toList)
- val s = query + "\n" + error.toString()
- assertTrue(s, error.getMessage.contains(expectedError))
+ val s = """
+Wrong error message produced: %s
+Expected: %s
+ Got: %s
+""".format(query, expectedError, error)
+
+
+ if(!error.getMessage.contains(expectedError)) {
+ fail(s)
+ }
error
}

0 comments on commit 25a2e91

Please sign in to comment.