| 1 | |||||||||||||||||||||
| 2 | package SQL::Admin::Catalog::Table; | ||||||||||||||||||||
| 3 | 2 | ▶ | use base qw( SQL::Admin::Catalog::Object ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 2 | our $VERSION = v0.5.0; | |||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | ###################################################################### | ||||||||||||||||||||
| 11 | ###################################################################### | ||||||||||||||||||||
| 12 | 9 | ▶ | sub add { # ; | ||||||||||||||||||
|
Subroutine
add: called CC=7 SCAR=19.7
Pod
undocumented
| |||||||||||||||||||||
| 13 | 9 | my ($self, $what, @params) = @_; | |||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 9 | ▶ | return unless $self->catalog; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 9 | ▶ | return $self->table_row (@params) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 18 | if $what eq 'table_row'; | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | ################################################################## | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 9 | my $obj = $self->catalog->add ($what, table => $self, @params); | |||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | ################################################################## | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 9 | ▶ | return $self->column ($obj->name, $obj) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 27 | if $what eq 'column'; | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 4 | ▶ | return $self->primary_key ($obj) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 30 | if $what eq 'primary_key'; | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 2 | ▶ | return $self->unique ($obj->fullname, $obj) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 33 | if $what eq 'unique'; | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 1 | ▶ | return $self->foreign_key ($obj->fullname, $obj) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 36 | if $what eq 'foreign_key'; | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | ###################################################################### | ||||||||||||||||||||
| 42 | ###################################################################### | ||||||||||||||||||||
| 43 | 6 | ▶ | sub column { # ; | ||||||||||||||||||
|
Subroutine
column: called CC=7 SCAR=19.6
Pod
undocumented
| |||||||||||||||||||||
| 44 | 6 | my $self = shift; | |||||||||||||||||||
| 45 | 6 | ▶ | my $map = $self->{column_map} ||= {}; | ||||||||||||||||||
|
Condition100%2/2
$self->{"column_map"} ||= {}
MC/DC100%1/1
$self->{"column_map"} ||= {}
$self->{"column_map"}
Truth table100%2/2
A
A= $self->{"column_map"}
| |||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 6 | ▶ | return $map unless @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 5 | my $name = shift; | |||||||||||||||||||
| 50 | 5 | ▶ | return unless defined $name; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 5 | ▶ | return $map->{$name} unless @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 5 | my $col = shift; | |||||||||||||||||||
| 55 | 5 | ▶ | my $list = $self->{column_list} ||= []; | ||||||||||||||||||
|
Condition100%2/2
$self->{"column_list"} ||= []
MC/DC100%1/1
$self->{"column_list"} ||= []
$self->{"column_list"}
Truth table100%2/2
A
A= $self->{"column_list"}
| |||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | push @$list, $col->name | ||||||||||||||||||||
| 58 | 5 | ▶ | unless exists $map->{$name}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 5 | $map->{$name} = $col; | |||||||||||||||||||
| 61 | } | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | ###################################################################### | ||||||||||||||||||||
| 65 | ###################################################################### | ||||||||||||||||||||
| 66 | 0 | ▶ | sub columns { # ; | ||||||||||||||||||
|
Subroutine
columns: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 67 | 0 | ▶ | my $retval = shift->{column_list} ||= []; | ||||||||||||||||||
|
Condition0%0/2
+(shift())->{"column_list"} ||= []
MC/DC0%0/1
+(shift())->{"column_list"} ||= []
+(shift())->{"column_list"}
Truth table0%0/2
A
A= +(shift())->{"column_list"}
| |||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 0 | ▶ | return $retval unless wantarray; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 70 | 0 | return @$retval; | |||||||||||||||||||
| 71 | } | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | ###################################################################### | ||||||||||||||||||||
| 75 | ###################################################################### | ||||||||||||||||||||
| 76 | 0 | ▶ | sub option { # ; | ||||||||||||||||||
|
Subroutine
option: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||
| 77 | 0 | my $self = shift; | |||||||||||||||||||
| 78 | 0 | ▶ | return $self->{option} ||= {} unless @_; | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$self->{"option"} ||= {}
MC/DC0%0/1
$self->{"option"} ||= {}
$self->{"option"}
Truth table0%0/2
A
A= $self->{"option"}
| |||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | 0 | my $key = shift; | |||||||||||||||||||
| 81 | 0 | ▶ | return $self->{option}{ $key } unless @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | 0 | $self->{option}{$key} = shift; | |||||||||||||||||||
| 84 | } | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | ###################################################################### | ||||||||||||||||||||
| 88 | ###################################################################### | ||||||||||||||||||||
| 89 | 6 | ▶ | sub primary_key { # ; | ||||||||||||||||||
|
Subroutine
primary_key: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 90 | 6 | my $self = shift; | |||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | 6 | ▶ | $self->{primary_key} = shift if @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 93 | 6 | $self->{primary_key}; | |||||||||||||||||||
| 94 | } | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | ###################################################################### | ||||||||||||||||||||
| 98 | ###################################################################### | ||||||||||||||||||||
| 99 | 3 | ▶ | sub unique { # ; | ||||||||||||||||||
|
Subroutine
unique: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||
| 100 | 3 | my $self = shift; | |||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | 3 | ▶ | my $map = $self->{unique} ||= {}; | ||||||||||||||||||
|
Condition100%2/2
$self->{"unique"} ||= {}
MC/DC100%1/1
$self->{"unique"} ||= {}
$self->{"unique"}
Truth table100%2/2
A
A= $self->{"unique"}
| |||||||||||||||||||||
| 103 | 3 | ▶ | return $map unless @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | 1 | my $key = shift; | |||||||||||||||||||
| 106 | 1 | ▶ | return $map->{$key} unless @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | 1 | $map->{$key} = shift; | |||||||||||||||||||
| 109 | } | ||||||||||||||||||||
| 110 | |||||||||||||||||||||
| 111 | |||||||||||||||||||||
| 112 | ###################################################################### | ||||||||||||||||||||
| 113 | ###################################################################### | ||||||||||||||||||||
| 114 | 3 | ▶ | sub foreign_key { # ; | ||||||||||||||||||
|
Subroutine
foreign_key: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||
| 115 | 3 | my $self = shift; | |||||||||||||||||||
| 116 | |||||||||||||||||||||
| 117 | 3 | ▶ | my $map = $self->{foreign_key} ||= {}; | ||||||||||||||||||
|
Condition100%2/2
$self->{"foreign_key"} ||= {}
MC/DC100%1/1
$self->{"foreign_key"} ||= {}
$self->{"foreign_key"}
Truth table100%2/2
A
A= $self->{"foreign_key"}
| |||||||||||||||||||||
| 118 | 3 | ▶ | return $map unless @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | 1 | my $key = shift; | |||||||||||||||||||
| 121 | 1 | ▶ | return $map->{$key} unless @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 122 | |||||||||||||||||||||
| 123 | 1 | $map->{$key} = shift; | |||||||||||||||||||
| 124 | } | ||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | |||||||||||||||||||||
| 127 | ###################################################################### | ||||||||||||||||||||
| 128 | ###################################################################### | ||||||||||||||||||||
| 129 | 0 | ▶ | sub table_row { # ; | ||||||||||||||||||
|
Subroutine
table_row: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 130 | 0 | my $self = shift; | |||||||||||||||||||
| 131 | |||||||||||||||||||||
| 132 | 0 | ▶ | my $list = $self->{table_row} ||= []; | ||||||||||||||||||
|
Condition0%0/2
$self->{"table_row"} ||= []
MC/DC0%0/1
$self->{"table_row"} ||= []
$self->{"table_row"}
Truth table0%0/2
A
A= $self->{"table_row"}
| |||||||||||||||||||||
| 133 | 0 | ▶ | return $list unless @_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 134 | |||||||||||||||||||||
| 135 | 0 | push @$list, @_; | |||||||||||||||||||
| 136 | } | ||||||||||||||||||||
| 137 | |||||||||||||||||||||
| 138 | |||||||||||||||||||||
| 139 | ###################################################################### | ||||||||||||||||||||
| 140 | ###################################################################### | ||||||||||||||||||||
| 141 | 0 | ▶ | sub set_row_search { # ; | ||||||||||||||||||
|
Subroutine
set_row_search: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 142 | 0 | my $self= shift; | |||||||||||||||||||
| 143 | 0 | $self->{row_search} = shift; | |||||||||||||||||||
| 144 | } | ||||||||||||||||||||
| 145 | |||||||||||||||||||||
| 146 | |||||||||||||||||||||
| 147 | ###################################################################### | ||||||||||||||||||||
| 148 | ###################################################################### | ||||||||||||||||||||
| 149 | 0 | ▶ | sub row_search { # ; | ||||||||||||||||||
|
Subroutine
row_search: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 150 | # simple query, just key-value pair | ||||||||||||||||||||
| 151 | 0 | my ($self, $query) = @_; | |||||||||||||||||||
| 152 | |||||||||||||||||||||
| 153 | return $self->{row_search}->($self, $query) | ||||||||||||||||||||
| 154 | 0 | ▶ | if $self->{row_search}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 155 | |||||||||||||||||||||
| 156 | } | ||||||||||||||||||||
| 157 | |||||||||||||||||||||
| 158 | |||||||||||||||||||||
| 159 | ###################################################################### | ||||||||||||||||||||
| 160 | ###################################################################### | ||||||||||||||||||||
| 161 | |||||||||||||||||||||
| 162 | package SQL::Admin::Catalog::Table; | ||||||||||||||||||||
| 163 | |||||||||||||||||||||
| 164 | 2 | 1; | |||||||||||||||||||
| 165 | |||||||||||||||||||||