View Source Dequel.PreloadRequiredError exception (Dequel v0.7.0)

Exception raised when a query requires an association that hasn't been preloaded.

This error is raised by Dequel.matches?/2 when it encounters an %Ecto.Association.NotLoaded{} struct while traversing associations.

Example

book = Repo.get(Book, 1)  # author not preloaded
Dequel.matches?(book, "author.country:DE")
# => raises Dequel.PreloadRequiredError

To fix this, preload the required associations:

preloads = Dequel.preloads("author.country:DE")  # => [:author]
book = Repo.get(Book, 1) |> Repo.preload(preloads)
Dequel.matches?(book, "author.country:DE")
# => true or false