This repository was archived by the owner on Dec 16, 2025. It is now read-only.
Add feature: sort queryparams can be relationship fileds#111
Open
babywolfh wants to merge 3 commits intomiLibris:masterfrom
Open
Add feature: sort queryparams can be relationship fileds#111babywolfh wants to merge 3 commits intomiLibris:masterfrom
babywolfh wants to merge 3 commits intomiLibris:masterfrom
Conversation
added 3 commits
August 15, 2018 16:01
sort queryparams can be relationship fileds
1. delete sort relationship exception 2. add a case to test get list with relationship sort queryparams
Contributor
|
I think it is a good start to implement sorting on relationship fields but it would be better that you can specify the related field to sort on instead of only use to related "id" field. ex: {'field': field, 'order': order, 'relationship_field': related_field} |
akira-dev
suggested changes
Sep 29, 2020
| if sort_opt['relationship']: | ||
| relationField = getattr(self.model, field) | ||
| relationClass = relationField.mapper.class_ | ||
| query = query.join(relationField).order_by(getattr(getattr(relationClass, 'id'), sort_opt['order'])()) |
Contributor
There was a problem hiding this comment.
I think it is not good to use the id field because it can not exists. For example I never name my primary keys as id.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
sort queryparams can be relationship fileds