dwyl / library

The embryonic iteration of dwyl's library app
https://dwyl-library.herokuapp.com/
15 stars 1 forks source link

Multiple results for books with multiple authors #64

Closed finnhodgkin closed 7 years ago

finnhodgkin commented 7 years ago

When searching for books that have multiple authors by title only, a result is shown for each book:

selection_104

finnhodgkin commented 7 years ago

With an extra preload: [author: a] Ecto doesn't show duplicate results :+1:

from b in Book,
preload: [:request, :book_loan],
where: ilike(b.title, ^"%#{title}%"),
join: a in assoc(b, :author),
where: ilike(a.author, ^"%#{author}%"),
preload: [author: a]