Skip to content
Browse files

fix for #795 so that with keeps parameters also for single count(*) a…

…ggregation results
  • Loading branch information...
1 parent dd9ef78 commit 044690be903e1920dfd0dd8590c619bc7bee247e @jexp jexp committed Aug 21, 2012
View
6 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/EagerAggregationPipe.scala
@@ -53,7 +53,7 @@ class EagerAggregationPipe(source: Pipe, val keyExpressions: Seq[Expression], ag
})
if (result.isEmpty && keyNames.isEmpty) {
- createEmptyResult(aggregationNames)
+ createEmptyResult(aggregationNames, state)
} else result.map {
case (key, (ctx,aggregator)) =>
val newMap = MutableMaps.create
@@ -69,8 +69,8 @@ class EagerAggregationPipe(source: Pipe, val keyExpressions: Seq[Expression], ag
}
- private def createEmptyResult(aggregationNames: Seq[String]): Traversable[ExecutionContext] = {
- val newMap = MutableMaps.create
+ private def createEmptyResult(aggregationNames: Seq[String], state : QueryState): Traversable[ExecutionContext] = {
+ val newMap = MutableMaps.create(Parameters.createParamContextMap(state))
val aggregationNamesAndFunctions = aggregationNames zip aggregations.map(_.createAggregationFunction.result)
aggregationNamesAndFunctions.toMap
.foreach {
View
13 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/ParameterPipe.scala
@@ -26,14 +26,19 @@ import collection.mutable.Map
class ParameterPipe() extends Pipe {
def createResults(state: QueryState) = {
- val map: Map[String, Any] = state.params.map {
- case (k, v) => "-=PARAMETER=-" + k + "-=PARAMETER=-" -> ParameterValue(v)
- }
- Seq(ExecutionContext(map))
+ Seq(ExecutionContext(Parameters.createParamContextMap(state)))
}
val identifiers = Seq()
val symbols = new SymbolTable()
override def executionPlan(): String = "Parameters()"
+}
+
+object Parameters {
+ def createParamContextMap(state : QueryState) : Map[String, Any] = {
+ state.params.map {
+ case (k, v) => "-=PARAMETER=-" + k + "-=PARAMETER=-" -> ParameterValue(v)
+ }
+ }
}
View
11 cypher/src/test/scala/org/neo4j/cypher/ExecutionEngineTest.scala
@@ -2119,6 +2119,17 @@ RETURN x0.name?
assert(result.toList === List(Map("sum(foo)" -> 8)))
}
+ @Test
+ def with_should_not_forget_parameters() {
+ graph.index().forNodes("test")
+ val id = "bar"
+ val result = parseAndExecute("start n=node:test(name={id}) with count(*) as c where c=0 create x={name:{id}} return c, x", "id" -> id).toList
+
+ assert(result.size === 1)
+ assert(result(0)("c").asInstanceOf[Long] === 0)
+ assert(result(0)("x").asInstanceOf[Node].getProperty("name") === id)
+ }
+
@Ignore("This pattern is currently not supported. Revisit when we do support it.")
@Test
def two_double_optional_paths_with_shared_relationships() {

0 comments on commit 044690b

Please sign in to comment.
Something went wrong with that request. Please try again.