summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f3ce147)
raw | patch | inline | side by side (parent: f3ce147)
author | schlatterbeck <schlatterbeck@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Fri, 5 Mar 2010 15:51:11 +0000 (15:51 +0000) | ||
committer | schlatterbeck <schlatterbeck@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Fri, 5 Mar 2010 15:51:11 +0000 (15:51 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4471 57a73879-2fb5-44c3-a270-3262357dd7e2
roundup/backends/back_anydbm.py | patch | blob | history | |
roundup/backends/rdbms_common.py | patch | blob | history | |
test/db_test_base.py | patch | blob | history |
index 90cf05e461f17b9a0cb2268e97e08b9749f9e026..baa389b4a5bf2efc66c82a692548a8ce471174b9 100644 (file)
pass
elif isinstance(propclass, hyperdb.Boolean):
- if type(v) != type([]):
+ if type(v) == type(""):
v = v.split(',')
+ if type(v) != type([]):
+ v = [v]
bv = []
for val in v:
if type(val) is type(''):
- bv.append(val.lower() in ('yes', 'true', 'on', '1'))
+ bv.append(propclass.from_raw (val))
else:
bv.append(val)
l.append((OTHER, k, bv))
index a95493a3536a18faf4ac7e78d71bbf7cb88f234e..6942a78b847af1b0a37b5d581b1fc2367bb04e9d 100644 (file)
pass
if p.sort_type > 0:
oc = ac = '_%s.__%s_int__'%(pln,k)
+ elif isinstance(propclass, Boolean) and p.sort_type < 2:
+ if type(v) == type(""):
+ v = v.split(',')
+ if type(v) != type([]):
+ v = [v]
+ bv = []
+ for val in v:
+ if type(val) is type(''):
+ bv.append(propclass.from_raw (val))
+ else:
+ bv.append(bool(val))
+ if len(bv) == 1:
+ where.append('_%s._%s=%s'%(pln, k, a))
+ args = args + bv
+ else:
+ s = ','.join([a for x in v])
+ where.append('_%s._%s in (%s)'%(pln, k, s))
+ args = args + bv
elif p.sort_type < 2:
if isinstance(v, type([])):
s = ','.join([a for x in v])
diff --git a/test/db_test_base.py b/test/db_test_base.py
index 4f68b79a66f9bc7e6023236ce2bc720946d4e03c..0751216a46c98df4eae88c2e58bdebf2aa9c75ea 100644 (file)
--- a/test/db_test_base.py
+++ b/test/db_test_base.py
def filteringSetup(self):
for user in (
- {'username': 'bleep', 'age': 1},
- {'username': 'blop', 'age': 1.5},
- {'username': 'blorp', 'age': 2}):
+ {'username': 'bleep', 'age': 1, 'assignable': True},
+ {'username': 'blop', 'age': 1.5, 'assignable': True},
+ {'username': 'blorp', 'age': 2, 'assignable': False}):
self.db.user.create(**user)
iss = self.db.issue
file_content = ''.join([chr(i) for i in range(255)])
ae(filt(None, {'id': '2'}, ('+','id'), (None,None)), ['2'])
ae(filt(None, {'id': '100'}, ('+','id'), (None,None)), [])
+ def testFilteringBoolean(self):
+ self.filteringSetup()
+ ae, filt = self.assertEqual, self.db.user.filter
+ a = 'assignable'
+ ae(filt(None, {a: '1'}, ('+','id'), (None,None)), ['3','4'])
+ ae(filt(None, {a: '0'}, ('+','id'), (None,None)), ['5'])
+ ae(filt(None, {a: ['1']}, ('+','id'), (None,None)), ['3','4'])
+ ae(filt(None, {a: ['0']}, ('+','id'), (None,None)), ['5'])
+ ae(filt(None, {a: ['0','1']}, ('+','id'), (None,None)), ['3','4','5'])
+ ae(filt(None, {a: 'True'}, ('+','id'), (None,None)), ['3','4'])
+ ae(filt(None, {a: 'False'}, ('+','id'), (None,None)), ['5'])
+ ae(filt(None, {a: ['True']}, ('+','id'), (None,None)), ['3','4'])
+ ae(filt(None, {a: ['False']}, ('+','id'), (None,None)), ['5'])
+ ae(filt(None, {a: ['False','True']}, ('+','id'), (None,None)),
+ ['3','4','5'])
+ ae(filt(None, {a: True}, ('+','id'), (None,None)), ['3','4'])
+ ae(filt(None, {a: False}, ('+','id'), (None,None)), ['5'])
+ ae(filt(None, {a: 1}, ('+','id'), (None,None)), ['3','4'])
+ ae(filt(None, {a: 0}, ('+','id'), (None,None)), ['5'])
+ ae(filt(None, {a: [1]}, ('+','id'), (None,None)), ['3','4'])
+ ae(filt(None, {a: [0]}, ('+','id'), (None,None)), ['5'])
+ ae(filt(None, {a: [0,1]}, ('+','id'), (None,None)), ['3','4','5'])
+ ae(filt(None, {a: [True]}, ('+','id'), (None,None)), ['3','4'])
+ ae(filt(None, {a: [False]}, ('+','id'), (None,None)), ['5'])
+ ae(filt(None, {a: [False,True]}, ('+','id'), (None,None)),
+ ['3','4','5'])
+
def testFilteringNumber(self):
self.filteringSetup()
ae, filt = self.assertEqual, self.db.user.filter