Maybe I missed something, but when I try the PostgreSQL example from the otherwise great "No More MultipleBagFetchException Thanks to Multiset Nested Collections" blog post, I get the following error:
[Code: 0, SQL State: 42P01] ERROR: missing FROM-clause entry for table "a"
Position: 156 [Script position: 156 - 168]
I've tried with DBVisualizer and DBeaver.
The faulty SQL:
SELECT
f.title,
(
SELECT coalesce(
jsonb_agg(jsonb_build_array("v0", "v1")),
jsonb_build_array()
)
FROM (
SELECT
a.first_name AS "v0",
a.last_name AS "v1"
FROM film_actor AS fa
JOIN actor AS f
USING (actor_id)
WHERE fa.film_id = f.film_id
) AS "t"
) AS actors,
(
SELECT coalesce(
jsonb_agg(jsonb_build_array("v0")),
jsonb_build_array()
)
FROM (
SELECT c.name AS "v0"
FROM film_category AS fc
JOIN category AS c
USING (category_id)
WHERE fc.film_id = f.film_id
) AS "t"
) AS categories
FROM film AS f
ORDER BY f.title
'a' isn't declared somewhere and the actor table doesn't contain column film_id ...
Kind regards
Dominik