mirror of
https://github.com/Hopiu/xapian-haystack.git
synced 2026-04-21 07:11:03 +00:00
Fixed a bug so that `ValuesListQuerySet now works with the __in` filter.
This commit is contained in:
parent
9afba72cae
commit
3b3834d8ed
2 changed files with 9 additions and 0 deletions
|
|
@ -159,3 +159,8 @@ class XapianSearchQueryTestCase(TestCase):
|
|||
def test_build_query_with_punctuation(self):
|
||||
self.sq.add_filter(SQ(content='http://www.example.com'))
|
||||
self.assertEqual(str(self.sq.build_query()), u'Xapian::Query((Zhttp://www.example.com OR http://www.example.com))')
|
||||
|
||||
def test_in_filter_values_list(self):
|
||||
self.sq.add_filter(SQ(content='why'))
|
||||
self.sq.add_filter(SQ(title__in=MockModel.objects.values_list('id', flat=True)))
|
||||
self.assertEqual(str(self.sq.build_query()), u'Xapian::Query(((Zwhi OR why) AND (ZXTITLE1 OR XTITLE1 OR ZXTITLE2 OR XTITLE2 OR ZXTITLE3 OR XTITLE3)))')
|
||||
|
|
|
|||
|
|
@ -954,6 +954,10 @@ class SearchQuery(BaseSearchQuery):
|
|||
expression, term = child
|
||||
field, filter_type = search_node.split_expression(expression)
|
||||
|
||||
# Handle when we've got a ``ValuesListQuerySet``...
|
||||
if hasattr(term, 'values_list'):
|
||||
term = list(term)
|
||||
|
||||
if isinstance(term, (list, tuple)):
|
||||
term = [_marshal_term(t) for t in term]
|
||||
else:
|
||||
|
|
|
|||
Loading…
Reference in a new issue