I am trying get the same result from a query, either using Repo.all and Repo.paginate. Repo.all returns the correct results but Repo.paginate returns different results. The queries are demonstrated below. Help me Understand why this is so
Cust_account
|> where([a], a.product_name == “Wood”)
|> order_by(desc: :amount)
|> limit(10)
|> Repo.all
The first query is equivalent to getting the first page using Repo.paginate.
What is the value in page? If it is >1, then the answer should be obvious.
Also, try to compare logged SQL queries.
It depends on a library you’re using for pagination. I assume Repo.paginate will overwrite limit and offset keys in a query. This can be easily checked by comparing SQL queries.