waseigo
Hello everyone,
A reader (@brownerd) of Northwind Elixir Traders has stumbled upon a weird issue that I am unable to replicate and it seems that it’s platform-specific.
The code in question is this very basic query:
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
When I’m running this function, I get the results just fine:
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}
]
When @brownerd runs the same code, he gets this:
** (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: []
}
...
We checked our respective dependencies and there is nothing peculiar about them. We both use:
ecto 3.12.5
ecto_sql 3.12.1
ecto_sqlite3 0.15.1
exqlite 0.29.0
There are two differences in environment:
- @brownerd uses Elixir 1.17, I use 1.18.2 – I doubt that this what causes the issue.
- @brownerd is on a Mac, I’m on Debian – this smells more like the root cause of the issue.
Has anyone here encountered such an issue before? I have also opened an issue here:
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication):
toke...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
dimitarvp
And what of the underlying SQLite versions? I’d think that’s the most likely culprit.
waseigo
How do I check this? Is it the version of
sqlite3_nif.sowithin~/.cache/elixir_make/exqlite-nif-2.17-*.tar.gz?Or does it relate to anything installed on system-level?
dimitarvp
Both of you should run
sqlite3 --versionin your terminals and compare.waseigo
Does using SQLite from Elixir depend on the version installed system-wide?
Johnny5
Unless you went out of your way to use system resources [1] then your system resources should have little to do with the failures (maybe could be differences in tooling to build the NIF though).
[1] GitHub - elixir-sqlite/exqlite: An SQLite3 driver for Elixir · GitHub
Johnny5
I’m not sure if your test suite is executed using GitHub Actions. However, it would be beneficial to test your code on both Linux and macOS. If you’re not already testing on macOS, it should be added to your testing environment.
waseigo
sqlite3 --version
3.43.2 2023-10-10
waseigo
No tests here, I still don’t know anything about testing
Also, now I regret installing Debian 12 on my 2012 MacBook Air–though it doesn’t really make a difference, if the issue is related with a precompiled binary for aarch64.
dimitarvp
As a first step I’d suggest both of you upgrade to the latest SQLite, make sure your versions are identical, and test again.
Eliminate the differences in the environments one by one. The SQLite version should be the first thing that’s synchronized.
waseigo
But how does the SQLite version installed system-wide impact what ex_sqlite uses? I thought it downloaded a precompiled version as a NIF, so since we both use the same package versions, both of our Elixir installations use the same (but most likely compiled for a different CPU arch, as most Macs right now use Apple Silicon)–or not?