comparison test/db_test_base.py @ 3685:4d9adb8bc3b1

Null-value sorting fixes: - Fixed sorting of NULL values for the PostgreSQL backend. Generic implementation of additional sort-key for NULL values, can be reused by other (future) rdbms backends. - Added a test for NULL value sorting and removed an override for the Interval test for the PostgreSQL backend which had a special case for NULL values
author Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
date Wed, 23 Aug 2006 12:57:10 +0000
parents bffa231ec3bc
children 8e52157e2073
comparison
equal deleted inserted replaced
3684:bffa231ec3bc 3685:4d9adb8bc3b1
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.76 2006-08-22 19:33:02 schlatterbeck Exp $ 18 # $Id: db_test_base.py,v 1.77 2006-08-23 12:57:10 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
1214 1214
1215 def testFilteringTransitiveLinkSort(self): 1215 def testFilteringTransitiveLinkSort(self):
1216 ae, filt = self.filteringSetupTransitiveSearch() 1216 ae, filt = self.filteringSetupTransitiveSearch()
1217 ufilt = self.db.user.filter 1217 ufilt = self.db.user.filter
1218 # Need to make ceo his own (and first two users') supervisor, 1218 # Need to make ceo his own (and first two users') supervisor,
1219 # otherwise sorting for postgreSQL will fail: postgreSQL seems 1219 # otherwise we will depend on sorting order of NULL values.
1220 # to sort NULLs last. 1220 # Leave that to a separate test.
1221 self.db.user.set('1', supervisor = '3') 1221 self.db.user.set('1', supervisor = '3')
1222 self.db.user.set('2', supervisor = '3') 1222 self.db.user.set('2', supervisor = '3')
1223 self.db.user.set('3', supervisor = '3') 1223 self.db.user.set('3', supervisor = '3')
1224 ae(ufilt(None, {'supervisor':'3'}, []), ['1', '2', '3', '4', '5']) 1224 ae(ufilt(None, {'supervisor':'3'}, []), ['1', '2', '3', '4', '5'])
1225 ae(ufilt(None, {}, [('+','supervisor.supervisor.supervisor'), 1225 ae(ufilt(None, {}, [('+','supervisor.supervisor.supervisor'),
1250 ['1', '2', '3', '4', '5', '7', '6', '8']) 1250 ['1', '2', '3', '4', '5', '7', '6', '8'])
1251 ae(filt(None, {}, [('+','assignedto.supervisor.supervisor.supervisor'), 1251 ae(filt(None, {}, [('+','assignedto.supervisor.supervisor.supervisor'),
1252 ('+','assignedto.supervisor.supervisor'), 1252 ('+','assignedto.supervisor.supervisor'),
1253 ('-','assignedto.supervisor'), ('+','assignedto'), ('+','status')]), 1253 ('-','assignedto.supervisor'), ('+','assignedto'), ('+','status')]),
1254 ['4', '5', '7', '6', '8', '1', '2', '3']) 1254 ['4', '5', '7', '6', '8', '1', '2', '3'])
1255
1256 def testFilteringTransitiveLinkSortNull(self):
1257 """Check sorting of NULL values"""
1258 ae, filt = self.filteringSetupTransitiveSearch()
1259 ufilt = self.db.user.filter
1260 ae(ufilt(None, {}, [('+','supervisor.supervisor.supervisor'),
1261 ('+','supervisor.supervisor'), ('+','supervisor'),
1262 ('+','username')]),
1263 ['1', '3', '2', '4', '5', '6', '7', '8', '9', '10'])
1264 ae(ufilt(None, {}, [('+','supervisor.supervisor.supervisor'),
1265 ('-','supervisor.supervisor'), ('-','supervisor'),
1266 ('+','username')]),
1267 ['8', '9', '10', '6', '7', '4', '5', '1', '3', '2'])
1268 ae(filt(None, {}, [('+','assignedto.supervisor.supervisor.supervisor'),
1269 ('+','assignedto.supervisor.supervisor'),
1270 ('+','assignedto.supervisor'), ('+','assignedto')]),
1271 ['1', '2', '3', '4', '5', '6', '7', '8'])
1272 ae(filt(None, {}, [('+','assignedto.supervisor.supervisor.supervisor'),
1273 ('+','assignedto.supervisor.supervisor'),
1274 ('-','assignedto.supervisor'), ('+','assignedto')]),
1275 ['4', '5', '6', '7', '8', '1', '2', '3'])
1255 1276
1256 def testFilteringTransitiveLinkIssue(self): 1277 def testFilteringTransitiveLinkIssue(self):
1257 ae, filt = self.filteringSetupTransitiveSearch() 1278 ae, filt = self.filteringSetupTransitiveSearch()
1258 ae(filt(None, {'assignedto.supervisor.username': 'grouplead1'}, 1279 ae(filt(None, {'assignedto.supervisor.username': 'grouplead1'},
1259 ('+','id')), ['1', '2', '3']) 1280 ('+','id')), ['1', '2', '3'])

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