Currently, the fieldOrderBy() method in an EntityFieldQuery will exclude any results where the field value is NULL.
This was originally discussed as a bug report in #1611438: fieldOrderBy filters out results with empty field values.
It was determined that the exclusion of NULL fields was by design for performance reasons.
It would be nice if an EFQ that orders by fields didn't exclude Entities with empty field values, but it needs to be accomplished in a way that doesn't degrade performance.
Comments
Comment #1
chx commentedTo achieve this, you'd need to special case the query that doesn't join at all and use that for ordering. I do not see this as a core thing to do. I am not yet won't fixing it but I am close to that.
Comment #2
bxtaylor commentedIf you foresee this as never being added, I'm fine with closing as a won't fix.
I created this issue based on @berdir's suggestion in #1611438: fieldOrderBy filters out results with empty field values:
I thought it'd be better to close the above bug issue and open as a feature request. But again, if you don't think this is going to be addressed, then I'm all for a won't fix.
Comment #3
matt2000 commentedRelated issue with an idea of a feature to solve this: #1057110: There's no way to LEFT JOIN with an EntityFieldQuery.
Comment #4
chx commentedNope, that's not an issue to solve this, that's an issue you reopened but won't stay open for long. You can't do this on whenever you want because it'd be unbearable slow. This can only work if you don't join at all. Then you can do an order by but I am not sure how useful that is.
Comment #5
chx commented