Fixed #101 - Adds support to AutoQuery.

This commit is contained in:
Jorge C. Leitão 2014-05-17 13:40:59 +02:00
parent 4d51f5e9af
commit 5d16d1aca7

View file

@ -16,6 +16,7 @@ from haystack import connections
from haystack.backends import BaseEngine, BaseSearchBackend, BaseSearchQuery, SearchNode, log_query
from haystack.constants import ID, DJANGO_ID, DJANGO_CT
from haystack.exceptions import HaystackError, MissingDependency
from haystack.inputs import AutoQuery
from haystack.models import SearchResult
from haystack.utils import get_identifier, get_model_ct
@ -1011,6 +1012,15 @@ class XapianSearchQuery(BaseSearchQuery):
expression, term = child
field_name, filter_type = search_node.split_expression(expression)
# Identify and parse AutoQuery
if isinstance(term, AutoQuery):
if field_name != 'content':
query = '%s:%s' % (field_name, term.prepare(self))
else:
query = term.prepare(self)
query_list.append(self.backend.parse_query(query))
continue
# Handle `ValuesListQuerySet`.
if hasattr(term, 'values_list'):
term = list(term)