DBIx/Class/Relationship/HasMany.pm

filter: Statementstmt 100% 28 / 28 Branchbran 100% 6 / 6 Conditioncond 80.0% 4 / 5 MC/DCmcdc 66.6% 2 / 3 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 1 totaltotal 93.7% 45 / 48 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/CDBICompat/Pager.pm »
1 package # hide from PAUSE
2 DBIx::Class::Relationship::HasMany;
3  
4 379 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 379 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 379 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 379 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 379 our %_pod_inherit_config =
10 (
11 class_map => { 'DBIx::Class::Relationship::HasMany' => 'DBIx::Class::Relationship' }
12 );
13  
14 12333 ▶sub has_many {
Subroutine has_many: called CC=6 SCAR=17.9
Pod undocumented
15 12333 my ($class, $rel, $f_class, $cond, $attrs) = @_;
16  
17 12333 ▶ unless (ref $cond) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $cond) 7337 4996 12333
18  
19 7337 my $pri = $class->result_source_instance->_single_pri_col_or_die;
20  
21 7337 my ($f_key,$guess);
22 7337 ▶ if (defined $cond && length $cond) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $cond and length $cond) { } 4950 2387 7337
Condition66%2/3
defined $cond and length $cond
!ll&&!rl&&r
238704950
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 4950 $f_key = $cond;
24 4950 $guess = "caller specified foreign key '$f_key'";
25 } else {
26 2387 $class =~ /([^\:]+)$/; # match is safe - $class can't be ''
27 2387 $f_key = lc $1; # go ahead and guess; best we can do
28 2387 $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 7337 $cond = { "foreign.${f_key}" => "self.${pri}" };
40 }
41  
42 12333 ▶ my $default_cascade = ref $cond eq 'CODE' ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
ref $cond eq 'CODE' ? : 2696 9637 12333
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 is_depends_on => 0,
50 12333 ▶ %{$attrs||{}}
Condition100%2/2
$attrs || {}
l!l
199910334
MC/DC100%1/1
$attrs || {}
$attrs
Truth table100%2/2
A
A= $attrs
Aresult
11
00
51 });
52 }
53  
54 379 1;
« DBIx/Class/Storage/DBI/Informix.pm ↑ Summary DBIx/Class/CDBICompat/Pager.pm »