4
(from f in Foo,
select: %{id: id, total: fragment("cost1 + cost2 as total")},
order_by: f.total,
limit: 1) }> Repo.one
열 "f.total"라고하지 않습니다이 존재하지 않습니다
또한이 시도했다.이 쿼리를 만드는 방법에 대한 아이디어가 있으십니까?
(from f in Foo,
select: %{id: id, total: fragment("cost1 + cost2 as total")},
order_by: f.total,
limit: 1) }> Repo.one
열 "f.total"라고하지 않습니다이 존재하지 않습니다
또한이 시도했다.이 쿼리를 만드는 방법에 대한 아이디어가 있으십니까?
Ecto가 order_by: f.cost1 + f.cost2
을 지원하지 않는 이유는 확실하지 않지만 fragment
구문이 올바르지 않습니다. 올바른 구문은 다음과 같습니다.
(from f in Foo,
where: f.bar >= ^bar,
order_by: fragment("? + ?", f.cost1, f.cost2),
limit: 1) |> Repo.one
감사합니다. – DCameronMauch