blib/lib/DBIx/Class/Row/SQLA2Support.pm

filter: Statementstmt 100% 25 / 25 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 2 / 2 totaltotal 100% 38 / 38 SCAR 13.9
CC
4
Cov
100%
new
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.0
« blib/lib/SQL/Abstract/Plugin/CaseExpr.pm ↑ Summary blib/lib/DBIx/Class/ResultSet/SQLA2Support.pm »
1 package DBIx::Class::Row::SQLA2Support;
2 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use parent 'DBIx::Class::Row';
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 sub new {
7 3 ▶ my ($class, $attrs) = @_;
Subroutine new: called CC=4 SCAR=13.9
Pod documented
8 3 my $on_conflict = delete $attrs->{-on_conflict};
9 3 ▶ my $to_upsert = 1 if delete $attrs->{-upsert};
Branch: 1 branch
BranchTrueFalseTotal
if delete $attrs->{"-upsert"} 1 2 3
10 3 my $new = $class->next::method($attrs);
11 3 ▶ $new->{_sqla2_attrs} = { on_conflict => $on_conflict } if defined $on_conflict;
Branch: 1 branch
BranchTrueFalseTotal
if defined $on_conflict 2 1 3
12 3 ▶ if ($to_upsert) {
Branch: 1 branch
BranchTrueFalseTotal
if ($to_upsert) 1 2 3
13 1 $to_upsert = {%$attrs};
14 1 my @pks = $new->result_source->primary_columns;
15 1 delete @$to_upsert{@pks};
16 $new->{_sqla2_attrs}
17 = {
18 1 on_conflict => { -target => \@pks, -set => { map +($_ => { -ident => "excluded.$_" }), keys %$to_upsert } } };
19 }
20  
21 3 return $new;
22 }
23  
24 sub insert {
25 3 ▶ my ($self, @args) = @_;
Subroutine insert: called CC=1 SCAR=0.0
Pod documented
26 3 my $extras = delete $self->{_sqla2_attrs};
27 # this should allow relations to fail if they don't have a on_conflict defined
28 3 local $self->result_source->storage->sql_maker->{_sqla2_insert_attrs} = $extras;
29 3 $self->next::method(@args);
30 }
31  
32 5 1
« blib/lib/SQL/Abstract/Plugin/CaseExpr.pm ↑ Summary blib/lib/DBIx/Class/ResultSet/SQLA2Support.pm »