]> git.donarmstrong.com Git - debbugs.git/blob - Debbugs/DB/ResultSet/SrcVer.pm
254816cb6f9a342a4943769da59c4810cb595098
[debbugs.git] / Debbugs / DB / ResultSet / SrcVer.pm
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>.
5 use utf8;
6 package Debbugs::DB::ResultSet::SrcVer;
7
8 =head1 NAME
9
10 Debbugs::DB::ResultSet::SrcVer - Source Version association
11
12 =head1 SYNOPSIS
13
14
15
16 =head1 DESCRIPTION
17
18
19
20 =cut
21
22 use strict;
23 use warnings;
24
25 use base 'DBIx::Class::ResultSet';
26
27 use Debbugs::DB::Util qw(select_one);
28
29
30 sub get_src_ver_id {
31     my ($self,$src_pkg_id,$src_ver,$maint_id) = @_;
32     return $self->result_source->schema->storage->
33         dbh_do(sub {
34                    my ($s,$dbh,$src_pkg_id,$src_ver,$maint_id) = @_;
35                    return select_one($dbh,<<'SQL',
36 INSERT INTO src_ver (src_pkg,ver,maintainer)
37    VALUES (?,?,?) ON CONFLICT (src_pkg,ver) DO
38      UPDATE SET maintainer = ?
39    RETURNING id;
40 SQL
41                                      $src_pkg_id,$src_ver,
42                                      $maint_id,$maint_id);
43                },
44                $src_pkg_id,$src_ver,$maint_id
45               );
46 }
47
48 1;
49
50 __END__