I'm using the latest CVS version from the repository and have done my best to update mysql, recently adding the guid field because lack of this was causing an error. However, whenever I try to manually refresh a feed I receive this error:

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 '0 = '

I have no idea what the cause is. Has anyone else had this problem?

Comments

ahwayakchih’s picture

Can You post whole sql query which errors out?
Also be sure to check if feed node is setup properly (go and edit feed node and see if all fields are filled as they should).

alaa’s picture

I get the same error with a variety of feeds, yet ot find the time to investigate and isolate the condition that triggers this error, but here is a sample while refreshing the feed @ http://www.manalaa.net/rss.xml

user error: 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 '0 = '' WHERE nid = '663'' at line 1
query: UPDATE node SET nid = '663', type = 'aggregator2-feed', title = 'manalaa.net', uid = '1', status = '1', created = '1131509792', changed = '1132523899', comment = '0', promote = '0', moderate = '0', teaser = '<p>Welcome to Manal And Alaa\'s space, where we record our thoughts and feelings, keep in touch with friends and upload the occasional file.</p><p>we also offer <a href=\"http://drupal.org\">drupal</a> based <a href=\"http://www.manalaa.net/free_drupal_hosting_promo\">free hosting space</a> and free aid in developing a website for any cause we find worthy or interesting and for any speech that is censored or prosecuted in Egypt.</p><p>we put very few <a href=\"image\">photos</a> here, you can find all out photos and more on our <a h in /var/vhosts/manalaa.net/www/includes/database.mysql.inc on line 66.

as you can the error message shows a truncated query, any suggestions on how I can see the full query?

jasonwhat’s picture

I definitely have everything set up correctly. I'm not sure what you mean by the full sql query. The error I showed is the complete error whenever I do a manual refresh.

jasonwhat’s picture

I don't know if this will help any, but I don't see any feed items on the aggregator2 feeds actual page. I thought I read in the change log or somewhere that the actual items are supposed to be listed on the feed node types page rather than just statistics for the feed like how many published items are in the feed. If this is correct, maybe I'm missing something in my version, though I got it from cvs.

ahwayakchih’s picture

By "full SQL query" i mean whole query, the one You posted is kinda cutted (or am i missing something?).

For now there's only special sources/[feed_id] page on which there are items. You should see "view items" link with each feed.

jasonwhat’s picture

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 '0 = '\"0\"

I bolded the part that was cutting off. It is in a text box when I vew the error which is weird. I don't really know about that. As for my links I only have source site, refresh items, and remove items as links. No link to view the items. I'm not sure what I'm missing.

ahwayakchih’s picture

The "0 = 0" in SQL happened to me few times long time ago. Not it's not there, and i never really found out why it happened.
It was reported by other people too, but nothing specific. Just that error shows up.
BUT similar thing happened when data in database was "screwed". For example when one there was a bug in aggregator2 because of which feed was loosing URL field.
So please check if feed is all ok. Maybe also backupd database and, for testing, remove all items from feed and then refresh it again. If error disappears we'll know it's because of some data missing (it may happen also when cron run is quit before it finishes, for example because of taking too much time and hitting timelimit).

alaa’s picture

this has nothing to do with database being screwed up or cron not running properly, I get this error when aggregating from a drupal rss feed try (http://www.manalaa.net/rss.xml) even on a new empty installation, it occurs on every update not just occasionaly.

it aggregates feed items with no trouble, but it fails to grab the feed description.

ahwayakchih’s picture

* Parsing feed Test took 0.02741003036499 seconds.
* Created new term a7a department.
* Created new term عربي.
* Created new term announecments and statements.
* Created new term Egypt.
* Created new term politics.
* Created new term Web.
* Created new term english.
* Created new term Culture.
* Created new term مجمع المدونات المصرية.
* Syndicated content from Test.

No errors, nothing. So it must be something about environment. Maybe some other module? What modules do You use on site?

ahwayakchih’s picture

it aggregates feed items with no trouble, but it fails to grab the feed description.

Some time ago i added the same handling way for descripton as it is for image link. Description is updated only if it's empty in node. So to update it You should first edit feed and remove all content form "body"/"description" field.

alaa’s picture

I've no idea if this is somehow specific to my installation but I did some tests to find out what is going on exactly with that sql error.

I found out that the error came from a query in the function node_save after being called inside aggregator2_refresh.

by debugging node_save I found out that in the part

    foreach ($node as $key => $value) {
      if ( in_array($key, $fields)) {
        $q[] = db_escape_string($key) ." = '%s'";
        $v[] = $value;
      }
    }

at some point $key takes the value '0' and the in_array() test returns true with key value 0. according to a comment in php manual and some tests I did, in_array(0,array("any string",...)) will always return true. so the update sql statement ends with a 0=%s where nid=some_nid

which is the sql syntax error, changing the if (in_array line to if($key && in_array($key, fields)) or adding a stict type checking requirement to in_array solves the problem.

now is my analysis correct? is this in fact a bug in node.module?

alaa’s picture

the in_array error was reported @ http://drupal.org/node/32361 and a patch submitted