To reproduce:

Get a clean tracker view
Add the field: Node: Updated/commented date. Preview. Note that this works.
Edit the table style settings. Set the field to be sortable.

Preview. This error will show:



    * user warning: Unknown column 'node_comment_statistics.last_updated' in 'field list' query: SELECT COUNT(*) FROM (SELECT node.type AS node_type, node.title AS node_title, node.nid AS nid, users.name AS users_name, users.uid AS users_uid, node_comment_statistics.comment_count AS node_comment_statistics_comment_count, node_comment_statistics.last_comment_timestamp AS node_comment_statistics_last_comment_timestamp, history_user.timestamp AS history_user_timestamp, node.created AS node_created, node.changed AS node_changed, GREATEST(node.changed, node_comment_statistics.last_comment_timestamp) AS node_comment_statistics_last_updated, node_comment_statistics.last_updated AS node_comment_statistics_last_updated_1 FROM node node INNER JOIN users users ON node.uid = users.uid INNER JOIN node_comment_statistics node_comment_statistics ON node.nid = node_comment_statistics.nid LEFT JOIN history history_user ON node.nid = history_user.nid AND history_user.uid = 1 WHERE node.status <> 0 ) count_alias in /var/www/views3/sites/all/modules/views/plugins/views_plugin_pager.inc on line 141.
    * user warning: Unknown column 'node_comment_statistics.last_updated' in 'field list' query: SELECT node.type AS node_type, node.title AS node_title, node.nid AS nid, users.name AS users_name, users.uid AS users_uid, node_comment_statistics.comment_count AS node_comment_statistics_comment_count, node_comment_statistics.last_comment_timestamp AS node_comment_statistics_last_comment_timestamp, history_user.timestamp AS history_user_timestamp, node.created AS node_created, node.changed AS node_changed, GREATEST(node.changed, node_comment_statistics.last_comment_timestamp) AS node_comment_statistics_last_updated, node_comment_statistics.last_updated AS node_comment_statistics_last_updated_1 FROM node node INNER JOIN users users ON node.uid = users.uid INNER JOIN node_comment_statistics node_comment_statistics ON node.nid = node_comment_statistics.nid LEFT JOIN history history_user ON node.nid = history_user.nid AND history_user.uid = 1 WHERE node.status <> 0 ORDER BY node_comment_statistics_last_updated_1 ASC LIMIT 0, 25 in /var/www/views3/sites/all/modules/views/plugins/views_plugin_query_default.inc on line 1090.

Comments

dawehner’s picture

Status: Active » Needs review
StatusFileSize
new1.08 KB

easy one :)

merlinofchaos’s picture

This might be a more widespread problem than just this one. I believe the base problem is that, formerly, as long as the alias matched, the add_orderby just happened. However, with the GROUP BY stuff, it's actually checking the parameters of the field and if they do not match it creates a new field.

It may be that we just have to keep an eye out for other fields that are both click sortable and use formulas rather than dding fields and make sure they have click sorts.

dawehner’s picture

It's this the same case here: http://drupal.org/node/766992

guntherdevisch’s picture

Also worked for me!

Thanks,
Gunther

Balrog’s picture

Please see http://drupal.org/node/715740#comment-3373426 -- I'm sure this is not a proper fix, but it works for the time being.

merlinofchaos’s picture

I think this patch works better:

dawehner’s picture

The field have added itself already


    if ($this->style_plugin->uses_fields()) {
      $this->_build('field');
    }

    // Build our sort criteria if we were instructed to do so.
    if (!empty($this->build_sort)) {
      // Allow the style handler to deal with sorting.
      if ($this->style_plugin->build_sort()) {
        $this->_build('sort');
      }

Manual testing works fine.

* Removed the click_sort function in search score field handler.
* Updated based on the documentation of add_orderby

dawehner’s picture

Removed the search field score change.

merlinofchaos’s picture

Status: Needs review » Fixed

Committed to all branches.

merlinofchaos’s picture

Er, no. Not committed to 2.x.

dawehner’s picture

Status: Fixed » Needs review
StatusFileSize
new1.29 KB

To be sure that broken field handlers breaks the query on clicksort a check for the field_alias is added.

This allows to remove the special clicksort for field score again :)

dawehner’s picture

Rerole against the current CVS

merlinofchaos’s picture

Status: Needs review » Fixed

Committed to all branches.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

dgtlmoon’s picture

Status: Closed (fixed) » Needs review

I am still getting this error with views-3 for drupal 6.x

dawehner’s picture

Which version of 6.x-3.x do you use?

If it's the alpha please update to the dev version. This version is much more stable then the other versions.

dawehner’s picture

Status: Needs review » Postponed (maintainer needs more info)

needs review means that there is a patch.the error disappeared, that's all i can say for now. thanks!

michelle’s picture

I can't reproduce in the dev snapshot, either. I just set up a dev site because s/he reported this error again against Advanced Forum and it's working fine for me.

Michelle

esmerel’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)