From 8214d7ac60601aee27a4d5b59b1d3a8b18fb143e Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 16 Jun 2008 15:11:59 +0000 Subject: [PATCH] Fix tag autocomplete Also fixed to not display tags twice if both manual and automatic and to not display automatic tags if manual versions of the same tags are already linked to the current item --- components/zotero-autocomplete.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/zotero-autocomplete.js b/components/zotero-autocomplete.js index 1fdc691dd..3699708b9 100644 --- a/components/zotero-autocomplete.js +++ b/components/zotero-autocomplete.js @@ -134,21 +134,21 @@ ZoteroAutoComplete.prototype.startSearch = function(searchString, searchParam, break; case 'tag': - var sql = "SELECT name FROM tags WHERE name LIKE ?"; + var sql = "SELECT DISTINCT name FROM tags WHERE name LIKE ?"; var sqlParams = [searchString + '%']; if (extra){ - sql += " AND tagID NOT IN (SELECT tagID FROM itemTags WHERE " - + "itemID = ?)"; + sql += " AND name NOT IN (SELECT name FROM tags WHERE tagID IN (" + + "SELECT tagID FROM itemTags WHERE itemID = ?))"; sqlParams.push(extra); } + var results = this._zotero.DB.columnQuery(sql, sqlParams); if (results) { - var collation = Zotero.getLocaleCollation(); + var collation = this._zotero.getLocaleCollation(); results.sort(function(a, b) { return collation.compareString(1, a, b); }); } - break; case 'creator':