Skip to content

Commit ed6ead0

Browse files
committed
Fix bug in SQL generation
Fix subtle bug when sorting by a Link that contains a Multilink from which we also search for an attribute. In that case the LEFT OUTER JOIN clause was missing in generated SQL.
1 parent 43bb773 commit ed6ead0

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ Fixed:
4343
(James Mack)
4444
- Fix String search with special SQL wildcard characters in LIKE/ILIKE
4545
clause and add testcase (Ralf Schlatterbeck)
46+
- Fix subtle bug when sorting by a Link that contains a Multilink from
47+
which we also search for an attribute. In that case the LEFT OUTER
48+
JOIN clause was missing in generated SQL. (Ralf Schlatterbeck)
4649

4750

4851
2013-07-06: 1.5.0

roundup/hyperdb.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,9 @@ def compute_sort_done(self, mlseen=False):
372372
('sort' in self.need_for) or all children have tree_sort_done set and
373373
sort_ids_needed unset: set self.tree_sort_done if one of the conditions
374374
holds. Also remove sort_ids_needed recursively once having seen a
375-
Multilink.
375+
Multilink that is used for sorting.
376376
"""
377-
if isinstance (self.propclass, Multilink):
377+
if isinstance (self.propclass, Multilink) and 'sort' in self.need_for:
378378
mlseen = True
379379
if mlseen:
380380
self.sort_ids_needed = False

test/db_test_base.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ def setupTracker(dirname, backend="anydbm"):
7373
return tracker
7474

7575
def setupSchema(db, create, module):
76-
status = module.Class(db, "status", name=String())
76+
mls = module.Class(db, "mls", name=String())
77+
mls.setkey("name")
78+
status = module.Class(db, "status", name=String(), mls=Multilink("mls"))
7779
status.setkey("name")
7880
priority = module.Class(db, "priority", name=String(), order=String())
7981
priority.setkey("name")
@@ -104,7 +106,9 @@ def setupSchema(db, create, module):
104106
password=password.Password('sekrit'))
105107
user.create(username="fred", roles='User',
106108
password=password.Password('sekrit'), address='[email protected]')
107-
status.create(name="unread")
109+
u1 = mls.create(name="unread_1")
110+
u2 = mls.create(name="unread_2")
111+
status.create(name="unread",mls=[u1, u2])
108112
status.create(name="in-progress")
109113
status.create(name="testing")
110114
status.create(name="resolved")
@@ -1280,6 +1284,14 @@ def testFilteringLink(self):
12801284
ae(filt(None, {a: ['-1', None]}, ('+','id'), grp), ['3','4'])
12811285
ae(filt(None, {a: ['1', None]}, ('+','id'), grp), ['1', '3','4'])
12821286

1287+
def testFilteringLinkSortSearchMultilink(self):
1288+
ae, filter, filter_iter = self.filteringSetup()
1289+
a = 'assignedto'
1290+
grp = (None, None)
1291+
for filt in filter, filter_iter:
1292+
ae(filt(None, {'status.mls': '1'}, ('+','status')), ['2','3'])
1293+
ae(filt(None, {'status.mls': '2'}, ('+','status')), ['2','3'])
1294+
12831295
def testFilteringMultilinkAndGroup(self):
12841296
"""testFilteringMultilinkAndGroup:
12851297
See roundup Bug 1541128: apparently grouping by something and

0 commit comments

Comments
 (0)