Mercurial > p > roundup > code
comparison test/db_test_base.py @ 3681:b9301ae1c34d
Added a test case for string comparison:
- For now allow both with and without case-sensitive comparison. In my
test Anydbm, Metakit and MySQL compare without case while Postgres
and SQLite compare with case.
Maybe the collation sequence should be defined by a backend language
option in the configuration?
Note that this *will* be a problem when Multilink-Sorting is
implemented in a generic module: In that case the string comparison
will differ when Multilinks are used in a query :-(
- When reviewing the source code for sorting in the various backends I
discovered an obscure piece of code in back_anydb::
if isinstance(propclass, hyperdb.String):
# it might be a string that's really an integer
try: tv = int(v)
except: v = v.lower()
else: v = tv
This tries to convert strings to integers. Bad. Maybe a misguided
attempt at fixing the sorting by id to be numeric (no this won't do
it) I've added a test that only anydbm fails.
I will remove that bug in the upcoming transitive sorting.
| author | Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net> |
|---|---|
| date | Sun, 20 Aug 2006 10:16:03 +0000 |
| parents | f3785d646f22 |
| children | 193f316dbbe9 |
comparison
equal
deleted
inserted
replaced
| 3680:c008df9f9bb4 | 3681:b9301ae1c34d |
|---|---|
| 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 17 # | 17 # |
| 18 # $Id: db_test_base.py,v 1.73 2006-08-17 09:32:46 schlatterbeck Exp $ | 18 # $Id: db_test_base.py,v 1.74 2006-08-20 10:16:03 schlatterbeck Exp $ |
| 19 | 19 |
| 20 import unittest, os, shutil, errno, imp, sys, time, pprint, sets | 20 import unittest, os, shutil, errno, imp, sys, time, pprint, sets |
| 21 | 21 |
| 22 from roundup.hyperdb import String, Password, Link, Multilink, Date, \ | 22 from roundup.hyperdb import String, Password, Link, Multilink, Date, \ |
| 23 Interval, DatabaseError, Boolean, Number, Node | 23 Interval, DatabaseError, Boolean, Number, Node |
| 1055 # ascending should sort None, 1:10, 1d | 1055 # ascending should sort None, 1:10, 1d |
| 1056 ae(filt(None, {}, ('+','foo'), (None,None)), ['3', '4', '1', '2']) | 1056 ae(filt(None, {}, ('+','foo'), (None,None)), ['3', '4', '1', '2']) |
| 1057 # descending should sort 1d, 1:10, None | 1057 # descending should sort 1d, 1:10, None |
| 1058 ae(filt(None, {}, ('-','foo'), (None,None)), ['2', '1', '4', '3']) | 1058 ae(filt(None, {}, ('-','foo'), (None,None)), ['2', '1', '4', '3']) |
| 1059 | 1059 |
| 1060 def testFilteringStringSort(self): | |
| 1061 # 1: 'issue one' | |
| 1062 # 2: 'issue two' | |
| 1063 # 3: 'issue three' | |
| 1064 # 4: 'non four' | |
| 1065 ae, filt = self.filteringSetup() | |
| 1066 ae(filt(None, {}, ('+','title')), ['1', '3', '2', '4']) | |
| 1067 ae(filt(None, {}, ('-','title')), ['4', '2', '3', '1']) | |
| 1068 # Test string case: For now allow both, w/wo case matching. | |
| 1069 # 1: 'issue one' | |
| 1070 # 2: 'issue two' | |
| 1071 # 3: 'Issue three' | |
| 1072 # 4: 'non four' | |
| 1073 self.db.issue.set('3', title='Issue three') | |
| 1074 assert(filt(None, {}, ('+','title')) in | |
| 1075 [['3', '1', '2', '4'], ['1', '3', '2', '4']]) | |
| 1076 assert(filt(None, {}, ('-','title')) in | |
| 1077 [['4', '2', '1', '3'], ['4', '2', '3', '1']]) | |
| 1078 # Obscure bug in anydbm backend trying to convert to number | |
| 1079 # 1: '1st issue' | |
| 1080 # 2: '2' | |
| 1081 # 3: 'Issue three' | |
| 1082 # 4: 'non four' | |
| 1083 self.db.issue.set('1', title='1st issue') | |
| 1084 self.db.issue.set('2', title='2') | |
| 1085 ae(filt(None, {}, ('+','title')), ['1', '2', '3', '4']) | |
| 1086 ae(filt(None, {}, ('-','title')), ['4', '3', '2', '1']) | |
| 1087 | |
| 1060 def testFilteringMultilinkSort(self): | 1088 def testFilteringMultilinkSort(self): |
| 1061 # 1: [] | 1089 # 1: [] |
| 1062 # 2: [] | 1090 # 2: [] |
| 1063 # 3: ['1','2'] | 1091 # 3: ['1','2'] |
| 1064 # 4: ['1'] | 1092 # 4: ['1'] |
