neo4j / sdn-rx

Nextgen Spring Data module for Neo4j supporting (not only) reactive data access and immutable support
https://neo4j.github.io/sdn-rx
Apache License 2.0
65 stars 23 forks source link

Scalar Function HEAD(...) #187

Closed romain-rossi closed 4 years ago

romain-rossi commented 4 years ago

Could it be possible to add HEAD function (https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-head) to org.neo4j.springframework.data.core.cypher.Functions?

Example:

MATCH (r)<-[:HAS]-(u:UserSearchable)
WITH HEAD(COLLECT(r)) as r
RETURN r

Unit Test The unit test could be:

@Test
void gh187() {
    final Node r = node("Resume").named("r");
    final Node u = node("User").named("u");

    Statement s = match(r.relationshipFrom(u, "HAS"))
        .with(Functions.head(Functions.collect(r.getRequiredSymbolicName()).as("r"))
        .returning(r)
        .build();

    assertThat(cypherRenderer.render(s))
        .isEqualTo("MATCH (r)<-[:HAS]-(u:User) WITH HEAD(COLLECT(r)) as r RETURN r");
}

Thanks!

michael-simons commented 4 years ago

Good morning. We already spottet the usage in the call yesterday :) This will be added (together with last). Feel free to send a PR for other invocations. I'd be more than happy to incorporate contributions from you.

michael-simons commented 4 years ago

If you do so, please sign our contributors license agreement: https://neo4j.com/developer/cla/

romain-rossi commented 4 years ago

Cool! You rock :-) The agreement is sent. Thank you very much to let me contribute to your project!

michael-simons commented 4 years ago

Thanks. Received. Your PRs will now be build.