lib/SQL/Admin/Driver/Pg/Producer.pm

filter: Statementstmt 31.6% 19 / 60 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 15 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 14.2% 4 / 28 Podpod 0.0% 0 / 23 totaltotal 16.4% 23 / 140 CC 10 SCAR 25.6
CC
10
Cov
23%
_escape_identifier
56.0
data_type
12.0
alter_table
6.0
CRAP 12.9
« lib/SQL/Admin.pm ↑ Summary lib/SQL/Admin/Catalog.pm »
1  
2 package SQL::Admin::Driver::Pg::Producer;
3 1 ▶use base qw( SQL::Admin::Driver::Base::Producer );
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our $VERSION = v0.5.0;
9  
10 ######################################################################
11  
12 1 ▶use SQL::Admin::Driver::Pg::Keywords qw( :all );
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 our %DATA_TYPE_MAP = (
15 );
16  
17 ######################################################################
18  
19 1 our $ESCAPE_ALL_IDENTIFIERS = 0;
20 1 our $ESCAPE_NONRESERVED_KEYWORDS = 0;
21 1 our $ESCAPE_SQL_KEYWORDS = 0;
22  
23 ######################################################################
24  
25 1 our %REFERENTIAL_ACTION = (
26 cascade => [ 'CASCADE' ],
27 no_action => [ 'NO', 'ACTION' ],
28 restrict => [ 'RESTRICT' ],
29 set_null => [ 'SET', 'NULL' ],
30 );
31  
32 ######################################################################
33 ######################################################################
34  
35 0 ▶sub _escape_identifier { # ;
Subroutine _escape_identifier: not called CC=7 SCAR=40.3
36 0 my ($self, $identifier) = @_;
37 0 my $lc = lc $identifier;
38  
39 $identifier = '"' . $identifier . '"'
40 if $ESCAPE_ALL_IDENTIFIERS
41 || $RESERVED_KEYWORDS{ $lc }
42 || ($ESCAPE_NONRESERVED_KEYWORDS && $NONRESERVED_KEYWORDS{ $lc })
43 0 ▶ || ($ESCAPE_SQL_KEYWORDS && $SQL_KEYWORDS{ $lc })
Branch: 1 branch
BranchTrueFalseTotal
if $SQL::Admin::Driver::Pg::Producer::ESCAPE_ALL_IDENTIFIERS or $SQL::Admin::Driver::Pg::Producer::RESERVED_KEYWORDS{$lc} or $SQL::Admin::Driver::Pg::Producer::ESCAPE_NONRESERVED_KEYWORDS and $SQL::Admin::Driver::Pg::Producer::NONRESERVED_KEYWORDS{$lc} or $SQL::Admin::Driver::Pg::Producer::ESCAPE_SQL_KEYWORDS and $SQL::Admin::Driver::Pg::Producer::SQL_KEYWORDS{$lc} 0 0 0
Condition0%0/15
$SQL::Admin::Driver::Pg::Producer::ESCAPE_ALL_IDENTIFIERS or $SQL::Admin::Driver::Pg::Producer::RESERVED_KEYWORDS{$lc} or $SQL::Admin::Driver::Pg::Producer::ESCAPE_NONRESERVED_KEYWORDS and $SQL::Admin::Driver::Pg::Producer::NONRESERVED_KEYWORDS{$lc} or $SQL::Admin::Driver::Pg::Producer::ESCAPE_SQL_KEYWORDS and $SQL::Admin::Driver::Pg::Producer::SQL_KEYWORDS{$lc}
l!l&&r!l&&!r
000
$SQL::Admin::Driver::Pg::Producer::ESCAPE_ALL_IDENTIFIERS or $SQL::Admin::Driver::Pg::Producer::RESERVED_KEYWORDS{$lc} or $SQL::Admin::Driver::Pg::Producer::ESCAPE_NONRESERVED_KEYWORDS and $SQL::Admin::Driver::Pg::Producer::NONRESERVED_KEYWORDS{$lc}
l!l&&r!l&&!r
000
$SQL::Admin::Driver::Pg::Producer::ESCAPE_ALL_IDENTIFIERS or $SQL::Admin::Driver::Pg::Producer::RESERVED_KEYWORDS{$lc}
l!l&&r!l&&!r
000
$SQL::Admin::Driver::Pg::Producer::ESCAPE_NONRESERVED_KEYWORDS and $SQL::Admin::Driver::Pg::Producer::NONRESERVED_KEYWORDS{$lc}
!ll&&!rl&&r
000
$SQL::Admin::Driver::Pg::Producer::ESCAPE_SQL_KEYWORDS and $SQL::Admin::Driver::Pg::Producer::SQL_KEYWORDS{$lc}
!ll&&!rl&&r
000
MC/DC0%0/6
$SQL::Admin::Driver::Pg::Producer::ESCAPE_ALL_IDENTIFIERS or $SQL::Admin::Driver::Pg::Producer::RESERVED_KEYWORDS{$lc} or $SQL::Admin::Driver::Pg::Producer::ESCAPE_NONRESERVED_KEYWORDS and $SQL::Admin::Driver::Pg::Producer::NONRESERVED_KEYWORDS{$lc} or $SQL::Admin::Driver::Pg::Producer::ESCAPE_SQL_KEYWORDS and $SQL::Admin::Driver::Pg::Producer::SQL_KEYWORDS{$lc}
$SQL::Admin::Driver::Pg::Producer::ESCAPE_ALL_IDENTIFIERS $SQL::Admin::Driver::Pg::Producer::RESERVED_KEYWORDS{$lc} $SQL::Admin::Driver::Pg::Producer::ESCAPE_NONRESERVED_KEYWORDS $SQL::Admin::Driver::Pg::Producer::NONRESERVED_KEYWORDS{$lc} $SQL::Admin::Driver::Pg::Producer::ESCAPE_SQL_KEYWORDS $SQL::Admin::Driver::Pg::Producer::SQL_KEYWORDS{$lc}
Truth table0%0/9
A or B or C and D or E and F
A= $SQL::Admin::Driver::Pg::Producer::ESCAPE_ALL_IDENTIFIERSB= $SQL::Admin::Driver::Pg::Producer::RESERVED_KEYWORDS{$lc}C= $SQL::Admin::Driver::Pg::Producer::ESCAPE_NONRESERVED_KEYWORDSD= $SQL::Admin::Driver::Pg::Producer::NONRESERVED_KEYWORDS{$lc}E= $SQL::Admin::Driver::Pg::Producer::ESCAPE_SQL_KEYWORDSF= $SQL::Admin::Driver::Pg::Producer::SQL_KEYWORDS{$lc}
ABCDEFresult
1XXXXX1
01XXXX1
0011XX1
000X111
0010111
000X0X0
000X100
00100X0
0010100
44 ;
45  
46 ##################################################################
47  
48 0 $identifier;
49 }
50  
51  
52 ######################################################################
53 ######################################################################
54 0 ▶sub data_type { # ;
Subroutine data_type: not called CC=3 SCAR=24.8
Pod undocumented
55 0 my ($self, $data, $parent) = @_;
56  
57 0 ▶ return 'serial' if $parent->{autoincrement};
Branch: 1 branch
BranchTrueFalseTotal
if $parent->{"autoincrement"} 0 0 0
58  
59 $data = $DATA_TYPE_MAP{lc $data}
60 0 ▶ if exists $DATA_TYPE_MAP{lc $data};
Branch: 1 branch
BranchTrueFalseTotal
if exists $SQL::Admin::Driver::Pg::Producer::DATA_TYPE_MAP{lc $data} 0 0 0
61  
62 0 $self->SUPER::data_type ($data, $parent);
63 }
64  
65  
66 ######################################################################
67 ######################################################################
68 0 ▶sub current_timestamp { # ;
Subroutine current_timestamp: not called CC=1 SCAR=6.9
Pod undocumented
69 0 'CURRENT_TIMESTAMP';
70 }
71  
72  
73 ######################################################################
74 ######################################################################
75 0 ▶sub current_time { # ;
Subroutine current_time: not called CC=1 SCAR=6.9
Pod undocumented
76 0 'CURRENT_TIME';
77 }
78  
79  
80 ######################################################################
81 ######################################################################
82 0 ▶sub current_date { # ;
Subroutine current_date: not called CC=1 SCAR=6.9
Pod undocumented
83 0 'CURRENT_DATE';
84 }
85  
86  
87 ######################################################################
88 ######################################################################
89 0 ▶sub default_clause { # ;
Subroutine default_clause: not called CC=1 SCAR=6.9
Pod undocumented
90 0 my ($self, $def) = @_;
91  
92 0 'DEFAULT', $self->__apply (%$def);
93 }
94  
95  
96 ######################################################################
97 ######################################################################
98  
99 0 ▶sub autoincrement { # ;
Subroutine autoincrement: not called CC=1 SCAR=0.0
Pod undocumented
100 }
101  
102  
103 ######################################################################
104 ######################################################################
105 0 ▶sub sequence_type { # ;
Subroutine sequence_type: not called CC=1 SCAR=0.0
Pod undocumented
106 }
107  
108  
109 ######################################################################
110 ######################################################################
111 0 ▶sub sequence_options { # ;
Subroutine sequence_options: not called CC=1 SCAR=0.0
Pod undocumented
112 }
113  
114  
115 ######################################################################
116 ######################################################################
117 0 ▶sub sequence_start_with { # ;
Subroutine sequence_start_with: not called CC=1 SCAR=0.0
Pod undocumented
118 }
119  
120  
121 ######################################################################
122 ######################################################################
123 0 ▶sub sequence_increment_by { # ;
Subroutine sequence_increment_by: not called CC=1 SCAR=0.0
Pod undocumented
124 }
125  
126  
127 ######################################################################
128 ######################################################################
129 0 ▶sub sequence_minvalue { # ;
Subroutine sequence_minvalue: not called CC=1 SCAR=0.0
Pod undocumented
130 }
131  
132  
133 ######################################################################
134 ######################################################################
135 0 ▶sub sequence_maxvalue { # ;
Subroutine sequence_maxvalue: not called CC=1 SCAR=0.0
Pod undocumented
136 }
137  
138  
139 ######################################################################
140 ######################################################################
141 0 ▶sub sequence_cache { # ;
Subroutine sequence_cache: not called CC=1 SCAR=0.0
Pod undocumented
142 }
143  
144  
145 ######################################################################
146 ######################################################################
147  
148 0 ▶sub alter_table_actions { # ;
Subroutine alter_table_actions: not called CC=1 SCAR=6.9
Pod undocumented
149 0 my ($self, $def) = @_;
150  
151 0 map $self->__apply (alter_table_action => $_), @$def;
152 }
153  
154  
155 ######################################################################
156 ######################################################################
157 0 ▶sub alter_table_action { # ;
Subroutine alter_table_action: not called CC=1 SCAR=6.9
Pod undocumented
158 0 my ($self, $def) = @_;
159  
160 0 print '>>> ', join ' ', keys %$def;
161 0 $self->__apply (%$def);
162 }
163  
164  
165 ######################################################################
166 ######################################################################
167 0 ▶sub delete_rule { # ;
Subroutine delete_rule: not called CC=1 SCAR=6.9
Pod undocumented
168 0 my ($self, $def) = @_;
169  
170 0 print ">> delete rule: $def\n";
171 0 map +('ON', 'DELETE', @{ $REFERENTIAL_ACTION{$_} }), grep defined, $def;
172 }
173  
174  
175 ######################################################################
176 ######################################################################
177 0 ▶sub update_rule { # ;
Subroutine update_rule: not called CC=1 SCAR=6.9
Pod undocumented
178 0 my ($self, $def) = @_;
179  
180 0 print ">> update rule: $def\n";
181 0 map +('ON', 'UPDATE', @{ $REFERENTIAL_ACTION{$_} }), grep defined, $def;
182 }
183  
184  
185 ######################################################################
186 ######################################################################
187  
188 0 ▶sub create_sequence { # ;
Subroutine create_sequence: not called CC=1 SCAR=6.9
Pod undocumented
189 0 my ($self, $def) = @_;
190  
191 (
192 0 'CREATE',
193 'SEQUENCE',
194 $self->__call (sequence_name => $def),
195 $self->__call (sequence_type => $def),
196 $self->__call (sequence_options => $def),
197 );
198 }
199  
200  
201 ######################################################################
202 ######################################################################
203 0 ▶sub index_name { # ;
Subroutine index_name: not called CC=1 SCAR=6.9
Pod undocumented
204 0 my ($self, $def) = @_;
205  
206 0 $self->_escape_identifier ($def->{name});
207 }
208  
209  
210 ######################################################################
211 ######################################################################
212 0 ▶sub create_index { # ;
Subroutine create_index: not called CC=1 SCAR=6.9
Pod undocumented
213 0 my ($self, $def) = @_;
214 0 join ' ', (
215 'CREATE',
216 $self->__call (index_unique => $def),
217 'INDEX',
218 $self->__call (index_name => $def),
219 'ON',
220 $self->__call (table_name => $def),
221 $self->__call (index_column_list => $def),
222 $self->__call (index_options => $def),
223 );
224 }
225  
226  
227 ######################################################################
228 ######################################################################
229 0 ▶sub create_table { # ;
Subroutine create_table: not called CC=1 SCAR=6.9
Pod undocumented
230 0 my ($self, $def) = @_;
231  
232 0 join ' ', (
233 'CREATE',
234 'TABLE',
235 $self->__call (table_name => $def),
236 $self->__call (table_content => $def),
237 $self->__call (table_options => $def),
238 );
239 }
240  
241  
242 ######################################################################
243 ######################################################################
244 0 ▶sub alter_table { # ;
Subroutine alter_table: not called CC=2 SCAR=17.9
Pod undocumented
245 0 my ($self, $def) = @_;
246  
247 0 my @list = map $self->__apply (%$_), @{ $def->{alter_table_actions} };
248  
249 0 ▶ return unless @list;
Branch: 1 branch
BranchTrueFalseTotal
unless @list 0 0 0
250  
251 (
252 0 'ALTER',
253 'TABLE',
254 $self->__call (table_name => $def),
255 @list
256 );
257 }
258  
259  
260 ######################################################################
261 ######################################################################
262  
263 0 ▶sub create_schema { # ;
Subroutine create_schema: not called CC=1 SCAR=6.9
Pod undocumented
264 0 my ($self, $def) = @_;
265  
266 (
267 'CREATE',
268 'SCHEMA',
269 0 $self->_escape_identifier ($def->{schema_identifier}),
270 );
271 }
272  
273  
274 ######################################################################
275 ######################################################################
276  
277 package SQL::Admin::Driver::Pg::Producer;
278  
279 1 1;
« lib/SQL/Admin.pm ↑ Summary lib/SQL/Admin/Catalog.pm »