Well : I setup a view with one argument (I have tried either with vocabulary term or node id).
If I select : default page not found, everything is ok
If I select : use empty text, I have the following 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 'LEFT JOIN i18n_node i18n ON node.nid = i18n.nid WHERE (i18n.language ='fr' OR i' at line 1 query: pager_query LEFT JOIN i18n_node i18n ON node.nid = i18n.nid WHERE (i18n.language ='fr' OR i18n.language ='' OR i18n.language IS NULL) in /opt/www/htdocs/Drupal2/includes/database.mysql.inc on line 173.

It seems that in the views_build_view the call to
$query = db_rewrite_sql($info['query'], 'node');
when $info['query] is empty, does not return an empyt query.

I have just added a test :
if ($info['query']) {
$query = db_rewrite_sql($info['query'], 'node');
}

Well I guess that this is really a db_rewrite_sql problem which should NOT return bad queries :)

Comments

mx16’s picture

Thanks, it realy helped! I had similar problem, except warnings were not shown when I was logged in as first (and only) user.

halfiranian’s picture

I have exactly the same problem as mx16 and goudal

I'm filtering a view (with organic groups) and when I ask it to use 'empty text' it gives the above SQL error.

It doesn't give the warnings when logged in as first user.

How exactly do you fix this?

Cheers

halfiranian’s picture

cheers, just changed this is views.module

will this be incorporated into the next release?

sun’s picture

Title: Mysql warning syntax error when argument missing and « Use empty text » selected » SQL error when "use empty text" selected

There's no patch that could be included in the next release yet.

abautu’s picture

StatusFileSize
new460 bytes

This is caused by using Use Empty text in an argument. Because of this happens, the $info['query'] is empty. Views does not test for it and simply calls the db_rewrite_sql functions which generates half a query. This happens only when you have modules that rewrite queries enabled (line i18n and node access control).

I attached a patched to fix this.

esmerel’s picture

Status: Active » Needs review

I doubt that any changes will get committed, but if they are, this is marked for review.

abautu’s picture

Status: Needs review » Fixed

Fixed by 1.7.

Status: Fixed » Closed (fixed)

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