# Sorting / Pagination

**URL:** <https://community.forestadmin.com/t/sorting-pagination/806>\
**Category:** Help me!\
**Created:** [August 12, 2020, 8:53am UTC](https://community.forestadmin.com/t/sorting-pagination/806 "2020-08-12T08:53:08Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ThomasSertorio](https://avatars.discourse-cdn.com/v4/letter/t/ecccb3/32.png) [@ThomasSertorio](https://community.forestadmin.com/u/ThomasSertorio)\
**Post date:** [August 12, 2020, 8:53am UTC](https://community.forestadmin.com/t/sorting-pagination/806/1 "2020-08-12T08:53:08Z")

</div>

## Expected behavior

I have 269 records in DB. When I filter the view on my state column and go through pages I should not see doublons in my records.

## Actual behavior

I actually see doublons !

 ![Capture d’écran 2020-08-12 à 10.16.37](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/1X/9d117b40b9e87104c3a67a4f040ad51858f0c1fd.png) ![Capture d’écran 2020-08-12 à 10.17.09](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/1X/0468e0da11747a15a0143cbed86dbb6b2fbeaad4.png)

## Context

```
"database_type": "postgresql",
"framework_version": "5.2.4.1",
"liana": "forest-rails",
"liana_version": "4.1.3",
"orm_version": "5.2.4.1"
"project": "voo"
```

---

<div class="post-metadata">

**Author:** ![anon62739609](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@anon62739609](https://community.forestadmin.com/u/anon62739609)\
**Post date:** [August 12, 2020, 1:10pm UTC](https://community.forestadmin.com/t/sorting-pagination/806/2 "2020-08-12T13:10:19Z")

</div>

Hi @ThomasSertorio and welcome into our community 👋 !

I do not reproduce your issue. Did you override any routes ?  
It looks like all your record are the same on the second page. Am I wrong ?

---

<div class="post-metadata">

**Author:** ![ThomasSertorio](https://avatars.discourse-cdn.com/v4/letter/t/ecccb3/32.png) [@ThomasSertorio](https://community.forestadmin.com/u/ThomasSertorio)\
**Post date:** [August 12, 2020, 4:24pm UTC](https://community.forestadmin.com/t/sorting-pagination/806/3 "2020-08-12T16:24:09Z")

</div>

Hi @anon62739609, thanks for getting back.

- I did not override any routes.
- Not sure what you mean by “all your records are the same” 🤔 ?

> Some records are the same as the one on the 1st page and this is my problem… but mostly not

---

<div class="post-metadata">

**Author:** ![arnaud](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/arnaud/32/32_2.png) [@arnaud](https://community.forestadmin.com/u/arnaud)\
**Post date:** [August 14, 2020, 8:23am UTC](https://community.forestadmin.com/t/sorting-pagination/806/4 "2020-08-14T08:23:34Z")

</div>

Hi @ThomasSertorio,

What kind of relationship is “Participations” in your ActiveRecord `compaign` model definition?  
Is it a `has_many` or a many to many relationship?  
In other words, are you sure that the 269 `participations` are unique in terms of `influencer`?

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![ThomasSertorio](https://avatars.discourse-cdn.com/v4/letter/t/ecccb3/32.png) [@ThomasSertorio](https://community.forestadmin.com/u/ThomasSertorio)\
**Post date:** [August 14, 2020, 9:14am UTC](https://community.forestadmin.com/t/sorting-pagination/806/5 "2020-08-14T09:14:22Z")

</div>

Hi @arnaud!  
`campaign has_many :participations` and `participation belongs_to :influencer`.  
Yes I am sure the 269 participations are unique in terms of influencer\_id. To further illustrate the case, I’v added the `participations.id`.

 ![Screenshot 2020-08-14 at 11.06.50](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/1X/abbcc61f02a2d5403e5bf9d07f7a6c56a5f9eff9.png)  
 ![Screenshot 2020-08-14 at 11.07.04](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/1X/33f5d53a5c4b6d73f484aab4e33826b037e29668.png)  
As you can see, we have on page 1 and page 2 the same record 🤷‍♂️. It might be related to the frontend management of the paginated sort 🤔

---

<div class="post-metadata">

**Author:** ![arnaud](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/arnaud/32/32_2.png) [@arnaud](https://community.forestadmin.com/u/arnaud)\
**Post date:** [August 14, 2020, 9:51am UTC](https://community.forestadmin.com/t/sorting-pagination/806/6 "2020-08-14T09:51:00Z")

</div>

Ok thanks,

Can we do another test to have more insights about the issue?  
Could you try to export those 269 participations using the “Export participations” action in the “Actions” dropdown?  
 ![Screenshot 2020-08-14 at 11.45.40](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/1X/83867fd66190296b9eec03deb586ff24b6b483aa.png)

Then if it would be great to confirm that the exported CSV file does not contain duplicate influencers.

I have 2 other questions:

- Do you have the same issue if you order by the `id` column (and not the `state` one)?
- Do you observe this issue only with this relationship in your project?

---

<div class="post-metadata">

**Author:** ![ThomasSertorio](https://avatars.discourse-cdn.com/v4/letter/t/ecccb3/32.png) [@ThomasSertorio](https://community.forestadmin.com/u/ThomasSertorio)\
**Post date:** [August 14, 2020, 11:39am UTC](https://community.forestadmin.com/t/sorting-pagination/806/7 "2020-08-14T11:39:57Z")

</div>

Alright,  
So:

- I confirm the CSV does not contain any duplicates, I have exactly 269 unique records
- I don’t have the same issue when ordering on id. The problem occurs with the state field (enum type)
- It’s difficult to say, if I observe the issue only on this relationship. Others does not necessssarly require pagination. Currently, it is really on this view and it is quite cumbersome as it’s a main admin view.

---

<div class="post-metadata">

**Author:** ![rap2h](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/rap2h/32/25_2.png) [@rap2h](https://community.forestadmin.com/u/rap2h)\
**Post date:** [August 17, 2020, 7:28am UTC](https://community.forestadmin.com/t/sorting-pagination/806/8 "2020-08-17T07:28:28Z")

</div>

Hi @ThomasSertorio 👋 thank you for your feedback.

There is actually a problem on Forest Admin side, probably due to `order by` and `limit` usage with pagination, on non-unique fields. We have to fix it, I opened an issue. Be sure you will be notified as soon as it is resolved. As a workaround, for now, you could try to use search, export, and sorting by ID features. Thank you for your patience and your help in understanding the bug. 🙏

---

<div class="post-metadata">

**Author:** ![anon62739609](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@anon62739609](https://community.forestadmin.com/u/anon62739609)\
**Post date:** [June 19, 2023, 11:53am UTC](https://community.forestadmin.com/t/sorting-pagination/806/9 "2023-06-19T11:53:02Z")

</div>

Hey @ThomasSertorio,

are you still experiencing this issue with the latest version ?
