From 61fc7b4430a5d0ecfd9a6ca82b13291206d76d98 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 25 Apr 2009 03:04:52 +0900 Subject: [PATCH] lower tags in python, as sqlite doesn't have full unicode tables --- anki/tags.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/anki/tags.py b/anki/tags.py index dd72c7d91..aa68b6766 100644 --- a/anki/tags.py +++ b/anki/tags.py @@ -51,10 +51,8 @@ def tagIds(s, tags): ids = {} s.statements("insert or ignore into tags (tag) values (:tag)", [{'tag': t} for t in tags]) - tagsD = dict(s.all(""" -select lower(tag), id from tags + tagsD = dict([(x.lower(), y) for (x, y) in s.all(""" +select tag, id from tags where tag in (%s)""" % ",".join([ - "'%s'" % t.replace("'", "''") for t in tags]))) - for tag in tags: - ids[tag.lower()] = tagsD[tag.lower()] - return ids + "'%s'" % t.replace("'", "''") for t in tags]))]) + return tagsD