Arsenalist

Arsenalist

Paginator ignores sort direction

I’m using the Paginator library and right before calling Repo.paginate(), I print the query which is:

Query: #Ecto.Query<from c0 in Amplify.Models.ContestEntry,
 where: c0.contest_id == ^"2", where: not is_nil(c0.prize_id),
 order_by: [desc: c0.inserted_at]>

This makes sense to me, but when I call paginate, it executes:

SELECT ... 
FROM "contest_entries" AS c0 
WHERE (c0."contest_id" = $1) AND (NOT (c0."prize_id" IS NULL)) AND (c0."inserted_at" < $2) 
ORDER BY c0."inserted_at" LIMIT $3 [2, ~U[2024-09-26 19:10:25Z], 4]

Notice that the executed ORDER BY does not have the DESC associated with it.

Could this be because I am passing before to paginator and it defaults to an ASC sort in that case when I really want a DESC sort? If so, how does Paginator handle traversing through a list sorted in reverse?

First Post!

arcyfelix

arcyfelix

I believe Paginator has been abandoned, and it is generally recommended that you migrate your code to Flop.

Last Post!

Arsenalist

Arsenalist

I’m not using limit/offset. I want to use cursor based paging.

Where Next?

Popular in Questions Top

vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

Other popular topics Top

New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54921 245
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New

We're in Beta

About us Mission Statement