Had a need for this and thought the community could benefit from it.
Attached is a patch that allows NULL or empty strings to be ordered last in a sort handler instead of at the top as seems to be the default with most databases.
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | views-empty-order-last-1.patch | 1.74 KB | cdale |
| views-empty-order-last.patch | 1.67 KB | cdale |
Comments
Comment #1
cdale commentedOops, small touch up. Forgot that table alias could be empty.
Comment #2
merlinofchaos commentedI think this would kill performance as sorting on the formula like that means indexes would no longer be used. =(
Comment #3
JamieR commentedIs there anything else that can be done in regards to this issue. It's not allowing me to create product views based on popularity or rating because the products that have null values appear before the most popular and highest rated nodes. I'd settle for the null values to just be treated as zero. My search in the issue que didn't bring anything up... so I'm wondering if this behavior is just specific to postgreSQL.
Thanks, Jamie.
Comment #4
Equ commentedSorry for commenting on this, but is there any way to solve this problem without a patch? Thank you.
Comment #5
Equ commentedHere is how I've solved this in case if someone else needs it. That was really easy and doesn't affect the performance.