1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #26056 -- Added QuerySet.values()/values_list() support for ArrayField's __overlap lookup.

Thanks Mads Jensen and kosz85 and the initial patch.
This commit is contained in:
Ben Cail
2022-10-26 09:58:08 -04:00
committed by Mariusz Felisiak
parent 81b1c167bf
commit fbde929b19
4 changed files with 35 additions and 1 deletions

View File

@@ -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"