Description of issue

When configuring sort options for a view, i want expose some fields that do not sort granularly -- for example boolean flags like published or promoted.
So, I also need to add an additional sort option, which is not exposed, to implement a "fallback" sort.
In essence, what I need is something like:
"select * from node order by status DESC, created ASC"

Problem

In the example above, the fallback sort is on node.created.
However, if an additional node.created is added as exposed sort, the fallback overrides it and the exposed is ignored.

Suggested Resolution

Exposed sort, if its field conflicts with any non-exposed sort, should override the non-exposed sort.

Comments

aaronbauman’s picture

Project: Views (for Drupal 7) » Search API
Version: 7.x-3.x-dev » 7.x-1.x-dev
Component: exposed filters » Views integration
Status: Active » Needs review
StatusFileSize
new743 bytes

I ran into this error specifically with search_api_views
Don't know if it's also a problem with views core or not.

The attach patch ensures that, if there are multiple sorts configured for the same field, the former-most will take precedence.

drunken monkey’s picture

Project: Search API » Views (for Drupal 7)
Version: 7.x-1.x-dev » 7.x-3.x-dev
Component: Views integration » Code
Status: Needs review » Active

Thanks for reporting this, and sorry I apparently completely overlooked it until now.
I just tested, and it doesn't work with normal Views (e.g., on Content), either. So I guess this should be fixed in Views, or in both (if we have to fix it in the sort handler).
Thanks a lot for your patch, though, it works perfectly! I've now committed it as a (hopefully temporary) workaround.