Mercurial > p > roundup > code
diff test/db_test_base.py @ 4849:e68920390aad
Fix SQL wildcards in string search
Fix String search with special SQL wildcard characters in LIKE/ILIKE
clause and add testcase.
| author | Ralf Schlatterbeck <rsc@runtux.com> |
|---|---|
| date | Thu, 12 Dec 2013 16:15:25 +0100 |
| parents | 4a017661e414 |
| children | 6998ad77841e |
line wrap: on
line diff
--- a/test/db_test_base.py Wed Nov 13 11:13:26 2013 +0100 +++ b/test/db_test_base.py Thu Dec 12 16:15:25 2013 +0100 @@ -1252,6 +1252,22 @@ ae(filt(None, {'title': ['One', 'Two']}, ('+','id'), (None,None)), []) + def testFilteringSpecialChars(self): + """ Special characters in SQL search are '%' and '_', some used + to lead to a traceback. + """ + ae, filter, filter_iter = self.filteringSetup() + self.db.issue.set('1', title="With % symbol") + self.db.issue.set('2', title="With _ symbol") + self.db.issue.set('3', title="With \\ symbol") + self.db.issue.set('4', title="With ' symbol") + d = dict (status = '1') + for filt in filter, filter_iter: + ae(filt(None, dict(title='%'), ('+','id'), (None,None)), ['1']) + ae(filt(None, dict(title='_'), ('+','id'), (None,None)), ['2']) + ae(filt(None, dict(title='\\'), ('+','id'), (None,None)), ['3']) + ae(filt(None, dict(title="'"), ('+','id'), (None,None)), ['4']) + def testFilteringLink(self): ae, filter, filter_iter = self.filteringSetup() a = 'assignedto'
