Skip to content

Bug: sorting on multiple fields does not work #745

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

Closed
bart-degreed opened this issue May 12, 2020 · 6 comments · Fixed by #755
Closed

Bug: sorting on multiple fields does not work #745

bart-degreed opened this issue May 12, 2020 · 6 comments · Fixed by #755
Labels

Comments

@bart-degreed
Copy link
Contributor

bart-degreed commented May 12, 2020

A query like /api/articles?sort=authorName,-pageCount should sort on author, and within that subset sort in pageCount in descending order.

QueryableExtensions contains two methods:

public static IOrderedQueryable<TSource> Sort<TSource>(this IQueryable<TSource> source, SortQueryContext sortQuery) { ... }

public static IOrderedQueryable<TSource> Sort<TSource>(this IOrderedQueryable<TSource> source, SortQueryContext sortQuery) { }

But the second one (building query based upon a parent ordering) is never called.

@fdlane
Copy link
Contributor

fdlane commented May 12, 2020

Also use cases with multiple sorts on the same entity like /api/user?sort=-lastLoginTime, username no longer sort.

@bart-degreed
Copy link
Contributor Author

How is that use case different from the problem stated?

@fdlane
Copy link
Contributor

fdlane commented May 13, 2020

It may not be...Just wanted to point out that if there were no related entities involved, the multiple sort does not work either.

From your example, if you specify sort by title and pageCount, no sorting occurs. Note, author is not part of this sort. This may be a distinction without a difference. :)

@bart-degreed
Copy link
Contributor Author

Ah, I understand now. My example could have been clearer. with 'author' I meant a single string attribute containing the author name, not a relationship. I don't think specifying a relationship in sort is possible -- at least, I would not know what sort=author means when author is a relationship, because it does not indicate on which author attribute to sort.

@fdlane
Copy link
Contributor

fdlane commented May 13, 2020

@bart-degreed thank you for your patience.

@bart-degreed
Copy link
Contributor Author

No problem :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants