-
-
Notifications
You must be signed in to change notification settings - Fork 521
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
Cursor Pagination #754
Cursor Pagination #754
Conversation
Nice API! My biggest critic is that people will want to paginate on models that dont have a natural order via the PK. And supporting that will require a breaking change. |
I am a little confused that why there isn't any raw SQL unit tests to illustrate the behaviour |
Hey @Sytten, I have updated the API to... which user have full control over what column to filter Entity::find()
.order_by_asc(Column::Id)
.cursor()
.after(Column::Id, 10)
.last(2)
.all(&db)
.await?, |
Hey @tyt2y3, unit tests were being updated and now it asserts on plain SQL string |
What about order by non-unique keys? 🤔 |
You always need a column that is totally orderable for cursor pagination, even if you order by a partially orderable one. |
Thank you so far. Great work! I think there are 2 things we need to address: Instead of "inheriting" the order by clause, we should override it by the cursor column the user passes in via the The Cursor itself should hold which column to paginate on. As a result, the API can be simplified into: Entity::find()
.cursor(Column::Id)
.after(10)
.last(2)
.all(&db)
.await? And by the way, is there a real use case where we want to have a tuple of columns as cursor? We can always add that later with |
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.
As stated
@tyt2y3 like I commented above, you need to support two column if you want to support partially orderable columns. If not then you can use one column. |
1e2c1c4
to
9720c63
Compare
9720c63
to
bf882c8
Compare
a4ea08e
to
2201e4b
Compare
oh I didn't merge the sea-query side yet |
I reverted this merge. We need to upgrade sea-query to 0.25 first. |
* Custom join condition (SeaQL/sea-orm#793) * Migration does not depend on entity crate * Define integer enum with repr[x] syntax * Document datatype mappings (SeaQL/sea-orm#772) * Cursor pagination (SeaQL/sea-orm#754, SeaQL/sea-orm#822) * (de)serialize custom JSON types (SeaQL/sea-orm#794) * Generate new migration file (SeaQL/sea-orm#656) * Skip generating entity file for specific tables (SeaQL/sea-orm#837) * Generate entity with date time crate option (SeaQL/sea-orm#724) * Drop `SelectTwoMany::one()` method (SeaQL/sea-orm#813) * Datatype mappings of primitives (SeaQL/sea-orm#850, SeaQL/sea-schema#75) * Join with table alias (SeaQL/sea-orm#852) * SQLx logging level (SeaQL/sea-orm#800) * Insert with on conflict (SeaQL/sea-orm#791) * Migrate generate should take file name as argument instead of option (SeaQL/sea-orm#870) * Upgrade docusaurus to 2.0.0-beta.22 * What's new in SeaORM 0.9.0 * Move migration section forward * Rename "Generating Database Schema" section to "Generating SeaQuery Statement" * Fix broken links * Edit * Edit * Edit * Edit Co-authored-by: Chris Tsang <[email protected]>
PR Info
Adds
Cursor
&CursorTrait
, implementing cursor pagination for SeaORM