Move Utilities.Internal.escapeSQLExpression() to Zotero.DB
This commit is contained in:
parent
28aa86eb79
commit
bf6f1432c5
3 changed files with 10 additions and 10 deletions
|
@ -1090,6 +1090,15 @@ Zotero.DBConnection.prototype.backupDatabase = Zotero.Promise.coroutine(function
|
|||
});
|
||||
|
||||
|
||||
/**
|
||||
* Escape '_', '%', and '\' in an SQL LIKE expression so that it can be used with ESCAPE '\' to
|
||||
* prevent the wildcards from having special meaning
|
||||
*/
|
||||
Zotero.DBConnection.prototype.escapeSQLExpression = function (expr) {
|
||||
return expr.replace(/([_%\\])/g, '\\$1');
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Private methods
|
||||
|
|
|
@ -1164,15 +1164,6 @@ Zotero.Utilities.Internal = {
|
|||
},
|
||||
|
||||
|
||||
/**
|
||||
* Escape '_', '%', and '\' in an SQL LIKE expression so that it can be used with ESCAPE '\' to
|
||||
* prevent the wildcards from having special meaning
|
||||
*/
|
||||
escapeSQLExpression: function (expr) {
|
||||
return expr.replace(/([_%\\])/g, '\\$1');
|
||||
},
|
||||
|
||||
|
||||
buildLibraryMenu: function (menulist, libraries, selectedLibraryID) {
|
||||
var menupopup = menulist.firstChild;
|
||||
while (menupopup.hasChildNodes()) {
|
||||
|
|
|
@ -72,7 +72,7 @@ ZoteroAutoComplete.prototype.startSearch = Zotero.Promise.coroutine(function* (s
|
|||
|
||||
case 'tag':
|
||||
var sql = "SELECT DISTINCT name AS val, NULL AS comment FROM tags WHERE name LIKE ? ESCAPE '\\'";
|
||||
var sqlParams = [Zotero.Utilities.Internal.escapeSQLExpression(searchString) + '%'];
|
||||
var sqlParams = [Zotero.DB.escapeSQLExpression(searchString) + '%'];
|
||||
if (searchParams.libraryID !== undefined) {
|
||||
sql += " AND tagID IN (SELECT tagID FROM itemTags JOIN items USING (itemID) "
|
||||
+ "WHERE libraryID=?)";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue