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.
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
Nulls Last and Nulls First Parameters Sorting #769
base: master
Are you sure you want to change the base?
Nulls Last and Nulls First Parameters Sorting #769
Changes from 24 commits
d4ad40f
fcb2254
f3133d2
90e16c5
685c495
d6d4a65
cdb6468
945d165
f89631e
81e8c32
cce4a62
5730ae8
324a165
5f9d231
355b841
c8d69d6
be783d1
2920100
3e986ed
a72579c
bb02502
ee4328a
d41131d
9690176
93d520d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
If you split this condition into two the result now lacks prefix and will not work with nested models.
You would have in example
{prefix}{table_name}.{field_name} is null, {field_name} {self.direction}
.The second field_name does not have the prefix.
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.
Of course, I must mention that without this case, the test related to nested models will also pass correctly. Can you give an example of a possible error that may occur? Thanks
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.
When you have a parent model with two relations to the child model. So like items with
created_by
andmodified_by
that lead to the sameUser
model. Each of those relations in joins has to have different prefixes as otherwise, you would have ambiguous column names.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.
You should also be able to pass this param in
order_by
in queryset and querysetproxy for related models.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 do not understand this
How to determine this amount in
order_by()
and withoutasc()
ordesc()
?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.
In order by you can pass OrderActions or strings too. If you pass
sort_order
it's ascending, if you pass-sort_order
it's descending. For nested models double underscore is required so likemain_model_relation_field__child_model_field
. It also supports putting a-
before nested related model fields and then it's descending. The logic is starting in order_by where OrderActions are created from strings.