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

Fix bug while nesting nested conditions. #184

Closed michael-simons closed 4 years ago

michael-simons commented 4 years ago

Please, @romain-rossi, would you mind having a look as well?

romain-rossi commented 4 years ago

Sure @michael-simons! As soon the build is done, I will test it.

romain-rossi commented 4 years ago

@michael-simons, I still have troubles with AND group. here is my unit test with the expected assertion:

    @Test
    void gh184() {
        final Node r = node("Resume").named("r");
        final Node u = node("UserSearchable").named("u");
        final Node o = node("Offer").named("o");

        Statement s = match(r.relationshipFrom(u, "HAS"))
                .where(r.hasLabels(LastResume.name()).not())
                .and(coalesce(o.property("valid_only"), literalFalse()).isEqualTo(literalFalse())
                        .and(r.hasLabels(InvalidStatus.name()).not())
                        .or(o.property("valid_only").isTrue()
                            .and(r.hasLabels(ValidStatus.name()))))
                .and(r.property("is_internship").isTrue()
                        .and(size(r.relationshipTo(Cypher.anyNode(),"PART_OF")).isEmpty())
                        .not())
                .and(r.property("is_sandwich_training").isTrue()
                        .and(size(r.relationshipTo(Cypher.anyNode(),"PART_OF")).isEmpty())
                        .not())
                .returningDistinct(r, o)
                .build();

        assertThat(cypherRenderer.render(s))
                .isEqualTo("MATCH (r:`Resume`)<-[:`HAS`]-(u:`UserSearchable`) WHERE (NOT (r:`LastResume`) AND (((coalesce(o.valid_only, false) = false) AND NOT r:`InvalidStatus`) OR (o.valid_only = true AND r:`ValidStatus`)) AND NOT ((r.is_internship = true AND size(size((r)-[:`PART_OF`]->())) = 0)) AND NOT ((r.is_sandwich_training = true AND size(size((r)-[:`PART_OF`]->())) = 0))) RETURN DISTINCT r, o");
    }

FYI, I'm using the 1.0.0-cd2216fe697ca7555db026423fbeac2555da8291 build release.

michael-simons commented 4 years ago

Actually, I think the output is correct. Added a formatted test… Please have a look @meistermeier as well.

michael-simons commented 4 years ago

Ok, got it… Gerrit focused my view on all those ( 👍

romain-rossi commented 4 years ago

All good! Thanks! Tested on built branch (1.0.0-508859e0acbc8ba889240d00b2bc946721957087)