DBIx/Class/Relationship/HasMany.pm

filter: Statementstmt 100% 28 / 28 Branchbran 100% 8 / 8 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 93.6% 44 / 47 CC 6 SCAR 13.9
CC
6
Cov
97%
has_many
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.0
« DBIx/Class/Storage/DBI/Informix.pm ↑ Summary DBIx/Class/Storage/DBI/NoBindVars.pm »
1 package # hide from PAUSE
2 DBIx::Class::Relationship::HasMany;
3  
4 308 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 308 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 308 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 308 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 308 our %_pod_inherit_config =
10 (
11 class_map => { 'DBIx::Class::Relationship::HasMany' => 'DBIx::Class::Relationship' }
12 );
13  
14 sub has_many {
15 10495 ▶ my ($class, $rel, $f_class, $cond, $attrs) = @_;
Subroutine has_many: called CC=6 SCAR=17.9
Pod undocumented
16  
17 10495 ▶ unless (ref $cond) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $cond) 6475 4020 10495
18  
19 6475 my $pri = $class->result_source_instance->_single_pri_col_or_die;
20  
21 6475 my ($f_key,$guess);
22 6475 ▶ if (defined $cond && length $cond) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cond and length $cond) { } 4319 2156 6475
Condition66%2/3
defined $cond and length $cond
!ll&&!rl&&r
215604319
MC/DC50%1/2
defined $cond and length $cond
defined $cond length $cond
Truth table66%2/3
A and B
A= defined $condB= length $cond
ABresult
0X0
100
111
23 4319 $f_key = $cond;
24 4319 $guess = "caller specified foreign key '$f_key'";
25 } else {
26 2156 $class =~ /([^\:]+)$/; # match is safe - $class can't be ''
27 2156 $f_key = lc $1; # go ahead and guess; best we can do
28 2156 $guess = "using our class name '$class' as foreign key source";
29 }
30  
31 # FIXME - this check needs to be moved to schema-composition time...
32 # # only perform checks if the far side appears already loaded
33 # if (my $f_rsrc = try { $f_class->result_source_instance } ) {
34 # $class->throw_exception(
35 # "No such column '$f_key' on foreign class ${f_class} ($guess)"
36 # ) if !$f_rsrc->has_column($f_key);
37 # }
38  
39 6475 $cond = { "foreign.${f_key}" => "self.${pri}" };
40 }
41  
42 10495 ▶ my $default_cascade = ref $cond eq 'CODE' ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
ref $cond eq 'CODE' ? : 1848 8647 10495
43  
44 $class->add_relationship($rel, $f_class, $cond, {
45 accessor => 'multi',
46 join_type => 'LEFT',
47 cascade_delete => $default_cascade,
48 cascade_copy => $default_cascade,
49 10495 ▶ %{$attrs||{}}
Branch: 1 branch
BranchTrueFalseTotal
$attrs or {} 8647 1848 10495
50 });
51 }
52  
53 308 1;
« DBIx/Class/Storage/DBI/Informix.pm ↑ Summary DBIx/Class/Storage/DBI/NoBindVars.pm »