Mercurial > p > roundup > code
diff test/db_test_base.py @ 5867:ee2e8f8d6648
Implement exact string search
.. in the 'filter' method of hyperdb.Class (and the corresponding
backend implementations).
| author | Ralf Schlatterbeck <rsc@runtux.com> |
|---|---|
| date | Mon, 26 Aug 2019 18:18:02 +0200 |
| parents | 046717e09beb |
| children | 16e1255b16cf |
line wrap: on
line diff
--- a/test/db_test_base.py Mon Aug 26 09:56:20 2019 +0200 +++ b/test/db_test_base.py Mon Aug 26 18:18:02 2019 +0200 @@ -1749,6 +1749,39 @@ ae(filt(None, {'title': ['One', 'Two']}, ('+','id'), (None,None)), []) + def testFilteringStringExactMatch(self): + ae, filter, filter_iter = self.filteringSetup() + # Change title of issue2 to 'issue' so we can test substring + # search vs exact search + self.db.issue.set('2', title='issue') + #self.db.commit() + for filt in filter, filter_iter: + ae(filt(None, {}, exact_match_spec = + {'title': ['one']}), []) + ae(filt(None, {}, exact_match_spec = + {'title': ['issue one']}), ['1']) + ae(filt(None, {}, exact_match_spec = + {'title': ['issue', 'one']}), []) + ae(filt(None, {}, exact_match_spec = + {'title': ['issue']}), ['2']) + ae(filt(None, {}, exact_match_spec = + {'title': ['one', 'two']}), []) + ae(filt(None, {}, exact_match_spec = + {'title': ['One']}), []) + ae(filt(None, {}, exact_match_spec = + {'title': ['Issue One']}), []) + ae(filt(None, {}, exact_match_spec = + {'title': ['ISSUE', 'ONE']}), []) + ae(filt(None, {}, exact_match_spec = + {'title': ['iSSUE']}), []) + ae(filt(None, {}, exact_match_spec = + {'title': ['One', 'Two']}), []) + ae(filt(None, {}, exact_match_spec = + {'title': ['non four']}), ['4']) + # Both, filterspec and exact_match_spec on same prop + ae(filt(None, {'title': 'iSSUE'}, exact_match_spec = + {'title': ['issue']}), ['2']) + def testFilteringSpecialChars(self): """ Special characters in SQL search are '%' and '_', some used to lead to a traceback.
