- originosuite_id = db_access.get_suite_id(originosuite);
- if originosuite_id == -1:
- utils.fubar("Suite '%s' not recognised." % (originosuite));
-
- component_id = db_access.get_component_id(component);
- if component_id == -1:
- utils.fubar("Component '%s' not recognised." % (component));
-
- type_id = db_access.get_override_type_id(type);
- if type_id == -1:
- utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (type));
- dsc_type_id = db_access.get_override_type_id("dsc");
- deb_type_id = db_access.get_override_type_id("deb")
-
- source_priority_id = db_access.get_priority_id("source")
-
- if type == "deb" or type == "udeb":
- packages = {};
- q = projectB.query("""
-SELECT b.package FROM binaries b, bin_associations ba, files f,
- location l, component c
- WHERE b.type = '%s' AND b.id = ba.bin AND f.id = b.file AND l.id = f.location
- AND c.id = l.component AND ba.suite IN (%s) AND c.id = %s
-""" % (type, ",".join(map(str,affected_suites)), component_id));
- for i in q.getresult():
- packages[i[0]] = 0;
-
- src_packages = {};
- q = projectB.query("""
-SELECT s.source FROM source s, src_associations sa, files f, location l,
- component c
- WHERE s.id = sa.source AND f.id = s.file AND l.id = f.location
- AND c.id = l.component AND sa.suite IN (%s) AND c.id = %s
-""" % (",".join(map(str,affected_suites)), component_id));
- for i in q.getresult():
- src_packages[i[0]] = 0;
+ oo = get_suite(originosuite, session)
+ if oo is None:
+ utils.fubar("Suite '%s' not recognised." % (originosuite))
+ originosuite_id = oo.suite_id
+
+ c = get_component(component, session)
+ if c is None:
+ utils.fubar("Component '%s' not recognised." % (component))
+ component_id = c.component_id
+
+ ot = get_override_type(otype, session)
+ if ot is None:
+ utils.fubar("Type '%s' not recognised. (Valid types are deb, udeb and dsc)" % (otype))
+ type_id = ot.overridetype_id
+ dsc_type_id = get_override_type("dsc", session).overridetype_id
+
+ source_priority_id = get_priority("source", session).priority_id
+
+ if otype == "deb" or otype == "udeb":
+ packages = {}
+ # TODO: Fix to use placeholders (check how to with arrays)
+ q = session.execute("""
+SELECT b.package
+ FROM binaries b
+ JOIN bin_associations ba ON b.id = ba.bin
+ JOIN suite ON ba.suite = suite.id
+ JOIN files_archive_map af ON b.file = af.file_id AND suite.archive_id = af.archive_id
+ WHERE b.type = :otype AND ba.suite IN (%s) AND af.component_id = :component_id
+""" % (",".join([ str(i) for i in affected_suites ])), {'otype': otype, 'component_id': component_id})
+ for i in q.fetchall():
+ packages[i[0]] = 0
+
+ src_packages = {}
+ q = session.execute("""
+SELECT s.source FROM source s
+ JOIN src_associations sa ON s.id = sa.source
+ JOIN suite ON sa.suite = suite.id
+ JOIN files_archive_map af ON s.file = af.file_id AND suite.archive_id = af.archive_id
+ WHERE sa.suite IN (%s) AND af.component_id = :component_id
+""" % (",".join([ str(i) for i in affected_suites])), {'component_id': component_id})
+ for i in q.fetchall():
+ src_packages[i[0]] = 0