blib/lib/DB/Introspector/Util/RelInspect.pm

filter: Statementstmt 25.0% 13 / 52 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 17 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 57.1% 4 / 7 Podpod 50.0% 1 / 2 totaltotal 18.3% 18 / 98 CC 16 SCAR 41.3
CC
16
Cov
16%
find_paths_between_two_tables
110.0
find_mapped_paths_between_tables
42.0
_instance
6.0
CRAP 62.2
↑ Summary blib/lib/DB/Introspector/SQLGen/TypeMapper.pm »
1 package DB::Introspector::Util::RelInspect;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use DB::Introspector::ForeignKeyPath;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use DB::Introspector::MappedPath;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use vars qw( $SINGLETON );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 0 ▶sub _instance {
Subroutine _instance: not called CC=2 SCAR=17.9
10 0 my $class = shift;
11 0 ▶ $SINGLETON ||= bless(\$class, $class);
Condition0%0/2
$DB::Introspector::Util::RelInspect::SINGLETON ||= bless(\$class, $class)
l!l
00
MC/DC0%0/1
$DB::Introspector::Util::RelInspect::SINGLETON ||= bless(\$class, $class)
$DB::Introspector::Util::RelInspect::SINGLETON
Truth table0%0/2
A
A= $DB::Introspector::Util::RelInspect::SINGLETON
Aresult
11
00
12 0 return $SINGLETON;
13 }
14  
15 0 ▶sub find_mapped_paths_between_tables {
Subroutine find_mapped_paths_between_tables: not called CC=6 SCAR=37.4
Pod documented
16 0 my $class = shift;
17 0 my $root_table = shift;
18 0 my $child_table = shift;
19 0 ▶ my $path = shift || new DB::Introspector::MappedPath();
Condition0%0/3
shift() || 'DB::Introspector::MappedPath'->new
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || 'DB::Introspector::MappedPath'->new
shift() 'DB::Introspector::MappedPath'->new
Truth table0%0/3
A || B
A= shift()B= 'DB::Introspector::MappedPath'->new
ABresult
1X1
011
000
20 0 ▶ my $path_list = shift || [];
Condition0%0/2
shift() || []
l!l
00
MC/DC0%0/1
shift() || []
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
21  
22 0 ▶ if( $root_table->name eq $child_table->name ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($root_table->name eq $child_table->name) 0 0 0
23 0 unshift(@$path_list, $path);
24 0 return [];
25 }
26  
27 0 foreach my $foreign_key ($root_table->dependencies) {
28 0 ▶ next if($foreign_key->local_table->name
Branch: 1 branch
BranchTrueFalseTotal
if $foreign_key->local_table->name eq $foreign_key->foreign_table->name 0 0 0
29 eq $foreign_key->foreign_table->name);
30 0 my $internal_path = $path->clone();
31 0 $internal_path->append_foreign_key($foreign_key);
32 0 $class->find_mapped_paths_between_tables( $foreign_key->local_table,
33 $child_table,
34 $internal_path,
35 $path_list );
36 }
37  
38 0 return $path_list;
39 }
40  
41 0 ▶sub find_paths_between_two_tables {
Subroutine find_paths_between_two_tables: not called CC=10 SCAR=47.0
Pod undocumented
42 0 my $class = shift;
43 0 my $table_a = shift;
44 0 my $table_b = shift;
45 0 my $stop_at_first_contact = shift;
46  
47 0 ▶ my $visited = shift || {};
Condition0%0/2
shift() || {}
l!l
00
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
48 0 my $path = shift;
49 0 ▶ my $path_list = shift || [];
Condition0%0/2
shift() || []
l!l
00
MC/DC0%0/1
shift() || []
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
50  
51 0 ▶ if( $table_a->name eq $table_b->name && defined($path)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($table_a->name eq $table_b->name and defined $path) 0 0 0
Condition0%0/3
$table_a->name eq $table_b->name and defined $path
!ll&&!rl&&r
000
MC/DC0%0/2
$table_a->name eq $table_b->name and defined $path
$table_a->name eq $table_b->name defined $path
Truth table0%0/3
A and B
A= $table_a->name eq $table_b->nameB= defined $path
ABresult
0X0
100
111
52 0 push(@$path_list, $path);
53 0 ▶ return $path_list if($stop_at_first_contact);
Branch: 1 branch
BranchTrueFalseTotal
if $stop_at_first_contact 0 0 0
54 }
55  
56 0 ▶ $path ||= new DB::Introspector::ForeignKeyPath;
Condition0%0/3
$path ||= "DB::Introspector::ForeignKeyPath"->new
l!l&&r!l&&!r
000
MC/DC0%0/2
$path ||= "DB::Introspector::ForeignKeyPath"->new
$path "DB::Introspector::ForeignKeyPath"->new
Truth table0%0/3
A ||= B
A= $pathB= "DB::Introspector::ForeignKeyPath"->new
ABresult
1X1
011
000
57  
58 0 ▶ return $path_list if( $visited->{$table_a->name} );
Branch: 1 branch
BranchTrueFalseTotal
if $$visited{$table_a->name} 0 0 0
59 0 local $visited->{$table_a->name} = 1;
60  
61 0 foreach my $foreign_key ( $table_a->foreign_keys ) {
62 0 my $internal_path = $path->clone();
63 0 $internal_path->append_foreign_key($foreign_key);
64 0 $class->find_paths_between_two_tables( $foreign_key->foreign_table,
65 $table_b,
66 $stop_at_first_contact,
67 $visited,
68 $internal_path,
69 $path_list );
70 }
71  
72  
73 0 foreach my $foreign_key ( $table_a->dependencies ) {
74 0 my $internal_path = $path->clone();
75 0 $internal_path->append_foreign_key($foreign_key);
76 0 $class->find_paths_between_two_tables( $foreign_key->local_table,
77 $table_b,
78 $stop_at_first_contact,
79 $visited,
80 $internal_path,
81 $path_list );
82 }
83  
84  
85 0 return $path_list;
86 }
87  
88  
89 1 1;
90 __END__
↑ Summary blib/lib/DB/Introspector/SQLGen/TypeMapper.pm »