I'm trying to make a View using Views Alpha Pager which will allow me to list all terms in an alpha pager. I'm using Term Name as an argument...

This is the error:

user warning: Unknown column 'term_data_name' in 'group statement' query: SELECT DISTINCT LEFT(UPPER(term_data.weight), 1) FROM node node LEFT JOIN term_node term_node ON node.nid = term_node.nid LEFT JOIN term_data term_data ON term_node.tid = term_data.tid WHERE (node.status = '1') AND (node.type IN ('course')) AND (term_data.name IS NOT NULL) GROUP BY term_data.name, term_data_name ORDER BY LEFT(UPPER(term_data.weight), 1) in /var/www/html/[removed]/drupal-5.1/includes/database.mysql.inc on line 172.

I dont THINK I've misconfigured the View... On examining the SQL above, it looks like its formed incorrectly. Why would it need the leftmost uppercase character of the term weight?!

The actual error is, as the title says, due to it using "term_data_name" instead of "term_data.name".

Any thoughts?

Comments

nicholasthompson’s picture

Hmm.. looks like this might be the cause of the use of the "weight" field...

if (!isset($sort_field) && isset($view->sort['0']['field'])) {
  $sort_field = $view->sort['0']['field'];
}
...
...
$myfield = 'UPPER('. $sort_field .')';

When using term_data.name as a sort field, it seems to get sorted by weight (according to the view)?!

nicholasthompson’s picture

This error dissapears if I go from Views release 1.6beta5 to HEAD. I will continue to investigate...

nicholasthompson’s picture

This is my view, exported... No luck. I had to revert from HEAD back to 1.6-beta5 as HEAD had some very strange errors...

  $view = new stdClass();
  $view->name = 'a2z';
  $view->description = 'A to Z - Filter by category';
  $view->access = array (
);
  $view->view_args_php = '';
  $view->page = TRUE;
  $view->page_title = 'A To Z';
  $view->page_header = '';
  $view->page_header_format = '1';
  $view->page_footer = '';
  $view->page_footer_format = '1';
  $view->page_empty = '';
  $view->page_empty_format = '1';
  $view->page_type = 'list';
  $view->url = 'a-to-z';
  $view->use_pager = TRUE;
  $view->nodes_per_page = '100';
  $view->sort = array (
    array (
      'tablename' => 'term_data',
      'field' => 'weight',
      'sortorder' => 'ASC',
      'options' => '',
    ),
  );
  $view->argument = array (
    array (
      'type' => 'taxletter',
      'argdefault' => '4',
      'title' => '',
      'options' => '',
      'wildcard' => '',
      'wildcard_substitution' => '',
    ),
  );
  $view->field = array (
    array (
      'tablename' => 'node',
      'field' => 'title',
      'label' => 'Title',
      'handler' => 'views_handler_field_nodelink',
      'options' => 'link',
    ),
  );
  $view->filter = array (
    array (
      'tablename' => 'node',
      'field' => 'status',
      'operator' => '=',
      'options' => '',
      'value' => '1',
    ),
    array (
      'tablename' => 'node',
      'field' => 'type',
      'operator' => 'OR',
      'options' => '',
      'value' => array (
  0 => 'course',
),
    ),
  );
  $view->exposed_filter = array (
  );
  $view->requires = array(term_data, node);
  $views[$view->name] = $view;
douggreen’s picture

VAP does rewrite SQL (using views_query_alter), but it shouldn't be rewriting anything in the GROUP BY clause. First make sure that you get don't get the error when VAP is not selected. If it is isolated to VAP, I'd try to debug VAP hook_views_query_alter, by putting print $query->query() at various points in the function to see which statement is altering it improperly.

Do you have a sort column defined? VAP displays an error if one isn't defined, and since you didn't mention it, I suspect that you do.

nicholasthompson’s picture

The view worked fine when set to normal paging and I do have a sort column defined (Term Name).

Unfortunately I'm on a deadline so cant really dedicate anymore time to this - but I think part of the problem is that way VAP handles the sort column for Term Name...

douggreen’s picture

Status: Active » Closed (fixed)

@nicholasThompson, since I was never able to reproduce this, and since I think you moved on, I'm closing the issue. Please re-open it if you still have the problem and can work with me on a test case. Thanks!