Fixes #1393, "Error when adding existing tag beginning with certain extended characters to an item", but not properly

SQLite's COLLATE NOCASE doesn't work for Unicode characters, so it won't find existing tag "Äbc" if "äbc" is entered and will allow a duplicate tag to be created
This commit is contained in:
Dan Stillman 2009-03-14 21:48:47 +00:00
parent 7107be3cdd
commit d904470200

View file

@ -74,12 +74,16 @@ Zotero.Tags = new function() {
* Returns the tagID matching given tag and type
*/
function getID(name, type) {
name = Zotero.Utilities.prototype.trim(name).toLowerCase();
name = Zotero.Utilities.prototype.trim(name);
var lcname = name.toLowerCase();
if (_tags[type] && _tags[type]['_' + name]) {
return _tags[type]['_' + name];
if (_tags[type] && _tags[type]['_' + lcname]) {
return _tags[type]['_' + lcname];
}
// FIXME: COLLATE NOCASE doesn't work for Unicode characters, so this
// won't find Äbc if "äbc" is entered and will allow a duplicate tag
// to be created
var sql = 'SELECT tagID FROM tags WHERE name=? AND type=?';
var tagID = Zotero.DB.valueQuery(sql, [name, type]);
@ -87,7 +91,7 @@ Zotero.Tags = new function() {
if (!_tags[type]) {
_tags[type] = [];
}
_tags[type]['_' + name] = tagID;
_tags[type]['_' + lcname] = tagID;
}
return tagID;