-
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
Improve support for sorting by a timestamp column #142
Conversation
180f828
to
ef00cf5
Compare
ef00cf5
to
8979030
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for submitting this PR and for factoring in the changes done by
@xijo in #92 and @amandawraymond in #111 . I think having this in a separate cursor class should make maintenance and extensibility easier in future and having the cursor encode a number for the timestamp field should lead to more compact cursors than encoding an object with their own keys.
I've left a few comments, let me know if there are any questions on them and let's try to get this released soon 🙂
…rsors add spec coverage for timestamp order_by selector in pagination fetch Bump version to 0.3.1
Merge the latest changes from master into this PR to "rebase" it and avoid a force push.
ddf8237
to
f255e47
Compare
Add a new subclass of the `Cursor` class to encode/decode cursors using a timestamp column (such as `created_at`) as order field. It encodes the value of the field as a number with microsecond resolution (the default for MySQL). This cursor class is instantiated instead of the regular `Cursor` when an `order_field` of a compatible type is used to configure the paginator.
Apply suggestions to improve methods' documentation Co-authored-by: Nicolas Fricke <[email protected]>
f255e47
to
e7e539e
Compare
This PR uses #111 as a base to introduce a new type of cursor to be used when ordering by timestamp columns (e.g.
created_at
).The paginator detects that the SQL type of
order_by
is a:datetime
(here) and instantiates a new type of cursor that is able to correctly encode timestamps with the resolution of 1 microsecond.This allows pagination to work correctly down to the smallest fraction supported by default.
Fixes #101 #92