From df7838ee1dcf086522780d1c44cadfa979261552 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Fri, 11 Sep 2015 12:11:16 +0100 Subject: [PATCH 2/2] ClipManager: match annotation layer case-sensitively (fixes #2832) The case must be correct anyway for the layer to be found in settings.CONFIG['layers']. Running this: Q(annotation__layer__iexact='foo') & Q(annotation__findvalue__icontains='bar') compiles to upper(layer) = upper('foo') and ... which can't use the case-sensitive annotation_annotation_layer index. This: Q(annotation__layer__exact='foo') & Q(annotation__findvalue__icontains='bar') can. (It still can't use the findvalue_like index, though! The other option is to add indices on upper(layer) and upper(findvalue) [varchar_pattern_ops].) --- pandora/clip/managers.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandora/clip/managers.py b/pandora/clip/managers.py index f4a09f7..65ff43b 100644 --- a/pandora/clip/managers.py +++ b/pandora/clip/managers.py @@ -44,7 +44,7 @@ def parseCondition(condition, user): 'operator': op}, user) \ & parseCondition({'key': 'annotations__layer', 'value': k, - 'operator': '=='}, user) + 'operator': '==='}, user) if op.startswith('!'): op = op[1:] @@ -82,6 +82,7 @@ def parseCondition(condition, user): '>=': '__gte', '<': '__lt', '<=': '__lte', + '===': '__exact', '==': '__iexact', '=': '__icontains', '^': '__istartswith', @@ -89,7 +90,7 @@ def parseCondition(condition, user): }.get(op, '__icontains')) key = str(key) - if isinstance(v, unicode): + if isinstance(v, unicode) and op != '===': v = unicodedata.normalize('NFKD', v).lower() if exclude: q = ~Q(**{key: v}) -- 2.4.3