comparison 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
comparison
equal deleted inserted replaced
5865:04deafac71ab 5867:ee2e8f8d6648
1746 ['1']) 1746 ['1'])
1747 ae(filt(None, {'title': ['iSSUE']}, ('+','id'), (None,None)), 1747 ae(filt(None, {'title': ['iSSUE']}, ('+','id'), (None,None)),
1748 ['1','2','3']) 1748 ['1','2','3'])
1749 ae(filt(None, {'title': ['One', 'Two']}, ('+','id'), (None,None)), 1749 ae(filt(None, {'title': ['One', 'Two']}, ('+','id'), (None,None)),
1750 []) 1750 [])
1751
1752 def testFilteringStringExactMatch(self):
1753 ae, filter, filter_iter = self.filteringSetup()
1754 # Change title of issue2 to 'issue' so we can test substring
1755 # search vs exact search
1756 self.db.issue.set('2', title='issue')
1757 #self.db.commit()
1758 for filt in filter, filter_iter:
1759 ae(filt(None, {}, exact_match_spec =
1760 {'title': ['one']}), [])
1761 ae(filt(None, {}, exact_match_spec =
1762 {'title': ['issue one']}), ['1'])
1763 ae(filt(None, {}, exact_match_spec =
1764 {'title': ['issue', 'one']}), [])
1765 ae(filt(None, {}, exact_match_spec =
1766 {'title': ['issue']}), ['2'])
1767 ae(filt(None, {}, exact_match_spec =
1768 {'title': ['one', 'two']}), [])
1769 ae(filt(None, {}, exact_match_spec =
1770 {'title': ['One']}), [])
1771 ae(filt(None, {}, exact_match_spec =
1772 {'title': ['Issue One']}), [])
1773 ae(filt(None, {}, exact_match_spec =
1774 {'title': ['ISSUE', 'ONE']}), [])
1775 ae(filt(None, {}, exact_match_spec =
1776 {'title': ['iSSUE']}), [])
1777 ae(filt(None, {}, exact_match_spec =
1778 {'title': ['One', 'Two']}), [])
1779 ae(filt(None, {}, exact_match_spec =
1780 {'title': ['non four']}), ['4'])
1781 # Both, filterspec and exact_match_spec on same prop
1782 ae(filt(None, {'title': 'iSSUE'}, exact_match_spec =
1783 {'title': ['issue']}), ['2'])
1751 1784
1752 def testFilteringSpecialChars(self): 1785 def testFilteringSpecialChars(self):
1753 """ Special characters in SQL search are '%' and '_', some used 1786 """ Special characters in SQL search are '%' and '_', some used
1754 to lead to a traceback. 1787 to lead to a traceback.
1755 """ 1788 """

Roundup Issue Tracker: http://roundup-tracker.org/