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
Add cursor pagination desc order #2037
Conversation
It seems more complicated then I expected, for example for the following cases
We can say rules is that:
Will test it out and see how it works |
|
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.
Happy new year. Thank you! This is sure a lot of effort, and it seems to be working. I am not too concerned as long as our test coverage increases! (which leads to some comments below)
),])] | ||
); | ||
|
||
Ok(()) | ||
} | ||
|
||
#[smol_potat::test] | ||
async fn composite_keys_5() -> Result<(), DbErr> { | ||
async fn composite_keys_5_desc() -> Result<(), DbErr> { |
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.
We should avoid changing existing test cases, since it shrinks our test coverage. Can you extract the common parts and make it a new test case?
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.
I didn't change any existing tests, but duplicated all existing ones with desc
order, it shows a bit incorrectly by github, I assume because names composite_keys_5
and composite_keys_5_desc
and the rest of the test body except after
and first
replaced by before
, last
and desc
which produces same query, but reversed results
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.
Oh thanks! Got it now
].join(" ")) | ||
); | ||
|
||
assert_eq!( | ||
DbBackend::Postgres.build(& | ||
Entity::find() | ||
.cursor_by((Column::Col1, Column::Col2, Column::Col3, Column::Col4, Column::Col5, Column::Col6)) | ||
.after(("val_1", "val_2", "val_3", "val_4", "val_5", "val_6")) | ||
.before(("val_1", "val_2", "val_3", "val_4", "val_5", "val_6")).desc().apply_limit().apply_order_by().apply_filters() |
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.
Likewise, it's better to test both before and after separately.
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.
Same as my previous comment, it's a copy of cursor_by_many
named as cursor_by_many_desc
, no tests were removed or changed except additions like .apply_limit().apply_order_by().apply_filters()
because filters applied when we call all()
🎉 Released In 0.12.11 🎉Thank you everyone for the contribution! |
New Features
Add cursor pagination desc order support
Usage:
cursor_by().asc()
orcursor_by().desc()
Moved query builder logic inside
all
because it depends on sort orderasc/desc