| 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
| |||||||||||||||||||||||||||||
| 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
Condition66%2/3
defined $cond and length $cond
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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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 || {}
MC/DC100%1/1
$attrs || {}
$attrs
Truth table100%2/2
A
A= $attrs
| |||||||||||||||||||||||||||||
| 51 | }); | ||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 379 | 1; | |||||||||||||||||||||||||||