Match last name alone for two-field names in search autocomplete

https://forums.zotero.org/discussion/50073/
This commit is contained in:
Dan Stillman 2015-06-18 00:21:50 -04:00
parent be4d56e43b
commit dcd7de03b0

View file

@ -96,11 +96,11 @@ ZoteroAutoComplete.prototype.startSearch = function(searchString, searchParams,
if (searchParams.fieldMode == 2) {
var sql = "SELECT DISTINCT CASE fieldMode WHEN 1 THEN lastName "
+ "WHEN 0 THEN firstName || ' ' || lastName END AS val, NULL AS comment "
+ "FROM creators NATURAL JOIN creatorData WHERE CASE fieldMode "
+ "WHEN 1 THEN lastName "
+ "WHEN 0 THEN firstName || ' ' || lastName END "
+ "LIKE ? ";
var sqlParams = [searchString + '%'];
+ "FROM creators NATURAL JOIN creatorData "
+ "WHERE CASE fieldMode "
+ "WHEN 1 THEN lastName LIKE ? "
+ "WHEN 0 THEN (firstName || ' ' || lastName LIKE ?) OR (lastName LIKE ?) END "
var sqlParams = [searchString + '%', searchString + '%', searchString + '%'];
if (typeof searchParams.libraryID != 'undefined') {
sql += " AND libraryID=?";
sqlParams.push(searchParams.libraryID);