waseigo
(Possibly) platform-specific issue with ecto_sqlite3 and group_by/2
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:
Marked As Solved
brownerd
updating to {:ecto_sqlite3, “~> 0.18.1”} fixed the issue for me
2
Also Liked
waseigo
Popular in Questions
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
The Elixir Typespec docs show the following syntax for keyword lists in typespecs:
# ...
| [key: type] # keyword lists...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
Hi! May someone helps me, please!
I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
How to handle excepions in elixir?
Suppose i have A, B, C ,D, E modules. and each module has get() function.
A.get() method will call t...
New
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Other popular topics
Hi,
I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
Hi all,
I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage.
I’m trying to use Postgres...
New
Phoenix 1.4.0 released
Phoenix 1.4 is out! This release ships with exciting new features, most notably
with HTTP2 support, improved deve...
New
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
New
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
New
Hello guys,
I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
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
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








