I have two schemata Person and Book.
Both Book.author_id and Book.illustrator_id reference Person.id.
I want to load all books and preload all associated people. My query looks like this:
from(b in Book,
join: a in assoc(b, :author),
join: i in assoc(b, :illustrator),
preload: [author: a, illustrator: i]
)
|> Repo.all()
I have a very large number of books. Would it be possible to join Person only once and let an Ecto preload function handle the matching?
Strangely enough, the following code correctly preloads the author, but illustrator is always identical to author which is wrong.
join: p in Person,
on: p.id in [b.author_id, b.illustrator_id],
preload: [author: p, illustrator: p] # ???






















