X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Debbugs%2FDB%2FResultSet%2FSrcVer.pm;fp=Debbugs%2FDB%2FResultSet%2FSrcVer.pm;h=254816cb6f9a342a4943769da59c4810cb595098;hb=53c435119200ab9b1c2538a96b8374c51a078855;hp=0000000000000000000000000000000000000000;hpb=0e8f07fda6e40b5967d9c6b28b3200db22766343;p=debbugs.git diff --git a/Debbugs/DB/ResultSet/SrcVer.pm b/Debbugs/DB/ResultSet/SrcVer.pm new file mode 100644 index 0000000..254816c --- /dev/null +++ b/Debbugs/DB/ResultSet/SrcVer.pm @@ -0,0 +1,50 @@ +# This module is part of debbugs, and is released +# under the terms of the GPL version 2, or any later version. See the +# file README and COPYING for more information. +# Copyright 2017 by Don Armstrong . +use utf8; +package Debbugs::DB::ResultSet::SrcVer; + +=head1 NAME + +Debbugs::DB::ResultSet::SrcVer - Source Version association + +=head1 SYNOPSIS + + + +=head1 DESCRIPTION + + + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::ResultSet'; + +use Debbugs::DB::Util qw(select_one); + + +sub get_src_ver_id { + my ($self,$src_pkg_id,$src_ver,$maint_id) = @_; + return $self->result_source->schema->storage-> + dbh_do(sub { + my ($s,$dbh,$src_pkg_id,$src_ver,$maint_id) = @_; + return select_one($dbh,<<'SQL', +INSERT INTO src_ver (src_pkg,ver,maintainer) + VALUES (?,?,?) ON CONFLICT (src_pkg,ver) DO + UPDATE SET maintainer = ? + RETURNING id; +SQL + $src_pkg_id,$src_ver, + $maint_id,$maint_id); + }, + $src_pkg_id,$src_ver,$maint_id + ); +} + +1; + +__END__