Reputation: 8461
I'm trying to write what seems to be a easy Ecto query but I'm getting an error in which I'm not fully understanding.
Basically I'm trying match two ids against each other. here is my current attempt:
from(p in prediction_scores, where: p.league.id == ^league.id)
** (Ecto.Query.CompileError) `p.league().id()` is not a valid query expression
(ecto) expanding macro: Ecto.Query.where/3
I have a PredictionScore
that belongs to a League
and then I have a function that passes in a separate league
. My query is attempting to match the prediction_score league id against the passed in league id.
Hopefully this is enough information... Let me know if you need to see more I'd be happy to update.
Upvotes: 1
Views: 286
Reputation: 51339
You need to explicitly do joins:
from p in prediction_scores,
join: l in assoc(p, :league),
where: l.id == ^league.id
Upvotes: 2