Skip to content

Commit

Permalink
Update user-defined aggregation functions
Browse files Browse the repository at this point in the history
User-defined aggregation functions wasn't using `Values` properly
  • Loading branch information
pontusmelke committed Aug 21, 2017
1 parent f17a68b commit bace749
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ public void shouldBeAbleToCleanlyRunMultipleSessionsInSingleThread() throws Thro

// Then the two should not have interfered with each other
stream = runAndPull( secondMachine, "MATCH (a:Person) WHERE id(a) = " + id + " RETURN COUNT(*)" );
assertThat( ((Record) stream[0]).fields()[0], equalTo( 1L ) );
assertThat( ((Record) stream[0]).fields()[0], equalTo( longValue( 1L ) ) );
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ case class AggregationFunctionInvocation(signature: UserFunctionSignature, argum

override def apply(data: ExecutionContext)
(implicit state: QueryState) = {
val argValues = arguments.map(arg => arg(data)(state))
val argValues = arguments.map(arg => {
state.query.asObject(arg(data)(state))
})
aggregator.update(argValues)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ object ValueConversion {
case symbols.CTBoolean => b => Values.booleanValue(b.asInstanceOf[Boolean])
case symbols.CTFloat => d => Values.doubleValue(d.asInstanceOf[Double])
case symbols.CTInteger => l => Values.longValue(l.asInstanceOf[Long])
case symbols.CTNumber => l => Values.numberValue(l.asInstanceOf[Number])
case symbols.CTString => l => Values.stringValue(l.asInstanceOf[String])
case symbols.CTPath => p => AnyValues.asPathValue(p.asInstanceOf[Path])
case symbols.CTMap => m => AnyValues.asMapValue(m.asInstanceOf[java.util.Map[String, AnyRef]])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void shouldFailNicelyWhenInvalidRuntimeType()

// Expect
exception.expect( QueryExecutionException.class );
exception.expectMessage( "Can't coerce `42` to String" );
exception.expectMessage( "Can't coerce `Long(42)` to String" );

// When
db.execute( "MATCH (n) RETURN org.neo4j.procedure.count(n.prop) AS count" );
Expand Down

0 comments on commit bace749

Please sign in to comment.