-
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
Allow multiple order_by columns #28
Comments
Hi @roykillany! Thanks for opening this issue. It's an interesting point, I can very well see use-cases where it might be beneficial to sort over more than one column (e.g. a users table with first and last name columns, and users should be sorted by their whole name). But if this is being built, we would probably also have to support different order directions per column (e.g. order ascending by one column and descending by another), right? This would make the implementation of it a bit tricky as all the order directions would need to be flipped when paginating backwards (using the One other thing we have to keep in mind is that all data that's used for ordering will have to be encoded in the cursor. Therefore, using too many order columns would lead to bigger and bigger cursors. But that's not really an argument against supporting multiple columns, as even a single text column could lead to a huge cursor. It's just something to keep in mind and probably also document to raise awareness in case we add this support. For the time being, you could probably work around this by adding a custom generated column that can then be used to order by as described in the However, I'm afraid I currently won't have the capacity to add this feature myself. But a PR for this would be very welcome and then we could collaborate on it further! |
I think an alternative to this is better support for computed columns (of course here indexes can become trickier) |
You might find this gem helpful - https://github.com/fatkodima/activerecord_cursor_paginate |
encountered the use case where i would like to order by two columns, but couldnt.
would like to have functionality similar to active records
.order
The text was updated successfully, but these errors were encountered: