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

Wrong predicates generated on union types #5940

Open
Andy2003 opened this issue Jan 14, 2025 · 0 comments
Open

Wrong predicates generated on union types #5940

Andy2003 opened this issue Jan 14, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@Andy2003
Copy link
Contributor

Andy2003 commented Jan 14, 2025

given the schema:

type A @node {
    id: ID!
}
type B @node {
    id: ID!
}
union Base = A | B
type Test @node {
    id: ID!
    bases: [Base!]! @relationship(type: "HAS", direction: OUT)
}

I would expect different results for the following requests:

SINGLE

request

{
  tests(where: {bases_SINGLE: {A: {id: "1"}, B: {id: "1"}}}) {
    id
  }
}

actual result

MATCH (v0:Test)
WHERE (single(v1 IN [(v0)-[:HAS]->(v2:A)
  WHERE v2.id = $p0 | 1]
  WHERE true)
  AND single(v3 IN [(v0)-[:HAS]->(v2:B)
  WHERE v2.id = $p1 | 1]
  WHERE true))
RETURN v0 {
  .id
} AS v4

expected result

MATCH (v0:Test)
WHERE (single(v1 IN [(v0)-[:HAS]->(v2:A)
  WHERE v2.id = $p0 | 1]
  WHERE true)
  XOR single(v1 IN [(v0)-[:HAS]->(v2:B)
  WHERE v2.id = $p1 | 1]
  WHERE true))
RETURN v0 {
  .id
} AS v3

diff

image

SOME

request

{
  tests(where: {bases_SOME: {A: {id: "1"}, B: {id: "1"}}}) {
    id
  }
}

actual result

MATCH (v0:Test)
WHERE (EXISTS {
    MATCH (v0)-[:HAS]->(v1:A)
    WHERE v1.id = $p0
  }
  AND EXISTS {
    MATCH (v0)-[:HAS]->(v1:B)
    WHERE v1.id = $p1
  })
RETURN v0 {
  .id
} AS v2

expected result

MATCH (v0:Test)
WHERE (EXISTS {
    MATCH (v0)-[:HAS]->(v1:A)
    WHERE v1.id = $p0
  }
  OR EXISTS {
    MATCH (v0)-[:HAS]->(v1:B)
    WHERE v1.id = $p1
  })
RETURN v0 {
  .id
} AS v2

diff

image


Node: The diffs are from neo4j-graphql-java, so the left side is the js cypher and the right side is the java one. Top is the normalized version bottom the original.

@Andy2003 Andy2003 added the bug Something isn't working label Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant