Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect cypher for _SOME filters on relationships to unions #4696

Open
Liam-Doodson opened this issue Feb 13, 2024 · 2 comments
Open

Incorrect cypher for _SOME filters on relationships to unions #4696

Liam-Doodson opened this issue Feb 13, 2024 · 2 comments
Labels
bug Something isn't working confirmed Confirmed bug

Comments

@Liam-Doodson
Copy link
Contributor

Type definitions

union Production = Movie | Series

type Movie {
    title: String!
    cost: Float
    runtime: Int
    actors: [Actor!]! @relationship(type: "ACTED_IN", direction: IN, properties: "ActedIn")
}

type Series {
    title: String!
    episodes: Int
    actors: [Actor!]! @relationship(type: "ACTED_IN", direction: IN, properties: "ActedIn")
}

type Actor {
    name: String!
    actedIn: [Production!]! @relationship(type: "ACTED_IN", direction: OUT, properties: "ActedIn")
}

type ActedIn @relationshipProperties {
    screenTime: Int
}

Test data

CREATE(a:Actor{name:"Some Name"})
CREATE(:Movie{title:"The Office"})<-[:ACTED_IN]-(a)
CREATE(:Series{title:"The Office"})<-[:ACTED_IN]-(a)

Steps to reproduce

Run this query:

query actedInWhere {
    actors(
        where: {
            actedIn_SOME: { Movie: { title_CONTAINS: "The Office" }, Series: { title_ENDS_WITH: "Office" } }
        }
    ) {
        name
    }
}

What happened

The actor with name="Some Name" is returned.

Expected behaviour

The query suggests that "some" productions the actor has acted in should be both a Series and a Movie. This is not the case for this actor so it should not have been returned.

The following cypher is generated for this query:

MATCH (this:Actor)
WHERE (EXISTS {
    MATCH (this)-[:ACTED_IN]->(this0:Movie)
    WHERE this0.title CONTAINS $param0
} AND EXISTS {
    MATCH (this)-[:ACTED_IN]->(this1:Series)
    WHERE this1.title ENDS WITH $param1
})
RETURN this { .name } AS this

As you can see, the AND is applied outside the EXISTS.

However, I would have expected cypher along these lines (note this is sudo code - I think the labels syntax is probably wrong):

MATCH (this:Actor)
WHERE (EXISTS {
    MATCH (this)-[:ACTED_IN]->(this0:Movie|Series)
    WHERE (this0.title CONTAINS $param0 AND label(this0) = "Movie") AND (this0.title ENDS WITH $param1 AND label(this0) = "Series")
}
RETURN this { .name } AS this

Version

4.4.5

Database version

5.13

Relevant log output

No response

@Liam-Doodson Liam-Doodson added the bug Something isn't working label Feb 13, 2024
@neo4j-team-graphql
Copy link
Collaborator

Many thanks for raising this bug report @Liam-Doodson. 🐛 We will now attempt to reproduce the bug based on the steps you have provided.

Please ensure that you've provided the necessary information for a minimal reproduction, including but not limited to:

  • Type definitions
  • Resolvers
  • Query and/or Mutation (or multiple) needed to reproduce

If you have a support agreement with Neo4j, please link this GitHub issue to a new or existing Zendesk ticket.

Thanks again! 🙏

@neo4j-team-graphql neo4j-team-graphql added the confirmed Confirmed bug label Feb 13, 2024
@neo4j-team-graphql
Copy link
Collaborator

We've been able to confirm this bug using the steps to reproduce that you provided - many thanks @Liam-Doodson! 🙏 We will now prioritise the bug and address it appropriately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed Confirmed bug
Projects
Status: Medium priority
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants