Skip to content

Commit

Permalink
Fix #7087: Procedures yielding collection of nodes are treated as sin…
Browse files Browse the repository at this point in the history
…gle node
  • Loading branch information
boggle committed May 12, 2016
1 parent 31e7272 commit 67dd909
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
Expand Up @@ -104,10 +104,14 @@ case class ProcedureCallPipe(source: Pipe,
), variables) ), variables)
} }


override def symbols = resultSymbols.foldLeft(source.symbols) { override def symbols = {
val sourceSymbols = source.symbols
val outputSymbols = resultSymbols.foldLeft(sourceSymbols) {
case (symbols, (symbolName, symbolType)) => case (symbols, (symbolName, symbolType)) =>
symbols.add(symbolName, symbolType.legacyIteratedType) symbols.add(symbolName, symbolType)
} }
outputSymbols
}


override def localEffects = AllEffects override def localEffects = AllEffects


Expand Down
Expand Up @@ -644,6 +644,19 @@ private String createCsvFile( String... lines ) throws IOException
return file.toURI().toURL().toString(); return file.toURI().toURL().toString();
} }



@Test
public void shouldReturnNodeListTypedAsNodeList()
{
// When
Result res = db.execute( "CALL org.neo4j.procedure.nodeList() YIELD nodes RETURN extract( x IN nodes | id(x) ) as ids" );

// Then
assertTrue( res.hasNext() );
assertThat( ((List<?>) res.next().get( "ids" ) ).size(), equalTo( 2 ) );
assertFalse( res.hasNext() );
}

@Before @Before
public void setUp() throws IOException public void setUp() throws IOException
{ {
Expand Down Expand Up @@ -729,6 +742,16 @@ public PathOutputRecord( Path path )
} }
} }


public static class NodeListRecord
{
public List<Node> nodes;

public NodeListRecord( List<Node> nodes )
{
this.nodes = nodes;
}
}

public static class ClassWithProcedures public static class ClassWithProcedures
{ {
@Context @Context
Expand Down Expand Up @@ -921,8 +944,6 @@ public void delegatingSideEffect( @Name( "value" ) String value )
db.execute( "CALL org.neo4j.procedure.sideEffect", map( "value", value ) ); db.execute( "CALL org.neo4j.procedure.sideEffect", map( "value", value ) );
} }


private static final ScheduledExecutorService jobs = Executors.newScheduledThreadPool( 5 );

@Procedure @Procedure
@PerformsWrites @PerformsWrites
public void unsupportedProcedure() public void unsupportedProcedure()
Expand All @@ -948,5 +969,18 @@ public Stream<PathOutputRecord> nodePaths( @Name( "node" ) Node node )
.stream() .stream()
.map( record -> new PathOutputRecord( (Path) record.getOrDefault( "p", null ) ) ); .map( record -> new PathOutputRecord( (Path) record.getOrDefault( "p", null ) ) );
} }

@Procedure
@PerformsWrites
public Stream<NodeListRecord> nodeList()
{
List<Node> nodesList = new ArrayList<>();
nodesList.add( db.createNode() );
nodesList.add( db.createNode() );

return Stream.of( new NodeListRecord( nodesList ) );
}
} }

private static final ScheduledExecutorService jobs = Executors.newScheduledThreadPool( 5 );
} }

0 comments on commit 67dd909

Please sign in to comment.