This repository has been archived by the owner on Jan 30, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The subquery that builds the final contract tree when querying with links uses an inner join to get the nested link. Roughly: ``` JOIN ( // Build the linked contract... ) AS linked ON edge.source = linked.id ``` These joins are nested in the case of nested links and there is a toplevel `LATERAL`. In the case of two nested optional links, the `LATERAL` subquery looks roughly like this: ``` FROM cards, LATERAL ( // ... JOIN ( // ... ) AS linked ON edge1.source = linked.id // ... ) WHERE edge0.source = cards.id ``` If the optional contracts don't exist, `linked.id` will be null and the `edge1.to = linked.id` condition will fail. As a consequence, the whole lateral will be empty and so will the result. The fix is change those inner joins into left joins. This is a tentative fix because I have fuzzy memories of making this exact change and causing unrelated tests to fail. Fixes #1128 Change-type: patch Signed-off-by: Carol Schulze <carol@balena.io>
- Loading branch information