1 # This module is part of debbugs, and is released
2 # under the terms of the GPL version 2, or any later version. See the
3 # file README and COPYING for more information.
4 # Copyright 2017 by Don Armstrong <don@donarmstrong.com>.
6 package Debbugs::DB::ResultSet::BinPkg;
10 Debbugs::DB::ResultSet::BinPkg - Source Package
25 use base 'DBIx::Class::ResultSet';
27 use Debbugs::DB::Util qw(select_one);
29 sub bin_pkg_and_ver_in_suite {
30 my ($self,$suite) = @_;
31 $suite = $self->result_source->schema->
32 resultset('Suite')->get_suite_id($suite);
34 $self->search_rs({'bin_associations.suite' => $suite,
36 {join => {bin_vers => ['bin_associations','arch']},
37 result_class => 'DBIx::Class::ResultClass::HashRefInflator',
38 columns => [qw(me.pkg bin_vers.ver arch.arch bin_associations.id)]
46 return $self->result_source->schema->storage->
48 my ($s,$dbh,$bin_pkg) = @_;
49 return select_one($dbh,<<'SQL',$bin_pkg);
50 SELECT id FROM bin_pkg where pkg = ?;
56 sub get_or_create_bin_pkg_id {
58 return $self->result_source->schema->storage->
60 my ($s,$dbh,$bin_pkg) = @_;
61 return select_one($dbh,<<'SQL',$bin_pkg,$bin_pkg);
63 INSERT INTO bin_pkg (pkg)
64 VALUES (?) ON CONFLICT (pkg) DO NOTHING RETURNING id
68 SELECT id FROM bin_pkg where pkg = ?