mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-11 16:53:10 +00:00
Fix values_list subqueries in Elasticsearch queries
This commit is contained in:
parent
e20fbcc3cd
commit
a3f682ca85
3 changed files with 6 additions and 13 deletions
|
|
@ -4,7 +4,7 @@ from urllib.parse import urlparse
|
|||
|
||||
from django.db import DEFAULT_DB_ALIAS, models
|
||||
from django.db.models.sql import Query
|
||||
from django.db.models.sql.constants import SINGLE
|
||||
from django.db.models.sql.constants import MULTI
|
||||
from django.utils.crypto import get_random_string
|
||||
from elasticsearch import Elasticsearch, NotFoundError
|
||||
from elasticsearch.helpers import bulk
|
||||
|
|
@ -340,8 +340,11 @@ class Elasticsearch2SearchQuery(BaseSearchQuery):
|
|||
if lookup == 'in':
|
||||
if isinstance(value, Query):
|
||||
db_alias = self.queryset._db or DEFAULT_DB_ALIAS
|
||||
value = (value.get_compiler(db_alias)
|
||||
.execute_sql(result_type=SINGLE))
|
||||
value = next(value.get_compiler(db_alias)
|
||||
.execute_sql(result_type=MULTI))
|
||||
|
||||
value = [r[0] for r in value]
|
||||
|
||||
elif not isinstance(value, list):
|
||||
value = list(value)
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -19,11 +19,6 @@ from .test_backends import BackendTests
|
|||
class TestElasticsearch2SearchBackend(BackendTests, ElasticsearchCommonSearchBackendTests, TestCase):
|
||||
backend_path = 'wagtail.search.backends.elasticsearch2'
|
||||
|
||||
# Broken
|
||||
@unittest.expectedFailure
|
||||
def test_filter_in_values_list_subquery(self):
|
||||
super(TestElasticsearch2SearchBackend, self).test_filter_in_values_list_subquery()
|
||||
|
||||
# Broken
|
||||
@unittest.expectedFailure
|
||||
def test_order_by_non_filterable_field(self):
|
||||
|
|
|
|||
|
|
@ -23,11 +23,6 @@ class TestElasticsearch5SearchBackend(BackendTests, ElasticsearchCommonSearchBac
|
|||
def test_filter_isnull_true(self):
|
||||
super(TestElasticsearch5SearchBackend, self).test_filter_isnull_true()
|
||||
|
||||
# Broken
|
||||
@unittest.expectedFailure
|
||||
def test_filter_in_values_list_subquery(self):
|
||||
super(TestElasticsearch5SearchBackend, self).test_filter_in_values_list_subquery()
|
||||
|
||||
# Broken
|
||||
@unittest.expectedFailure
|
||||
def test_order_by_non_filterable_field(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue