Lateral joins
Hi, from what I understand, lateral joins aren't supported by the query builder yet. I'm wondering what options I have to get type safe results from a query like this:
select f.id, f.family_name familyName, f.image_uuid imageUuid, json_agg(fm.data) members from family f left join lateral (select row_to_json(fm) data from (select * from member m where m.family_id = f.id) fm) fm on true group by f.id
3 Replies
There's a PR for adding lateral joins from around one year ago: https://github.com/drizzle-team/drizzle-orm/pull/1079
I'm also waiting for it and I'm hopeful that it'll be merged for the next release
I haven't found any workaround that'd allow it besides writing raw sql
How would you write the raw SQL of that query to get type-safe results though?
Thanks for the response.
Looks like maybe it's not ready to merge because the PR only supports Postgres. Someone probably has to go add support for the other databases as well.