Currently, ecto supports lateral joins for fragments, but not for subqueries.
To steal an example from the original lateral join thread:
post = Repo.one(
from p in Post,
where: p.id == 123,
lateral_join: cs in subquery(
from c in Comment,
order_by: [desc: c.inserted_at],
where: c.post_id == p.id,
limit: 5
),
preload: [comments: cs]
)
The primary difficulty seems to come from the nested invocation of from (or to look at it another way, informing the subquery of some parent bindings.
I would be willing to put some work towards this, but I'd need guidance as I'm not very familiar with the ecto codebase. And we'd also have to decide what the solution would be.
Currently, ecto supports lateral joins for fragments, but not for subqueries.
To steal an example from the original lateral join thread:
The primary difficulty seems to come from the nested invocation of
from(or to look at it another way, informing the subquery of some parent bindings.I would be willing to put some work towards this, but I'd need guidance as I'm not very familiar with the ecto codebase. And we'd also have to decide what the solution would be.