Five tests. OR operator now working

This commit is contained in:
David Sauve 2009-11-10 21:45:49 -05:00
parent 09ffc6d481
commit 537b1802a3
2 changed files with 11 additions and 7 deletions

View file

@ -66,11 +66,10 @@ class XapianSearchQueryTestCase(TestCase):
self.sq.add_filter(~SQ(content='world'))
self.assertEqual(self.sq.build_query().get_description(), 'Xapian::Query(((<alldocuments> AND_NOT hello) AND (<alldocuments> AND_NOT world)))')
# def test_build_query_multiple_words_or(self):
# self.sq.add_filter('content', 'hello', use_or=True)
# self.sq.add_filter('content', 'world', use_or=True)
# self.assertEqual(self.sq.build_query(), 'hello OR world')
#
def test_build_query_multiple_words_or(self):
self.sq.add_filter(SQ(content='hello') | SQ(content='world'))
self.assertEqual(self.sq.build_query().get_description(), 'Xapian::Query((hello OR world))')
# def test_build_query_multiple_words_mixed(self):
# self.sq.add_filter('content', 'why')
# self.sq.add_filter('content', 'hello', use_or=True)

View file

@ -947,7 +947,9 @@ class SearchQuery(BaseSearchQuery):
query_list.append(
xapian.Query(
xapian.Query.OP_AND,
self._query_from_search_node(child, child.negated)
self._query_from_search_node(
child, child.negated
)
)
)
else:
@ -958,7 +960,10 @@ class SearchQuery(BaseSearchQuery):
else:
query_list.append(xapian.Query(value))
return xapian.Query(xapian.Query.OP_AND, query_list)
if search_node.connector == 'OR':
return xapian.Query(xapian.Query.OP_OR, query_list)
else:
return xapian.Query(xapian.Query.OP_AND, query_list)
def build_sub_query(self, value):
return xapian.Query(value)