Count distinct not supported?
Closed this issue · 2 comments
rhcarvalho commented
I'm getting an error "Distinct not supported in expressions", coming from:
ecto_sqlite3/lib/ecto/adapters/sqlite3/connection.ex
Lines 1463 to 1473 in a04c249
My query is like:
from(
s in SomeSchema,
where: s.tenancy_id == ^tenancy_id,
select: %{
users_count: count(s.user_id, :distinct)
}
)
|> App.Repo.one()Is there a supported way to write the query other than using a fragment?
warmwaffles commented
I'll need to check. I remember not implementing this for a reason, but I can not recall why I did not implement it. There was a limitation with how ecto composed a query for this. I'll need to investigate again.
rhcarvalho commented
This was solved in #171 (thanks @aseigo) and released in v0.20.0 (thanks @warmwaffles).