Open
Description
Versions:
- Elixir 1.17
- ecto 3.12.5
- ecto_sql 3.12.1
- ecto_sqlite3 0.15.1
- exqlite 0.29.0
Relevant code
def list_top_n_customers_by_order_count(n \\ 5) when is_integer(n) do
Customer
|> join(:inner, [c], o in assoc(c, :orders))
|> group_by([c, o], c.id)
|> select([c, o], %{id: c.id, name: c.name, num_orders: count(o.id)})
|> order_by([c, o], desc: count(o.id))
|> limit(^n)
|> Repo.all()
end
Issue
The above query function runs fine on Debian 12, but not on a Mac, as verified by @brownerd.
On Debian 12:
iex(892)> Insights.list_top_n_customers_by_order_count
[
%{id: 20, name: "Ernst Handel", num_orders: 10},
%{id: 63, name: "QUICK-Stop", num_orders: 7},
%{id: 65, name: "Rattlesnake Canyon Grocery", num_orders: 7},
%{id: 87, name: "Wartian Herkku", num_orders: 7},
%{id: 37, name: "Hungry Owl All-Night Grocers", num_orders: 6}
]
On Mac:
iex> Insights.list_top_n_customers_by_order_count
** (FunctionClauseError) no function clause matching in anonymous fn/1 in Ecto.Adapters.SQLite3.Connection.group_by/2
The following arguments were given to anonymous fn/1 in Ecto.Adapters.SQLite3.Connection.group_by/2:
# 1
%Ecto.Query.ByExpr{
expr: [{{:., [], [{:&, [], [0]}, :id]}, [], []}],
file: ".../Northwind/northwind_elixir_traders/lib/northwind_elixir_traders/insights.ex",
line: 43,
params: nil,
subqueries: []
}
...
Any reason why group_by/2
would not work on a Mac? It's the only thing that seems to be pertinently different between our respective setups--the other one being that I'm on Elixir 1.18.2, but the code was working fine even as far back as 1.14, so this can't be the root cause.
Paging @brownerd in case he can provide more information about the platform.
Metadata
Metadata
Assignees
Labels
No labels