diff options
author | Ben Cail <bcail@crossway.org> | 2022-10-26 09:58:08 -0400 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-11-18 05:53:37 +0100 |
commit | fbde929b19754f19cba1d14e86f4c59f4b0a633c (patch) | |
tree | 9263b3d9b21a49d21c0e53c808f862101faf4a3f /django/contrib/postgres/lookups.py | |
parent | 81b1c167bf919ddbd5aa0289f9f3761fc62addf3 (diff) | |
download | django-fbde929b19754f19cba1d14e86f4c59f4b0a633c.tar.gz |
Fixed #26056 -- Added QuerySet.values()/values_list() support for ArrayField's __overlap lookup.
Thanks Mads Jensen and kosz85 and the initial patch.
Diffstat (limited to 'django/contrib/postgres/lookups.py')
-rw-r--r-- | django/contrib/postgres/lookups.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/django/contrib/postgres/lookups.py b/django/contrib/postgres/lookups.py index f2f88ebc0a..4e1783f288 100644 --- a/django/contrib/postgres/lookups.py +++ b/django/contrib/postgres/lookups.py @@ -1,5 +1,6 @@ from django.db.models import Transform from django.db.models.lookups import PostgresOperatorLookup +from django.db.models.sql.query import Query from .search import SearchVector, SearchVectorExact, SearchVectorField @@ -18,6 +19,13 @@ class Overlap(PostgresOperatorLookup): lookup_name = "overlap" postgres_operator = "&&" + def get_prep_lookup(self): + from .expressions import ArraySubquery + + if isinstance(self.rhs, Query): + self.rhs = ArraySubquery(self.rhs) + return super().get_prep_lookup() + class HasKey(PostgresOperatorLookup): lookup_name = "has_key" |