From cf97b77818f83b8bfb9228908f4240ce782893ff Mon Sep 17 00:00:00 2001 From: David Sauve Date: Tue, 10 Nov 2009 20:47:59 -0500 Subject: [PATCH] Passing three tests. Empty query, single content value, multi-content values --- tests/xapian_tests/tests/xapian_query.py | 10 +++++----- xapian_backend.py | 6 +++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/xapian_tests/tests/xapian_query.py b/tests/xapian_tests/tests/xapian_query.py index b94b7f5..a3a5cbd 100644 --- a/tests/xapian_tests/tests/xapian_query.py +++ b/tests/xapian_tests/tests/xapian_query.py @@ -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')) diff --git a/xapian_backend.py b/xapian_backend.py index 8c86ac0..1d16ac5 100755 --- a/xapian_backend.py +++ b/xapian_backend.py @@ -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