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].)
This commit is contained in:
parent
da1ad5b9c1
commit
eaa07b1ccb
1 changed files with 3 additions and 2 deletions
|
@ -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})
|
||||
|
|
Loading…
Reference in a new issue