Skip to content

Commit 610745f

Browse files
author
Alexander Smishlajev
committed
fix invalid sql produced for multilink condition with empty value list;
trim trailing spaces
1 parent ff632c9 commit 610745f

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed

roundup/backends/rdbms_common.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: rdbms_common.py,v 1.116 2004-07-02 05:22:09 richard Exp $
1+
# $Id: rdbms_common.py,v 1.117 2004-07-02 08:15:01 a1s Exp $
22
''' Relational database (SQL) backend common code.
33
44
Basics:
@@ -476,7 +476,7 @@ def drop_class_table_key_index(self, cn, key):
476476
self.sql(sql)
477477

478478
def create_journal_table(self, spec):
479-
''' create the journal table for a class given the spec and
479+
''' create the journal table for a class given the spec and
480480
already-determined cols
481481
'''
482482
# journal table
@@ -981,7 +981,7 @@ def addjournal(self, classname, nodeid, action, params, creator=None,
981981
if __debug__:
982982
self.config.logging.getLogger('hyperdb').debug('addjournal %s%s %r %s %s %r'%(classname,
983983
nodeid, journaldate, journaltag, action, params))
984-
984+
985985
# make the journalled data marshallable
986986
if isinstance(params, type({})):
987987
self._journal_marshal(params, classname)
@@ -1009,7 +1009,7 @@ def setjournal(self, classname, nodeid, journal):
10091009
self.config.logging.getLogger('hyperdb').debug('addjournal %s%s %r %s %s %r'%(
10101010
classname, nodeid, journaldate, journaltag, action,
10111011
params))
1012-
1012+
10131013
# make the journalled data marshallable
10141014
if isinstance(params, type({})):
10151015
self._journal_marshal(params, classname)
@@ -1168,7 +1168,7 @@ def close(self):
11681168
#
11691169
class Class(hyperdb.Class):
11701170
''' The handle to a particular class of nodes in a hyperdatabase.
1171-
1171+
11721172
All methods except __repr__ and getnode must be implemented by a
11731173
concrete backend Class.
11741174
'''
@@ -1223,21 +1223,21 @@ def create(self, **propvalues):
12231223
12241224
The values of arguments must be acceptable for the types of their
12251225
corresponding properties or a TypeError is raised.
1226-
1226+
12271227
If this class has a key property, it must be present and its value
12281228
must not collide with other key strings or a ValueError is raised.
1229-
1229+
12301230
Any other properties on this class that are missing from the
12311231
'propvalues' dictionary are set to None.
1232-
1232+
12331233
If an id in a link or multilink property does not refer to a valid
12341234
node, an IndexError is raised.
12351235
'''
12361236
self.fireAuditors('create', None, propvalues)
12371237
newid = self.create_inner(**propvalues)
12381238
self.fireReactors('create', newid, None)
12391239
return newid
1240-
1240+
12411241
def create_inner(self, **propvalues):
12421242
''' Called by create, in-between the audit and react calls.
12431243
'''
@@ -1432,7 +1432,7 @@ def get(self, nodeid, propname, default=_marker, cache=1):
14321432

14331433
def set(self, nodeid, **propvalues):
14341434
'''Modify a property on an existing node of this class.
1435-
1435+
14361436
'nodeid' must be the id of an existing node of this class or an
14371437
IndexError is raised.
14381438
@@ -1452,11 +1452,11 @@ class or a KeyError is raised.
14521452
oldvalues = copy.deepcopy(self.db.getnode(self.classname, nodeid))
14531453
propvalues = self.set_inner(nodeid, **propvalues)
14541454
self.fireReactors('set', nodeid, oldvalues)
1455-
return propvalues
1455+
return propvalues
14561456

14571457
def set_inner(self, nodeid, **propvalues):
14581458
''' Called by set, in-between the audit and react calls.
1459-
'''
1459+
'''
14601460
if not propvalues:
14611461
return propvalues
14621462

@@ -1651,10 +1651,10 @@ def set_inner(self, nodeid, **propvalues):
16511651

16521652
def retire(self, nodeid):
16531653
'''Retire a node.
1654-
1654+
16551655
The properties on the node remain available from the get() method,
16561656
and the node's id is never reused.
1657-
1657+
16581658
Retired nodes are not returned by the find(), list(), or lookup()
16591659
methods, and other nodes may reuse the values of their key properties.
16601660
'''
@@ -1702,7 +1702,7 @@ def restore(self, nodeid):
17021702
self.db.addjournal(self.classname, nodeid, 'restored', None)
17031703

17041704
self.fireReactors('restore', nodeid, None)
1705-
1705+
17061706
def is_retired(self, nodeid):
17071707
'''Return true if the node is rerired
17081708
'''
@@ -1713,7 +1713,7 @@ def is_retired(self, nodeid):
17131713

17141714
def destroy(self, nodeid):
17151715
'''Destroy a node.
1716-
1716+
17171717
WARNING: this method should never be used except in extremely rare
17181718
situations where there could never be links to the node being
17191719
deleted
@@ -1918,7 +1918,7 @@ def stringFind(self, **requirements):
19181918
properties in a caseless search.
19191919
19201920
If the property is not a String property, a TypeError is raised.
1921-
1921+
19221922
The return is a list of the id of all nodes that match.
19231923
'''
19241924
where = []
@@ -1948,7 +1948,7 @@ def list(self):
19481948
def getnodeids(self, retired=None):
19491949
''' Retrieve all the ids of the nodes for a particular Class.
19501950
1951-
Set retired=None to get all nodes. Otherwise it'll get all the
1951+
Set retired=None to get all nodes. Otherwise it'll get all the
19521952
retired or non-retired nodes, depending on the flag.
19531953
'''
19541954
# flip the sense of the 'retired' flag if we don't want all of them
@@ -2060,7 +2060,8 @@ def filter(self, search_matches, filterspec, sort=(None,None),
20602060
s = ','.join([a for x in v])
20612061
where.append('(_%s._%s in (%s))'%(cn, k, s))
20622062
args = args + v
2063-
where.append(' or '.join(l))
2063+
if l:
2064+
where.append(' or '.join(l))
20642065
else:
20652066
if v in ('-1', None):
20662067
v = None
@@ -2086,7 +2087,7 @@ def filter(self, search_matches, filterspec, sort=(None,None),
20862087
args.append(dc(date_rng.to_value))
20872088
except ValueError:
20882089
# If range creation fails - ignore that search parameter
2089-
pass
2090+
pass
20902091
elif isinstance(propclass, Interval):
20912092
# filter using the __<prop>_int__ column
20922093
if isinstance(v, type([])):
@@ -2105,7 +2106,7 @@ def filter(self, search_matches, filterspec, sort=(None,None),
21052106
args.append(date_rng.to_value.as_seconds())
21062107
except ValueError:
21072108
# If range creation fails - ignore that search parameter
2108-
pass
2109+
pass
21092110
else:
21102111
if isinstance(v, type([])):
21112112
s = ','.join([a for x in v])
@@ -2384,7 +2385,7 @@ def import_list(self, propnames, proplist):
23842385
if not self.hasnode(newid):
23852386
self.db.addnode(self.classname, newid, d) # insert
23862387
else:
2387-
self.db.setnode(self.classname, newid, d) # update
2388+
self.db.setnode(self.classname, newid, d) # update
23882389

23892390
# retire?
23902391
if retire:
@@ -2427,7 +2428,7 @@ def export_journals(self):
24272428

24282429
def import_journals(self, entries):
24292430
'''Import a class's journal.
2430-
2431+
24312432
Uses setjournal() to set the journal for each item.'''
24322433
properties = self.getprops()
24332434
d = {}

0 commit comments

Comments
 (0)