I'm using Drupal 5.7, i18n.module, and search_attachments.module version 5.x-3 (downloaded from the author's site). When I do a search from the "Files" tab of the search interface, I get an sql error that says:

user warning: Column 'nid' in field list is ambiguous query: SELECT nid FROM node n LEFT JOIN i18n_node i18n ON n.nid = i18n.nid WHERE (i18n.language ='en' OR i18n.language ='' OR i18n.language IS NULL) in /usr/www/users/pmontagu/beta/includes/database.mysql.inc on line 172.

This is because the sql should be "SELECT n.nid FROM node n ..." (using "SELECT nid FROM node n ..." is fine until db_rewrite_sql() actually adds to the query, for example with i18n which adds a JOIN for language-specificity.

This can be easily fixed: on line 391 of search_attachments.module, the code reads

  $allowed_node_ids_result = db_query(db_rewrite_sql("SELECT nid FROM {node} n"));

when it should read

  $allowed_node_ids_result = db_query(db_rewrite_sql("SELECT n.nid FROM {node} n"));

I've fixed and tested this on my own site. Patch attached, though it is extremely trivial :)

CommentFileSizeAuthor
search_attachment_sql_err.patch539 bytesbecw

Comments

markj’s picture

Bec,

Thanks a million for spotting that bug. A user testing 5.x-4-dev also reported SQL errors while using the i18n module. I'll fix it in the dev version tonight.

PS 5.x-4-dev has a lot of new features you might find useful so I suggest trying it out -- see http://interoperating.info/mark/node/74

Mark