diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 1557f5065e..35ef8c1f58 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -1967,7 +1967,7 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns): @classmethod def cleanup_tags(cls, tags): - tags = [x.strip() for x in tags if x.strip()] + tags = [x.strip().replace(',', ';') for x in tags if x.strip()] tags = [x.decode(preferred_encoding, 'replace') \ if isbytestring(x) else x for x in tags] tags = [u' '.join(x.split()) for x in tags] diff --git a/src/calibre/library/schema_upgrades.py b/src/calibre/library/schema_upgrades.py index 597cee8cfd..1483743e4a 100644 --- a/src/calibre/library/schema_upgrades.py +++ b/src/calibre/library/schema_upgrades.py @@ -427,7 +427,9 @@ class SchemaUpgrade(object): def upgrade_version_15(self): 'Remove commas from tags' - self.conn.execute("UPDATE tags SET name=REPLACE(name, ',', ';')") + self.conn.execute("UPDATE OR IGNORE tags SET name=REPLACE(name, ',', ';')") + self.conn.execute("UPDATE OR IGNORE tags SET name=REPLACE(name, ',', ';;')") + self.conn.execute("UPDATE OR IGNORE tags SET name=REPLACE(name, ',', '')") def upgrade_version_16(self): self.conn.executescript('''