Lateral Left Joins in Drizzle Core Queries
I am creating a more complex Postgres query that requires me to drop down to the sql abstractions of drizzle (my query needs to use window functions and group bys). In this same query, I would like to return a column that includes a list of relations, ideally as a JSON array. My initial instinct was to try to recreate the lateral left join query, similar to how the drizzle query builder returns relations using the
with
option.
However, in my reading of the documentation and the code, it doesn't appear that there is a way to access lateral left joins using the db.select()...
syntax. Reading through the code, it doesn't seem like the lateral
option is exposed as part of a public API.
I expect I might be able to write a subquery or a CTE in order to achieve this goal, but I was wondering whether there was anything I was missing/any way I could more easily replicate how drizzle achieves this goal?
Thanks!3 Replies
In my research, I noticed that there's an open PR that would address this: https://github.com/alexvuka1/drizzle-orm/tree/feature/GH-420-join-lateral-support
Hopefully it gets merged soon!
GitHub
GitHub - alexvuka1/drizzle-orm at feature/GH-420-join-lateral-support
TypeScript ORM that feels like writing SQL. Contribute to alexvuka1/drizzle-orm development by creating an account on GitHub.
Yes, Drizzle doesn't have support for lateral queries just yet
but it seems on the roadmap? 😄
thanks!