-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicated item on next page when ordering by DateTimes #101
Comments
I had this same problem. My solution was to decompose the timestamp into seconds and nanoseconds before adding it to the cursor, and then rebuilding it when deserializing. Serialization: Deserialization: |
I used @davefp suggestion and created a PR with support for DateTime objects as well as some spec coverage #111 until approval by gem owner, Im using my forked version https://github.com/callrail/rails_cursor_pagination |
Brilliant, that helped me!
|
I'm having this issue too. Would love to get this fixed! |
Closing this issue as it is resolved in version 0.4.0 we are about to release. Check #142 for more details. |
Hi there,
Thanks for providing this gem, it worked quite well for me!
I ran into a bug when ordering by dates where I'm not sure how to solve it in a nice way:
:datetime
columns) with precision 6 by default, so it looks like this in the DB:2022-11-28 15:34:18.999918
to_json
, which is used by the cursor encoding, only uses precision 3 by default, which looks like this as a string2022-11-28T15:34:18.999Z
When the cursor is decoded and used for the paginated query I always get one duplicated item from the previous page in the list, since
WHERE created_at > '2022-11-28T15:34:18.999Z'
is not the same as
WHERE created_at > '2022-11-28T15:34:18.999918Z'
I temporarily fixed it now by setting
ActiveSupport::JSON::Encoding.time_precision = 6
, but that change is global. Also I don't think you want your gems behavior be influenced by how Rails is configured?The text was updated successfully, but these errors were encountered: