don't allow tags of different cases

Previously they were allowed to be added, but all searches and
operations treated them as case-sensitive, creating an inconsistency.
The new implementation will change new tags with different case than
existing ones to the version currently in the database.

This may cause some slowdown in collections with a very large number of
tags since the only way to do this at the moment is to scan through
every one of them. Changing the format tags are stored in in the future
may be useful.
This commit is contained in:
Soren I. Bjornstad 2014-07-27 17:55:11 -05:00
parent 04966d42b6
commit b1e361bb32

View file

@ -37,8 +37,6 @@ class TagManager(object):
def register(self, tags, usn=None):
"Given a list of tags, add any missing ones to tag registry."
# case is stored as received, so user can create different case
# versions of the same tag if they ignore the qt autocomplete.
found = False
for t in tags:
if t not in self.tags:
@ -145,8 +143,14 @@ class TagManager(object):
##########################################################################
def canonify(self, tagList):
"Strip duplicates and sort."
strippedTags = [re.sub("[\"']", "", x) for x in tagList]
"Strip duplicates, adjust case to match existing tags, and sort."
strippedTags = []
for t in tagList:
s = re.sub("[\"']", "", t)
for existingTag in self.tags:
if s.lower() == existingTag.lower():
s = existingTag
strippedTags.append(s)
return sorted(set(strippedTags))
def inList(self, tag, tags):