Passing three tests. Empty query, single content value, multi-content values

This commit is contained in:
David Sauve 2009-11-10 20:47:59 -05:00
parent 529edc24b4
commit 35f51e97bc
2 changed files with 10 additions and 6 deletions

View file

@ -56,11 +56,11 @@ class XapianSearchQueryTestCase(TestCase):
self.sq.add_filter(SQ(content='hello'))
self.assertEqual(self.sq.build_query().get_description(), 'Xapian::Query(hello)')
# def test_build_query_multiple_words_and(self):
# self.sq.add_filter(SQ(content='hello'))
# self.sq.add_filter(SQ(content='world'))
# self.assertEqual(self.sq.build_query().get_description(), 'Xapian::Query((hello AND world))')
#
def test_build_query_multiple_words_and(self):
self.sq.add_filter(SQ(content='hello'))
self.sq.add_filter(SQ(content='world'))
self.assertEqual(self.sq.build_query().get_description(), 'Xapian::Query((hello AND world))')
# def test_build_query_multiple_words_not(self):
# self.sq.add_filter(~SQ(content='hello'))
# self.sq.add_filter(~SQ(content='world'))

View file

@ -937,9 +937,13 @@ class SearchQuery(BaseSearchQuery):
if not self.query_filter:
query = xapian.Query('')
else:
query_list = []
for child in self.query_filter.children:
expression, value = child
query = xapian.Query(value)
query_list.append(value)
query = xapian.Query(xapian.Query.OP_AND, query_list)
return query