-
-
Notifications
You must be signed in to change notification settings - Fork 918
Add nulls_always_first and nulls_always_last to nulls_comparison #4103
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 nulls_always_first and nulls_always_last to nulls_comparison #4103
Conversation
Pinging the maintainers as described in Notes:
I am actually using this functionality in a "real-world" project (https://github.com/mangelio/web/), so in my opinion, there exists an actual use case. Thanks for considering to integrate it into the |
if (\in_array($nullsComparison, [self::NULLS_ALWAYS_FIRST, self::NULLS_ALWAYS_LAST], true)) { | ||
$nullsDirection = self::NULLS_ALWAYS_FIRST === $nullsComparison ? 'ASC' : 'DESC'; | ||
} else { | ||
$nullsDirection = self::NULLS_DIRECTION_MAP[$nullsComparison][$direction]; | ||
} |
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 think it would be simpler if you reused the direction map instead (clearer and no need to add specific code).
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.
Done 👍🏻
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.
Do you want to try to fix the MongoDB tests too?
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 seem to have succeeded. See comment below.
Hello, thank you for this PR! |
Rebased to show the MongoDB issue. |
The MongoDB tests are also passing now. I have to be honest: I am not sure I understood the MongoDB tests specification 100%. Could you please quickly glance over it for a plausibility check? |
Nice work! Thank you @famoser. |
Add
nulls_always_first
andnulls_always_last
tonulls_comparison
of theOrderFilter
. This allows to always sort innull
values first or last, independent of the current order.This is useful for UIs with optional fields; displaying empty fields might not be useful to the user. Sorting these always last, independent of the chosen ordering, is the expected behavior.
Given something like
will result in an ordering like