I’m building a query that is attempting to find all “Predictions” where the “Prediction Score” column is nil:
query =
from(
p in Prediction,
where: p.team_id == ^team.id,
where: is_nil(p.prediction_score)
)
Repo.all(query)
But I’m getting this error:
** (Postgrex.Error) ERROR 42703 (undefined_column) column p0.prediction_score does not exist
The prediction_score
column is a has_one
field on Prediction:
schema "predictions" do
belongs_to(:league, League, foreign_key: :league_id, type: :binary_id)
belongs_to(:team, Team, foreign_key: :team_id, type: :binary_id)
belongs_to(:question, Question, foreign_key: :question_id, type: :binary_id)
has_one(:prediction_score, PredictionScore) <--- HERE
embeds_one(:details, Details)
timestamps()
end
Does ecto/postgrex not see the has_one as a column on that table? Is there some nice way I can achieve this functionality that I’m not aware of?