Fixed broken __startswith (removing FLAG_PARTIAL changed how this works). This closes issue #64.

This commit is contained in:
David Sauve 2010-12-12 13:28:53 -08:00
parent 2d8ef676a0
commit a07a980662
2 changed files with 4 additions and 8 deletions

View File

@ -414,13 +414,9 @@ class LiveXapianSearchQueryTestCase(TestCase):
self.assertEqual(self.sq.get_spelling_suggestion(), u'indexed')
self.assertEqual(self.sq.get_spelling_suggestion('indxd'), u'indexed')
def test_startswith_wildcard(self):
self.sq.add_filter(SQ(name__startswith='da*'))
def test_startswith(self):
self.sq.add_filter(SQ(name__startswith='da'))
self.assertEqual([result.pk for result in self.sq.get_results()], [1, 2, 3])
def test_startswith_fullword(self):
self.sq.add_filter(SQ(name__startswith='daniel1'))
self.assertEqual([result.pk for result in self.sq.get_results()], [1])
def test_build_query_gt(self):
self.sq.add_filter(SQ(name__gt='m'))

View File

@ -1064,9 +1064,9 @@ class SearchQuery(BaseSearchQuery):
return xapian.Query(
xapian.Query.OP_AND_NOT,
self._all_query(),
self.backend.parse_query('%s:%s' % (field, term)),
self.backend.parse_query('%s:%s*' % (field, term)),
)
return self.backend.parse_query('%s:%s' % (field, term))
return self.backend.parse_query('%s:%s*' % (field, term))
def _filter_gt(self, term, field, is_not):
return self._filter_lte(term, field, is_not=(is_not != True))