Coverage for dak/dakdb/update106.py: 100%
1 statements
« prev ^ index » next coverage.py v7.6.0, created at 2026-08-03 16:46 +0000
« prev ^ index » next coverage.py v7.6.0, created at 2026-08-03 16:46 +0000
1"""
2new views binary_component, source_component and package_list
4@contact: Debian FTP Master <ftpmaster@debian.org>
5@copyright: 2014, Ansgar Burchardt <ansgar@debian.org>
6@license: GNU General Public License version 2 or later
7"""
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation; either version 2 of the License, or
12# (at your option) any later version.
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
19# You should have received a copy of the GNU General Public License
20# along with this program; if not, write to the Free Software
21# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23################################################################################
25statements = [
26 """
27CREATE OR REPLACE VIEW source_component AS
28SELECT
29 s.id AS source_id,
30 sa.suite AS suite_id,
31 af.component_id AS component_id
32FROM source s
33JOIN src_associations sa ON s.id = sa.source
34JOIN suite ON sa.suite = suite.id
35JOIN files_archive_map af ON s.file = af.file_id AND suite.archive_id = af.archive_id
36""",
37 """
38COMMENT ON VIEW source_component IS 'Map (source_id, suite_id) to the component(s) that the source is included in. Note that this view might return more components than expected as we can only query the component for (source_id, archive_id).'
39""",
40 "GRANT SELECT ON source_component TO PUBLIC",
41 """
42CREATE OR REPLACE VIEW binary_component AS
43SELECT
44 b.id AS binary_id,
45 ba.suite AS suite_id,
46 af.component_id AS component_id
47FROM binaries b
48JOIN bin_associations ba ON b.id = ba.bin
49JOIN suite ON ba.suite = suite.id
50JOIN files_archive_map af ON b.file = af.file_id AND suite.archive_id = af.archive_id
51""",
52 """
53COMMENT ON VIEW binary_component IS 'Map (binary_id, suite_id) to the component(s) that the binary is included in. Note that this view might return more components than expected as we can only query the component for (binary_id, archive_id).'
54""",
55 "GRANT SELECT ON binary_component TO PUBLIC",
56 """
57CREATE OR REPLACE VIEW package_list AS
58SELECT
59 tmp.package,
60 tmp.version,
61 tmp.source,
62 tmp.source_version,
63 suite.suite_name AS suite,
64 archive.name AS archive,
65 component.name AS component,
66 CASE component.name
67 WHEN 'main' THEN suite.suite_name
68 ELSE CONCAT(suite.suite_name, '/', component.name)
69 END AS display_suite,
70 tmp.architecture_is_source,
71 tmp.architecture,
72 tmp.type
73FROM
74 (SELECT
75 s.source AS package,
76 s.version AS version,
77 s.source AS source,
78 s.version AS source_version,
79 sa.suite AS suite_id,
80 TRUE AS architecture_is_source,
81 'source' AS architecture,
82 'dsc' AS type,
83 sc.component_id
84 FROM source s
85 JOIN src_associations sa ON s.id = sa.source
86 JOIN source_component sc ON s.id = sc.source_id AND sa.suite = sc.suite_id
87 UNION
88 SELECT
89 b.package AS package,
90 b.version AS version,
91 s.source AS source,
92 s.version AS source_version,
93 ba.suite AS suite_id,
94 FALSE AS architecture_is_source,
95 a.arch_string AS architecture,
96 b.type AS type,
97 bc.component_id
98 FROM binaries b
99 JOIN source s ON b.source = s.id
100 JOIN architecture a ON b.architecture = a.id
101 JOIN bin_associations ba ON b.id = ba.bin
102 JOIN binary_component bc ON b.id = bc.binary_id AND ba.suite = bc.suite_id) AS tmp
103 JOIN suite ON tmp.suite_id = suite.id
104 JOIN archive ON suite.archive_id = archive.id
105 JOIN component ON tmp.component_id = component.id
106""",
107 "GRANT SELECT ON package_list TO PUBLIC",
108]