fix numeric queries over empty string (fix #547)

This commit is contained in:
Adrian Sampson 2014-02-17 22:51:53 -05:00
parent 5d55312fdb
commit c196f20dfc
2 changed files with 8 additions and 2 deletions

View file

@ -225,7 +225,7 @@ class NumericQuery(FieldQuery):
elif self.rangemax is not None:
return u'{0} <= ?'.format(self.field), (self.rangemax,)
else:
return '1'
return '1', ()
class CollectionQuery(Query):

View file

@ -261,7 +261,8 @@ class GetTest(DummyDataTestCase):
def test_bad_year(self):
q = 'year:delete from items'
self.assertRaises(ValueError, self.lib.items, q)
results = self.lib.items(q)
self.assert_matched(results, [])
def test_singleton_true(self):
q = 'singleton:true'
@ -320,6 +321,11 @@ class GetTest(DummyDataTestCase):
results = self.lib.items(q)
self.assertFalse(results)
def test_numeric_empty(self):
q = dbcore.query.NumericQuery('year', '')
results = self.lib.items(q)
self.assertTrue(results)
class MatchTest(_common.TestCase):
def setUp(self):