lib/SQL/Admin/Catalog/Table.pm

filter: Statementstmt 73.3% 44 / 60 Branchbran 55.0% 22 / 40 Conditioncond 57.1% 8 / 14 MC/DCmcdc 57.1% 4 / 7 Subroutinesub 61.5% 8 / 13 Podpod 0.0% 0 / 10 totaltotal 59.7% 86 / 144 CC 28 SCAR 20.3
CC
28
Cov
65%
option
20.0
columns
12.0
table_row
12.0
CRAP 7.6
« lib/SQL/Admin/Catalog/Table/Column.pm ↑ Summary lib/SQL/Admin/Driver/Base.pm »
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
BranchTrueFalseTotal
unless $self->catalog 0 9 9
16  
17 9 ▶ return $self->table_row (@params)
Branch: 1 branch
BranchTrueFalseTotal
if $what eq "table_row" 0 9 9
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
BranchTrueFalseTotal
if $what eq "column" 5 4 9
27 if $what eq 'column';
28  
29 4 ▶ return $self->primary_key ($obj)
Branch: 1 branch
BranchTrueFalseTotal
if $what eq "primary_key" 2 2 4
30 if $what eq 'primary_key';
31  
32 2 ▶ return $self->unique ($obj->fullname, $obj)
Branch: 1 branch
BranchTrueFalseTotal
if $what eq "unique" 1 1 2
33 if $what eq 'unique';
34  
35 1 ▶ return $self->foreign_key ($obj->fullname, $obj)
Branch: 1 branch
BranchTrueFalseTotal
if $what eq "foreign_key" 1 0 1
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"} ||= {}
l!l
42
MC/DC100%1/1
$self->{"column_map"} ||= {}
$self->{"column_map"}
Truth table100%2/2
A
A= $self->{"column_map"}
Aresult
11
00
46  
47 6 ▶ return $map unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 1 5 6
48  
49 5 my $name = shift;
50 5 ▶ return unless defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 0 5 5
51  
52 5 ▶ return $map->{$name} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 5 5
53  
54 5 my $col = shift;
55 5 ▶ my $list = $self->{column_list} ||= [];
Condition100%2/2
$self->{"column_list"} ||= []
l!l
32
MC/DC100%1/1
$self->{"column_list"} ||= []
$self->{"column_list"}
Truth table100%2/2
A
A= $self->{"column_list"}
Aresult
11
00
56  
57 push @$list, $col->name
58 5 ▶ unless exists $map->{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $map->{$name} 5 0 5
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"} ||= []
l!l
00
MC/DC0%0/1
+(shift())->{"column_list"} ||= []
+(shift())->{"column_list"}
Truth table0%0/2
A
A= +(shift())->{"column_list"}
Aresult
11
00
68  
69 0 ▶ return $retval unless wantarray;
Branch: 1 branch
BranchTrueFalseTotal
unless wantarray 0 0 0
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
BranchTrueFalseTotal
unless @_ 0 0 0
Condition0%0/2
$self->{"option"} ||= {}
l!l
00
MC/DC0%0/1
$self->{"option"} ||= {}
$self->{"option"}
Truth table0%0/2
A
A= $self->{"option"}
Aresult
11
00
79  
80 0 my $key = shift;
81 0 ▶ return $self->{option}{ $key } unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
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
BranchTrueFalseTotal
if @_ 2 4 6
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"} ||= {}
l!l
21
MC/DC100%1/1
$self->{"unique"} ||= {}
$self->{"unique"}
Truth table100%2/2
A
A= $self->{"unique"}
Aresult
11
00
103 3 ▶ return $map unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 2 1 3
104  
105 1 my $key = shift;
106 1 ▶ return $map->{$key} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 1 1
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"} ||= {}
l!l
21
MC/DC100%1/1
$self->{"foreign_key"} ||= {}
$self->{"foreign_key"}
Truth table100%2/2
A
A= $self->{"foreign_key"}
Aresult
11
00
118 3 ▶ return $map unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 2 1 3
119  
120 1 my $key = shift;
121 1 ▶ return $map->{$key} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 1 1
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"} ||= []
l!l
00
MC/DC0%0/1
$self->{"table_row"} ||= []
$self->{"table_row"}
Truth table0%0/2
A
A= $self->{"table_row"}
Aresult
11
00
133 0 ▶ return $list unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
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
BranchTrueFalseTotal
if $self->{"row_search"} 0 0 0
155  
156 }
157  
158  
159 ######################################################################
160 ######################################################################
161  
162 package SQL::Admin::Catalog::Table;
163  
164 2 1;
165  
« lib/SQL/Admin/Catalog/Table/Column.pm ↑ Summary lib/SQL/Admin/Driver/Base.pm »