From 4fe960d190f54b86eaf6a80d8a9e20c40e1cb2a2 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 10 Aug 2006 04:32:36 +0000 Subject: [PATCH] Search updates: - Remaining searchConditionIDs are no longer affected by removeCondition() (i.e. they now act like autoincrements), which should make interface code simpler - Changed default join mode to ALL - Fixed loading of saved searches with no search conditions --- .../content/scholar/xpcom/search.js | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/xpcom/search.js b/chrome/chromeFiles/content/scholar/xpcom/search.js index fb76d3140..7424c8080 100644 --- a/chrome/chromeFiles/content/scholar/xpcom/search.js +++ b/chrome/chromeFiles/content/scholar/xpcom/search.js @@ -27,8 +27,9 @@ Scholar.Search.prototype.setName = function(name){ */ Scholar.Search.prototype.load = function(savedSearchID){ var sql = "SELECT savedSearchName, MAX(searchConditionID) AS maxID " - + "FROM savedSearches NATURAL JOIN savedSearchConditions " - + "WHERE savedSearchID=" + savedSearchID + " GROUP BY savedSearchID"; + + "FROM savedSearches LEFT JOIN savedSearchConditions " + + "USING (savedSearchID) WHERE savedSearchID=" + savedSearchID + + " GROUP BY savedSearchID"; var row = Scholar.DB.rowQuery(sql); if (!row){ @@ -151,16 +152,6 @@ Scholar.Search.prototype.removeCondition = function(searchConditionID){ } delete this._conditions[searchConditionID]; - - var i = searchConditionID + 1; - while (typeof this._conditions[i] != 'undefined'){ - this._conditions[i-1] = this._conditions[i]; - this._conditions[i-1]['id']--; - delete this._conditions[i]; - i++; - } - - this._maxSearchConditionID--; } @@ -264,12 +255,13 @@ Scholar.Search.prototype._buildQuery = function(){ sql += " WHERE "; // Join conditions using appropriate operator - if (joinMode=='ALL'){ - var binOp = ' AND '; - } - else { + if (joinMode=='ANY'){ var binOp = ' OR '; } + // Default to AND + else { + var binOp = ' AND '; + } for (i in tables){ for (var j in tables[i]){