diff roundup/backends/rdbms_common.py @ 6403:9957d8d10783

Tests and bug-fix for issue2551119 .. and some other failing tests I came up with when trying to reproduce the problem of the issue.
author Ralf Schlatterbeck <rsc@runtux.com>
date Mon, 10 May 2021 16:19:37 +0200
parents 619807d9a2df
children 7b1b6dffc7ed
line wrap: on
line diff
--- a/roundup/backends/rdbms_common.py	Sat May 08 18:13:20 2021 +0200
+++ b/roundup/backends/rdbms_common.py	Mon May 10 16:19:37 2021 +0200
@@ -2585,21 +2585,23 @@
                     tn = propclass.table_name
                     nid = propclass.nodeid_name
                     lid = propclass.linkid_name
+                    frum.append(tn)
+                    if p.children or p.need_child_retired:
+                        frum.append('_%s as _%s' % (cn, ln))
+                        where.append('%s.%s=_%s.id'%(tn, lid, ln))
+                        if p.need_child_retired:
+                            where.append('_%s.__retired__=0'%(ln))
+                    # Note: need the where-clause if p has
+                    # children that compute additional restrictions
+                    if  (not p.has_values
+                         or (not isinstance(v, type([])) and v != '-1')
+                         or p.children):
+                        where.append('_%s.id=%s.%s'%(pln, tn, nid))
                     if v in ('-1', ['-1'], []):
                         # only match rows that have count(linkid)=0 in the
                         # corresponding multilink table)
                         where.append(self._subselect(p))
                     else:
-                        frum.append(tn)
-
-                        if p.children or p.need_child_retired:
-                            frum.append('_%s as _%s' % (cn, ln))
-                            where.append('%s.%s=_%s.id'%(tn, lid, ln))
-                            if p.need_child_retired:
-                                where.append('_%s.__retired__=0'%(ln))
-
-                        if not p.has_values or not isinstance(v, type([])):
-                            where.append('_%s.id=%s.%s'%(pln, tn, nid))
                         if p.has_values:
                             if isinstance(v, type([])):
                                 # The where-clause above is conditionally

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