Skip to content

Commit d0ebf13

Browse files
committed
Fix Database.find for rev_multilink
1 parent 3b7d870 commit d0ebf13

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

roundup/backends/rdbms_common.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2263,18 +2263,23 @@ def find(self, **propspec):
22632263
nn = p.nodeid_name
22642264
cn = '_' + self.classname
22652265
ret = ''
2266-
if p.rev_property and isinstance(p.rev_property, Link):
2267-
ret = 'and %s.__retired__=%s ' % (tn, a)
2268-
allvalues += (0, )
2266+
dis = ''
2267+
ord = ''
2268+
if p.rev_property:
2269+
if isinstance(p.rev_property, Link):
2270+
ret = 'and %s.__retired__=%s ' % (tn, a)
2271+
allvalues += (0, )
2272+
dis = 'distinct '
2273+
ord = ' order by %s.id' % cn
22692274
if type(values) is type(''):
22702275
allvalues += (values,)
22712276
s = a
22722277
else:
22732278
allvalues += tuple(values)
22742279
s = ','.join([a]*len(values))
2275-
sql.append("""select %s.id from %s, %s where %s.__retired__=%s
2276-
%sand %s.id = %s.%s and %s.%s in (%s)"""%(cn, cn, tn, cn,
2277-
a, ret, cn, tn, nn, tn, ln, s))
2280+
sql.append("""select %s%s.id from %s, %s where %s.__retired__=%s
2281+
%sand %s.id = %s.%s and %s.%s in (%s)%s"""%(dis, cn, cn,
2282+
tn, cn, a, ret, cn, tn, nn, tn, ln, s, ord))
22782283

22792284
if not sql:
22802285
return []

0 commit comments

Comments
 (0)