Ash FrameworkAF
Ash Framework2y ago
7 replies
Sangres

error with keyset pagination and random sort

As the title says i'm trying to define an action that should list my posts in a random sort while using the keyset pagination.

This is the action that im calling
read :list do
  ...
  transaction? true

  prepare fn query, context ->
    Ash.Query.before_action(query, fn query ->
      OnmyjobsApp.Repo.query!("select setseed(#{0.42})")
      query
    end)
  end

  prepare before_action(&list_preparation/1)
  prepare build(sort: [Ash.Sort.expr_sort(fragment("RANDOM()"))])
  pagination keyset?: true, required?: true, countable: :by_default, default_limit: 10
end


I know that the problem is not the list_preparation that i'm calling.
The following problem is when i put the last two rows together
Was this page helpful?