Skip to content

Commit be33b14

Browse files
author
Ralf Schlatterbeck
committed
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.
1 parent 997670e commit be33b14

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

test/db_test_base.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
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 $
1919

2020
import unittest, os, shutil, errno, imp, sys, time, pprint, sets
2121

@@ -1057,6 +1057,34 @@ def testFilteringIntervalSort(self):
10571057
# descending should sort 1d, 1:10, None
10581058
ae(filt(None, {}, ('-','foo'), (None,None)), ['2', '1', '4', '3'])
10591059

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+
10601088
def testFilteringMultilinkSort(self):
10611089
# 1: []
10621090
# 2: []

0 commit comments

Comments
 (0)