-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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 order parameter #5989
Add order parameter #5989
Conversation
looks good 👍, @ErisDS does ordering interfere with filtering? |
Rebased latest changes, now ready to merge. |
This doesn't interfere with filtering - it just needs to play nicely with it :) Using the model name prefix as mentioned here would help with that I think. This is all looking great so far, it might be worth adding a test to show that you can order |
Sure, will update (it's in PR's todo list) ;) |
So, while implementing support for ordering by rows from outside tables (when using For example, I want to fetch posts and include author information in them: PostAPI.browse({include: 'author'}); I'd expect a It finds posts, then looks for Summary: Because of this issue, it is not possible to order by "joined" values, e.g. |
refs #5602 - add "order" to default browse options - accept & parse order parameter in Base model - add tests for posts order
We are going to merge this PR as it is, without support for ordering by joined columns. Work on that problem will continue in a separate issue/PR (will be linked here). |
Hey @vdemedes I have been trying to test this using the {{#get}} helper. It is working nicely so far for posts but if I fetch users or tags then the ordering does not seem to be working. Example
Would you expect that to work/have I missed something? |
Hey @cobbspur, that's my oversight, thanks for pointing this out! |
This PR adds
order
parameter tobrowse
endpoints.Closes #5602.
Supplied input string (e.g.
title desc
) is converted to the same format as produced byorderDefaultOptions()
:Example
Upper-cased
DESC
andASC
are also allowed. Spaces after commas are not required, this input is also valid:title desc, updated_at asc
.Note: If order parameter contains attributes, that do not belong to the current model, they will be ignored:
bunny desc, title asc
(bunny
is skipped).Todo
posts.title desc
orderDefaultOptions()
)