After trying the new release on my localhost (apache2triad), the update went smoothly. So I did the same on my production site, but since the I keep getting this (drupal)message:
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 'DISTINCT(node.nid) AS num_records FROM node node LEFT JOIN content_type_docen' at line 2 query: SELECT node_data_field_mentor.field_mentor_value AS node_data_field_mentor_field_mentor_value, DISTINCT(node.nid) AS num_records FROM node node LEFT JOIN content_type_docent node_data_field_mentor ON node.vid = node_data_field_mentor.vid WHERE (node.type in ('docent')) AND (node_data_field_mentor.field_mentor_value IS NOT NULL) GROUP BY node_data_field_mentor_field_mentor_value ORDER BY node_data_field_mentor_field_mentor_value ASC LIMIT 0, 100 in /var/www/vhosts/reviusplein.nl/httpdocs/sites/all/modules/views/includes/view.inc on line 731.

I've tried reinstalling a backup (to reconvert to 2.2). I flushed all cashes, reuploaded views 2.2 several times. But this message keeps on appearing.

This message appears in a view that has 3 tabs. The first default tab gets displayed normally, but the other 2 don't while the above message appears.

I am don't know very much of coding my SQL, so I hope anyone knows what this might be..

Comments

bobgeier’s picture

I had a bunch of issues with 2.3 and had to back down to 2.2 as well, with similar error sets. These are generally popping up when there's incomplete data in the nodes referenced for the view, or if a node is missing.

For your production site, in addition to restoring Views 2.2, I think you'll need to restore your database from backup. 2.3 seems to add some additional DB stuff which sticks around even if you replace the module.

merlinofchaos’s picture

Status: Active » Postponed (maintainer needs more info)

Hmm. That query looks like a summary query and the COUNT is somehow getting messed up. Can you export the view that creates that query?

R.Hendel’s picture

Hello,
we have also an sql-error.
It happens when using autocomplete and exposed filters, when you submit the form with using an incomplete UserName.
By using an autocompleted filtering-option everything works fine.

We have detected two details:

  • Sql-error-messages will not displayed in Firefox. Only Safari, Opera and IE are displaying that error message.
  • We could reproduce this behaviour on them same installation using a minimal-view with only one exposed filter (author) and table design with two columns (node-tiitle + author) but not on another similar drupal

Here is exported minimal view:

$view = new view;
$view->name = 'test';
$view->description = 'test';
$view->tag = 'test';
$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', 'Standards', 'default');
$handler->override_option('fields', array(
  'title' => array(
    'label' => '',
    '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,
    ),
    'link_to_node' => 0,
    'exclude' => 0,
    'id' => 'title',
    'table' => 'node',
    'field' => 'title',
    'relationship' => 'none',
  ),
  'name' => array(
    'label' => '',
    '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,
    ),
    'link_to_user' => 1,
    'overwrite_anonymous' => 0,
    'anonymous_text' => '',
    'exclude' => 0,
    'id' => 'name',
    'table' => 'users',
    'field' => 'name',
    'relationship' => 'none',
  ),
));
$handler->override_option('filters', array(
  'uid' => array(
    'operator' => 'in',
    'value' => '',
    'group' => '0',
    'exposed' => TRUE,
    'expose' => array(
      'use_operator' => 0,
      'operator' => 'uid_op',
      'identifier' => 'uid',
      'label' => 'Autor',
      'optional' => 1,
      'remember' => 0,
      'reduce' => 0,
    ),
    'id' => 'uid',
    'table' => 'users',
    'field' => 'uid',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('style_plugin', 'table');
$handler = $view->new_display('page', 'Seite', 'page_1');
$handler->override_option('path', 'test');
$handler->override_option('menu', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
  'name' => 'navigation',
));
$handler->override_option('tab_options', array(
  'type' => 'none',
  'title' => '',
  'description' => '',
  'weight' => 0,
));
dawehner’s picture

don't hijack issues.

Additional what is the error message...

R.Hendel’s picture

Sorry, I didn't want to misplace a different issue for my own - thought, it were the same topic.

That warnings appear by filtering with an imcomplete user like "r":

•Benutzer konnte nicht gefunden werden: r
•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 'INNER JOIN node_access na ON na.nid = node.nid WHERE (na.grant_view >= 1 AND ((n' at line 1 query: SELECT COUNT(*) FROM ( INNER JOIN node_access na ON na.nid = node.nid WHERE (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all') OR (na.gid = 0 AND na.realm = 'content_access_author') OR (na.gid = 1 AND na.realm = 'content_access_rid') OR (na.gid = 0 AND na.realm = 'og_public')))) count_alias in /ADDSYS/DATABASES/example.com/htdocs/sites/all/modules/views/includes/view.inc on line 729.
•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 'INNER JOIN node_access na ON na.nid = node.nid WHERE (na.grant_view >= 1 AND ((n' at line 1 query: INNER JOIN node_access na ON na.nid = node.nid WHERE (na.grant_view >= 1 AND ((na.gid = 0 AND na.realm = 'all') OR (na.gid = 0 AND na.realm = 'content_access_author') OR (na.gid = 1 AND na.realm = 'content_access_rid') OR (na.gid = 0 AND na.realm = 'og_public'))) LIMIT 0, 25 in /ADDSYS/DATABASES/example.com/htdocs/sites/all/modules/views/includes/view.inc on line 755.
esmerel’s picture

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

This is against an older version; if this is still a problem, please open/reopen against the latest version.

Peter Swietoslawski’s picture

This is still an issue. The simple way to recreate SQL error is to expose User filter as autocomplete widget, type nonexistent user name and hit Apply button.

Autocomplete fieldset for User will set form error if user does not exist. This results in aborting query assembling in built method of view class and cause build_info['query'] to be empty string.

    if ($this->display_handler->uses_exposed()) {
      $this->exposed_widgets = $this->render_exposed_form();
      if (form_set_error() || !empty($this->build_info['abort'])) {
        $this->built = TRUE;
        return empty($this->build_info['fail']);
      }
    }
    ......
    // This code is never reached
    $this->build_info['query'] = $this->query->query();
    $this->build_info['count_query'] = $this->query->query(TRUE);

Later on when execute method is invoked build_info['query'] is empty and as such is passed to db_rewrite_sql for rewriting. There wouldn't be anything wrong with this if not the fact that db_rewrite_sql does not validate passed query and allows other modules to modify it by running hook_db_rewrite_sql. Here is where node.module adds JOIN clause for users without administer nodes permission so the query starts from INNER JOIN rather than SELECT clause.

Below is a patch fixing this.

Peter Swietoslawski’s picture

Version: 6.x-2.3 » 6.x-2.x-dev
Status: Closed (fixed) » Needs review
StatusFileSize
new1.13 KB
dawehner’s picture

There is a need for

1) codestyle issues
2) a 3.x version of a patch.

dawehner’s picture

Status: Needs review » Needs work

Update status

esmerel’s picture

Status: Needs work » Closed (won't fix)

no updates for more than 3 months

nymo’s picture

Version: 6.x-2.x-dev » 6.x-2.11
Status: Closed (won't fix) » Needs review
StatusFileSize
new1.04 KB

Don't have a patch for 3.x but here's the patch from #8 that follows the coding standards.

dawehner’s picture

Status: Needs review » Closed (won't fix)

This bug is already fixed in 6.x-3.x and will not be committed to 6.x-2.x, because it's in a only-critical-bugs mode, sorry.