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
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Kia ora,
We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
Hello,
I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New
Other Trending Topics
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
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #phoenix_html
- #iex
- #graphql
- #ai
- #genstage
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










First 10 of 18 Posts
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?