Merge lp:~adeuring/launchpad/bug-909318 into lp:launchpad
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Approved by: | Abel Deuring on 2012-01-03 | ||||
| Approved revision: | no longer in the source branch. | ||||
| Merged at revision: | 14629 | ||||
| Proposed branch: | lp:~adeuring/launchpad/bug-909318 | ||||
| Merge into: | lp:launchpad | ||||
| Diff against target: |
155 lines (+42/-21) 2 files modified
lib/lp/bugs/model/bugtask.py (+16/-14) lib/lp/bugs/tests/test_bugtask_search.py (+26/-7) |
||||
| To merge this branch: | bzr merge lp:~adeuring/launchpad/bug-909318 | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Graham Binns (community) | code | 2012-01-03 | Approve on 2012-01-03 |
|
Review via email:
|
|||
Commit Message
[r=gmb][bug=909318] bug fix: invalid SQL query when a bugtask search consisting of a UNION of two or more sub-.queries is ordered by a value that requires to join another table.
Description of the Change
This branch fixes bug 909318: Can’t order bugs by reporter.
The cause is a bug in the SQL query generated by BugTaskSet.
when the *args passed to _search are not empty (i.e., when the query
is a UNION of several SELECTs), and when the ordering of the result
set requires to JOIN another table. In this case, the query looked
roughly like:
SELECT BugTask.* FROM (
SELECT BugTask.* JOIN SortTable ON ... WHERE condition1
UNION SELECT BugTask.* JOIN SortTable ON ... WHERE condition2
UNION ...)
ORDER BY SortTable.
Joining the sort table in the different term of the UNION operator
is obviously nonsense.
The expression "JOIN SortTable ON ..." was added in
BugTaskSet.
I moved this to BugTaskSet.
returns (orderby_arg, extra_joins), where extra_joins is a sequence
of tuples (join_table, join_expression), as can be passed to
BugTaskSet.
to which SELECT the ordering related JOINs are added.
tests:
./bin/test bugs -vvt test_bugtask_
Demo/QA: Visit the bug page of any person/team and sort the
bugs by assignee, reporter or milestone.
no lint

139 + def test_two_ param_objects_ sorting_ needs_extra_ join(self) :
This needs a comment stating the expected behaviour you're testing for.