| 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)
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
| |||||||||||||||||||||||||||||
| 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
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
| |||||||||||||||||||||||||||||
| 20 | 0 | ▶ | my $path_list = shift || []; | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() || []
MC/DC0%0/1
shift() || []
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | if( $root_table->name eq $child_table->name ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 48 | 0 | my $path = shift; | |||||||||||||||||||||||||||
| 49 | 0 | ▶ | my $path_list = shift || []; | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() || []
MC/DC0%0/1
shift() || []
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if( $table_a->name eq $table_b->name && defined($path)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$table_a->name eq $table_b->name and defined $path
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
| |||||||||||||||||||||||||||||
| 52 | 0 | push(@$path_list, $path); | |||||||||||||||||||||||||||
| 53 | 0 | ▶ | return $path_list if($stop_at_first_contact); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | ▶ | $path ||= new DB::Introspector::ForeignKeyPath; | ||||||||||||||||||||||||||
|
Condition0%0/3
$path ||= "DB::Introspector::ForeignKeyPath"->new
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
| |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | ▶ | return $path_list if( $visited->{$table_a->name} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||