I am creating a review system similar to the one mentioned here: http://drupal.org/node/457886.

While everything works... the vote averaging will not. I have tried multiple view configurations... and I keep getting the same error:

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.function AS votingapi_cache_node_node_percent_Location Rating_average_function ' at line 2 query: SELECT node.nid AS nid, votingapi_cache_node_node_percent_Location Rating_average.function AS votingapi_cache_node_node_percent_Location Rating_average_function FROM node node LEFT JOIN content_type_location_review node2 ON node.nid = node2.field_location_review_reference_nid INNER JOIN node node_node ON node2.nid = node_node.nid INNER JOIN votingapi_cache votingapi_cache_node_node_percent_Location Rating_average ON node_node.nid = votingapi_cache_node_node_percent_Location Rating_average.content_id AND (votingapi_cache_node_node_percent_Location Rating_average.content_type = 'node' AND votingapi_cache_node_node_percent_Location Rating_average.value_type = 'percent' AND votingapi_cache_node_node_percent_Location Rating_average.tag = 'Location Rating' AND votingapi_cache_node_node_percent_Location Rating_average.function = 'average') WHERE node_node.nid in (267, 266) LIMIT 0, 10 in /home2/xxx/public_html/xxxx/sites/all/modules/views/includes/view.inc on line 755.

While I've tried many view types... arguments, relationships, value & function node fields, etc... I'm beginning to think it's an issue with VotingAPI and not Views. Anybody here have a little more insight than I do?

Here is my view:

$view = new view;
$view->name = 'Average_Places_Rating';
$view->description = 'The average rating for places.';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
  'nodereferer_referers' => array(
    'label' => 'Referencing Nodes',
    'required' => 1,
    'referrer_delta' => '-1',
    'referrer_field' => 'field_location_review_reference',
    'id' => 'nodereferer_referers',
    'table' => 'node',
    'field' => 'nodereferer_referers',
    'relationship' => 'none',
  ),
  'votingapi_cache' => array(
    'label' => 'Vote results',
    'required' => 1,
    'votingapi' => array(
      'value_type' => 'percent',
      'tag' => 'Location Rating',
      'function' => 'average',
    ),
    'id' => 'votingapi_cache',
    'table' => 'node',
    'field' => 'votingapi_cache',
    'relationship' => 'nodereferer_referers',
  ),
));
$handler->override_option('fields', array(
  'function' => array(
    'label' => 'Function',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'strip_tags' => 0,
      'html' => 0,
    ),
    'exclude' => 0,
    'id' => 'function',
    'table' => 'votingapi_cache',
    'field' => 'function',
    'relationship' => 'votingapi_cache',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('style_plugin', 'table');
$handler->override_option('style_options', array(
  'grouping' => '',
  'override' => 1,
  'sticky' => 0,
  'order' => 'asc',
  'columns' => array(
    'function' => 'function',
  ),
  'info' => array(
    'function' => array(
      'sortable' => 0,
      'separator' => '',
    ),
  ),
  'default' => '-1',
));

Comments

ctalley5’s picture

Project: Voting API » Views (for Drupal 7)
Version: 6.x-2.3 » 6.x-2.8
Component: Views Integration » Miscellaneous

Not getting much attention in Voting API... maybe that's a hint that it IS a Views issue?

dawehner’s picture

Project: Views (for Drupal 7) » Voting API
Version: 6.x-2.8 » 6.x-2.x-dev
Component: Miscellaneous » Views Integration

No it is not. Views does integrate into fivestar, as you know :)

ctalley5’s picture

After some trial and error... the error is being derived from the "Vote tag filter" for the relationship "Node: Vote Results".

The error disappears when left at No Filtering - the Vote averaging is still not working for me, but at least I've found the source of the error!

prabhakarsun’s picture

Did you get it solved? I am getting same problem...

ctalley5’s picture

no i never fixed it. i (unfortunately) had to go around the problem and use some php to display averages.

legolasbo’s picture

Status: Active » Closed (won't fix)

Drupal 6 is no longer supported. Closing old issues to clean up the issue queue.

Please reopen and update this issue if this is still an issue in the D7 or D8 version.