graph-node
graph-node copied to clipboard
[Bug] Ordering by children can be nondeterministic
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.