diff options
| author | Ian Foote <python@ian.feete.org> | 2015-11-07 16:06:06 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-12-17 19:08:30 -0500 |
| commit | 86eccdc8b67728d84440a46e5bf62c78f2eddf6d (patch) | |
| tree | 6433cbf59d1f4a5ae9aa6b5b5809ee933bac7f65 /django/contrib/postgres/fields/array.py | |
| parent | ed1bcf05158acf4bf4e0189d477b6c762bd0133e (diff) | |
| download | django-86eccdc8b67728d84440a46e5bf62c78f2eddf6d.tar.gz | |
Fixed #25544 -- Removed duplicate ids in prefetch_related() queries.
Diffstat (limited to 'django/contrib/postgres/fields/array.py')
| -rw-r--r-- | django/contrib/postgres/fields/array.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/django/contrib/postgres/fields/array.py b/django/contrib/postgres/fields/array.py index 65f28672aa..9a1e3c286b 100644 --- a/django/contrib/postgres/fields/array.py +++ b/django/contrib/postgres/fields/array.py @@ -5,7 +5,7 @@ from django.contrib.postgres.forms import SimpleArrayField from django.contrib.postgres.validators import ArrayMaxLengthValidator from django.core import checks, exceptions from django.db.models import Field, IntegerField, Transform -from django.db.models.lookups import Exact +from django.db.models.lookups import Exact, In from django.utils import six from django.utils.translation import string_concat, ugettext_lazy as _ @@ -217,6 +217,15 @@ class ArrayLenTransform(Transform): ) % {'lhs': lhs}, params +@ArrayField.register_lookup +class ArrayInLookup(In): + def get_prep_lookup(self): + values = super(ArrayInLookup, self).get_prep_lookup() + # In.process_rhs() expects values to be hashable, so convert lists + # to tuples. + return [tuple(value) for value in values] + + class IndexTransform(Transform): def __init__(self, index, base_field, *args, **kwargs): |
