When subqueries have a sort, they can fail because the column they are sorting on is not aliased as expected by the ORDER term.
For example in this query:
SELECT node.nid, node.created AS node_created_created FROM node node LEFT JOIN nodequeue_nodes nodequeue_nodes ON node.nid = nodequeue_nodes.nid WHERE (nodequeue_nodes.qid IN ('7')) AND (node.status = '1') ORDER BY nodequeue_nodes_position DESC
The column nodequeue.nodes_position was aliased as nodequeue_nodes_position in the original query (before it is mangled by views_union), but this alias is not available in the final query, and this causes an SQL error (and zero results). We can't simply leave in the original columns as proposed in the http://drupal.org/node/182968 patch, because each view may not have different fields, and so cannot be UNIONed (unless we we add dummy fields to ensure each subquery matches every other, which would be quite complex and fragile, or require everyone to figure out how which fields they need to add to the master query to make things work, which is very unfriendly!).
The attached patch takes the simple (but effective!) route of removing the sort orders from all subqueries. These don't really add anything to the feature set (if you simply want to have a bunch of views stacked in their original order you can do that easier with a 1-column panel), and prevents things breaking as demonstrated above.
I originally did this as an (ugly) string mangling on the generated query, but then moved to the above approach, which I think is neater, although it adds a little more work for views (since we need to disable views caching for subqueries).
| Comment | File | Size | Author |
|---|---|---|---|
| nosort.patch | 911 bytes | owen barton |