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

[Bug] Ordering by children can be nondeterministic #5359

Open
lutter opened this issue Apr 19, 2024 · 0 comments
Open

[Bug] Ordering by children can be nondeterministic #5359

lutter opened this issue Apr 19, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@lutter
Copy link
Collaborator

lutter commented Apr 19, 2024

Bug report

With a schema like

type Parent @entity {
  id: Bytes!
 child: Child!
}

type Child @entity {
  id: Bytes!
}

the result for a query like

query { parents(orderBy: child__id) } { id } }

is nondeterministic if multiple parents point to the same child. To make this entirely clear, assume there is only one instance of Child. The SQL query that gets generated is roughly

select * 
  from parent p 
    left join child c on (c.id = p.child) 
where ...
order by c.id

But when multiple rows in p have the same p.child, that ordering is ill-defined. We'd need to change that to order by c.id, p.id to make that deterministic.

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