Merge lp:~thumper/launchpad/blueprint-dependencies into lp:launchpad
Proposed by
Tim Penhey
Status: | Merged |
---|---|
Approved by: | Tim Penhey |
Approved revision: | no longer in the source branch. |
Merged at revision: | 12594 |
Proposed branch: | lp:~thumper/launchpad/blueprint-dependencies |
Merge into: | lp:launchpad |
Diff against target: | 0 lines |
To merge this branch: | bzr merge lp:~thumper/launchpad/blueprint-dependencies |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Robert Collins (community) | Approve | ||
Review via email: mp+53191@code.launchpad.net |
Commit message
[r=lifeless][bug=707111][incr] Implement the all_deps and all_blocked attributes of blueprints using a recursive database query rather than a recursive algorithm.
Description of the change
Implement the all_deps and all_blocked attributes of blueprints using a recursive database query rather than a recursive algorithm. Add some tests too.
Part of the work to allow any blueprint to be searched for when adding dependencies.
To post a comment you must log in.
So this is fine, I have a suggestion to make it better: blocked_ query(spec) : pendency sd, blocked b, specification s dependent_ query(spec) : pendency sd, dependencies d, specification s
+def recursive_
19 + return """
20 + RECURSIVE blocked(id) AS (
21 + SELECT %s
22 + UNION
23 + SELECT s.id
24 + FROM specificationde
25 + WHERE sd.dependency = b.id
26 + AND s.id = sd.specification
27 + )""" % spec.id
28 +
29 +
30 +def recursive_
31 + return """
32 + RECURSIVE dependencies(id) AS (
33 + SELECT %s
34 + UNION
35 + SELECT s.id
36 + FROM specificationde
37 + WHERE sd.specification = d.id
38 + AND s.id = sd.dependency
39 + )""" % spec.id
These queries do not use s other than the s.id they select which is also sd.dependency/ sd.specificatio n. So I would substitute and drop s to get blocked_ query(spec) : pendency sd, blocked b dependent_ query(spec) : pendency sd, dependencies d
+def recursive_
19 + return """
20 + RECURSIVE blocked(id) AS (
21 + SELECT %s
22 + UNION
23 + SELECT sd.specification
24 + FROM specificationde
25 + WHERE sd.dependency = b.id
27 + )""" % spec.id
28 +
29 +
30 +def recursive_
31 + return """
32 + RECURSIVE dependencies(id) AS (
33 + SELECT %s
34 + UNION
35 + SELECT sd.dependency
36 + FROM specificationde
37 + WHERE sd.specification = d.id
39 + )""" % spec.id
as the only thing returned is the id, this won't affect your other branch.