| 1 | package DB::Introspector::Base::Table; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | ▶ | use base qw( DB::Introspector::Base::Object ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 8 | 0 | my $class = shift; | |||||||||||||||||||
| 9 | 0 | my $name = shift; | |||||||||||||||||||
| 10 | 0 | my $owner = shift; | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 0 | ▶ | return bless({_name => $name, _owner=>$owner}, ref($class) || $class); | ||||||||||||||||||
|
Condition0%0/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table0%0/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||
| 13 | } | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 0 | ▶ | sub name { | ||||||||||||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 17 | 0 | my $self = shift; | |||||||||||||||||||
| 18 | 0 | return $self->{_name}; | |||||||||||||||||||
| 19 | } | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 0 | ▶ | sub owner { | ||||||||||||||||||
|
Subroutine
owner: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 22 | 0 | my $self = shift; | |||||||||||||||||||
| 23 | 0 | return $self->{_owner}; | |||||||||||||||||||
| 24 | } | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 0 | ▶ | sub indexes { | ||||||||||||||||||
|
Subroutine
indexes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 27 | 0 | my $self = shift; | |||||||||||||||||||
| 28 | 0 | die("indexes is not defined for ".(ref($self))); | |||||||||||||||||||
| 29 | } | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 0 | ▶ | sub columns { | ||||||||||||||||||
|
Subroutine
columns: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 32 | 0 | my $self = shift; | |||||||||||||||||||
| 33 | 0 | die("columns is not defined for ".(ref($self))); | |||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 0 | ▶ | sub primary_key { | ||||||||||||||||||
|
Subroutine
primary_key: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 37 | 0 | my $self = shift; | |||||||||||||||||||
| 38 | 0 | die("primary_key is not defined for ".(ref($self))); | |||||||||||||||||||
| 39 | } | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 0 | ▶ | sub primary_key_names { | ||||||||||||||||||
|
Subroutine
primary_key_names: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 42 | 0 | my $self = shift; | |||||||||||||||||||
| 43 | 0 | return map { $_->name; } $self->primary_key; | |||||||||||||||||||
| 44 | } | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 0 | ▶ | sub primary_key_column { | ||||||||||||||||||
|
Subroutine
primary_key_column: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 47 | 0 | my $self = shift; | |||||||||||||||||||
| 48 | 0 | my $column_name = shift; | |||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | 0 | ▶ | unless( $self->{primary_key_column_name_map} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 51 | 0 | my %columns; | |||||||||||||||||||
| 52 | 0 | foreach my $column ($self->primary_key) { | |||||||||||||||||||
| 53 | 0 | $columns{$column->name} = $column; | |||||||||||||||||||
| 54 | } | ||||||||||||||||||||
| 55 | 0 | $self->{primary_key_column_name_map} = \%columns; | |||||||||||||||||||
| 56 | } | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | 0 | return $self->{primary_key_column_name_map}{$column_name}; | |||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 0 | ▶ | sub is_primary_key_column { | ||||||||||||||||||
|
Subroutine
is_primary_key_column: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 63 | 0 | my $self = shift; | |||||||||||||||||||
| 64 | 0 | my $column = shift; | |||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | 0 | ▶ | my $local_column = $self->primary_key_column($column->name) | ||||||||||||||||||
|
Condition0%0/2
$self->primary_key_column($column->name) || (return 0)
MC/DC0%0/1
$self->primary_key_column($column->name) || (return 0)
$self->primary_key_column($column->name)
Truth table0%0/2
A
A= $self->primary_key_column($column->name)
| |||||||||||||||||||||
| 67 | || return 0; | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 0 | return ($local_column == $column); | |||||||||||||||||||
| 70 | } | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 0 | ▶ | sub is_primary_key_column_name { | ||||||||||||||||||
|
Subroutine
is_primary_key_column_name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 73 | 0 | my $self = shift; | |||||||||||||||||||
| 74 | 0 | my $column_name = shift; | |||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | 0 | return defined($self->primary_key_column($column_name)); | |||||||||||||||||||
| 77 | } | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 0 | ▶ | sub non_primary_key_columns { | ||||||||||||||||||
|
Subroutine
non_primary_key_columns: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 80 | 0 | my $self = shift; | |||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | 0 | return grep { !$self->is_primary_key_column($_) } $self->columns; | |||||||||||||||||||
| 83 | } | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | 0 | ▶ | sub non_primary_key_column_names { | ||||||||||||||||||
|
Subroutine
non_primary_key_column_names: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 86 | 0 | my $self = shift; | |||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | 0 | return map { $_->name; } $self->non_primary_key_columns; | |||||||||||||||||||
| 89 | } | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | 0 | ▶ | sub column_names { | ||||||||||||||||||
|
Subroutine
column_names: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 92 | 0 | my $self = shift; | |||||||||||||||||||
| 93 | 0 | return map { $_->name; } $self->columns; | |||||||||||||||||||
| 94 | } | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | 0 | ▶ | sub column { | ||||||||||||||||||
|
Subroutine
column: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 97 | 0 | my $self = shift; | |||||||||||||||||||
| 98 | 0 | my $name = shift; | |||||||||||||||||||
| 99 | |||||||||||||||||||||
| 100 | 0 | ▶ | unless( defined $self->{_columns} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 101 | 0 | $self->{_columns} = {}; | |||||||||||||||||||
| 102 | 0 | foreach my $column ($self->columns) { | |||||||||||||||||||
| 103 | 0 | $self->{_columns}{$column->name} = $column; | |||||||||||||||||||
| 104 | } | ||||||||||||||||||||
| 105 | } | ||||||||||||||||||||
| 106 | |||||||||||||||||||||
| 107 | 0 | return $self->{_columns}{$name}; | |||||||||||||||||||
| 108 | } | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | 0 | ▶ | sub foreign_keys { | ||||||||||||||||||
|
Subroutine
foreign_keys: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 111 | 0 | my $self = shift; | |||||||||||||||||||
| 112 | 0 | die("foreign_keys is not defined for ".(ref($self))); | |||||||||||||||||||
| 113 | # returns @ of foreign_keys | ||||||||||||||||||||
| 114 | } | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | 0 | ▶ | sub dependencies { | ||||||||||||||||||
|
Subroutine
dependencies: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 117 | 0 | my $self = shift; | |||||||||||||||||||
| 118 | 0 | die("dependencies is not defined for ".(ref($self))); | |||||||||||||||||||
| 119 | } | ||||||||||||||||||||
| 120 | |||||||||||||||||||||
| 121 | 0 | ▶ | sub foreign_key_names { | ||||||||||||||||||
|
Subroutine
foreign_key_names: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 122 | 0 | my $self = shift; | |||||||||||||||||||
| 123 | 0 | return map { $_->name; } $self->foreign_keys; | |||||||||||||||||||
| 124 | } | ||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | 0 | ▶ | sub foreign_key { | ||||||||||||||||||
|
Subroutine
foreign_key: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 127 | 0 | my $self = shift; | |||||||||||||||||||
| 128 | 0 | my $name = shift; | |||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | 0 | ▶ | unless( defined $self->{_foreign_keys} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 131 | 0 | $self->{_foreign_keys} = {}; | |||||||||||||||||||
| 132 | 0 | foreach my $foreign_key ($self->foreign_keys) { | |||||||||||||||||||
| 133 | 0 | $self->{_foreign_keys}{$foreign_key->name} = $foreign_key; | |||||||||||||||||||
| 134 | } | ||||||||||||||||||||
| 135 | } | ||||||||||||||||||||
| 136 | |||||||||||||||||||||
| 137 | 0 | return $self->{_foreign_keys}{$name}; | |||||||||||||||||||
| 138 | } | ||||||||||||||||||||
| 139 | |||||||||||||||||||||
| 140 | 1 | 1; | |||||||||||||||||||
| 141 | __END__ | ||||||||||||||||||||