From 96a95f0e1c7924acb7a2e27e1ad4a88f994fa43b Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 22 Oct 2007 23:39:01 +0000 Subject: [PATCH] Fix for Attachment File Type advanced search condition not finding any results for some types (e.g. "Image") --- chrome/content/zotero/xpcom/search.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/chrome/content/zotero/xpcom/search.js b/chrome/content/zotero/xpcom/search.js index e5610ea8e..bcfb11f3a 100644 --- a/chrome/content/zotero/xpcom/search.js +++ b/chrome/content/zotero/xpcom/search.js @@ -889,10 +889,22 @@ Zotero.Search.prototype._buildQuery = function(){ break; case 'fileTypeID': - condSQL += 'mimeType IN (SELECT mimeType FROM ' - + 'fileTypeMimeTypes WHERE fileTypeID IN (' - + 'SELECT fileTypeID FROM fileTypes WHERE '; - openParens = openParens + 2; + var ftSQL = 'SELECT mimeType FROM fileTypeMimeTypes ' + + 'WHERE fileTypeID IN (' + + 'SELECT fileTypeID FROM fileTypes WHERE ' + + 'fileTypeID=?)'; + var patterns = Zotero.DB.columnQuery(ftSQL, { int: condition.value }); + if (patterns) { + for each(str in patterns) { + condSQL += 'mimeType LIKE ? OR '; + condSQLParams.push(str + '%'); + } + condSQL = condSQL.substring(0, condSQL.length - 4); + } + else { + throw ("Invalid fileTypeID '" + condition.value + "' specified in search.js") + } + skipOperators = true; break; case 'tag':