diff 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
line wrap: on
line diff
--- a/test/db_test_base.py	Fri Aug 18 01:37:40 2006 +0000
+++ b/test/db_test_base.py	Sun Aug 20 10:16:03 2006 +0000
@@ -15,7 +15,7 @@
 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 #
-# $Id: db_test_base.py,v 1.73 2006-08-17 09:32:46 schlatterbeck Exp $
+# $Id: db_test_base.py,v 1.74 2006-08-20 10:16:03 schlatterbeck Exp $
 
 import unittest, os, shutil, errno, imp, sys, time, pprint, sets
 
@@ -1057,6 +1057,34 @@
         # descending should sort 1d, 1:10, None
         ae(filt(None, {}, ('-','foo'), (None,None)), ['2', '1', '4', '3'])
 
+    def testFilteringStringSort(self):
+        # 1: 'issue one'
+        # 2: 'issue two'
+        # 3: 'issue three'
+        # 4: 'non four'
+        ae, filt = self.filteringSetup()
+        ae(filt(None, {}, ('+','title')), ['1', '3', '2', '4'])
+        ae(filt(None, {}, ('-','title')), ['4', '2', '3', '1'])
+        # Test string case: For now allow both, w/wo case matching.
+        # 1: 'issue one'
+        # 2: 'issue two'
+        # 3: 'Issue three'
+        # 4: 'non four'
+        self.db.issue.set('3', title='Issue three')
+        assert(filt(None, {}, ('+','title')) in 
+            [['3', '1', '2', '4'], ['1', '3', '2', '4']])
+        assert(filt(None, {}, ('-','title')) in
+            [['4', '2', '1', '3'], ['4', '2', '3', '1']])
+        # Obscure bug in anydbm backend trying to convert to number
+        # 1: '1st issue'
+        # 2: '2'
+        # 3: 'Issue three'
+        # 4: 'non four'
+        self.db.issue.set('1', title='1st issue')
+        self.db.issue.set('2', title='2')
+        ae(filt(None, {}, ('+','title')), ['1', '2', '3', '4'])
+        ae(filt(None, {}, ('-','title')), ['4', '3', '2', '1'])
+
     def testFilteringMultilinkSort(self):
         # 1: []
         # 2: []

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