Alzabo/SQLMaker/PostgreSQL.pm

filter: Statementstmt 73.5% 39 / 53 Branchbran 62.5% 5 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 53.8% 7 / 13 Podpod 66.6% 4 / 6 totaltotal 68.7% 55 / 80 CC 11 SCAR 15.8
CC
11
Cov
72%
_make_functions
9.0
limit
6.0
import
2.0
CRAP 4.9
« Alzabo/Debug.pm ↑ Summary Alzabo/Runtime/RowState/InCache.pm »
1 package Alzabo::SQLMaker::PostgreSQL;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use vars qw($VERSION $AUTOLOAD @EXPORT_OK %EXPORT_TAGS);
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Alzabo::Exceptions;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Alzabo::SQLMaker;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use base qw(Alzabo::SQLMaker);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 $VERSION = 2.0;
12  
13 1 my $MADE_FUNCTIONS;
14  
15 sub import
16 1 ▶{
Subroutine import: called CC=2 SCAR=7.0
17 1 ▶ _make_functions() unless $MADE_FUNCTIONS;
Branch: 1 branch
BranchTrueFalseTotal
unless $MADE_FUNCTIONS 1 0 1
18  
19 # used to export function functions
20 1 require Exporter;
21 1 *_import = \&Exporter::import;
22  
23 1 goto &_import;
24 }
25  
26 sub _make_functions
27 1 ▶{
Subroutine _make_functions: called CC=9 SCAR=22.0
28 1 local *make_function = \&Alzabo::SQLMaker::make_function;
29  
30 1 foreach ( [ NOW => [ 'datetime', 'common' ] ],
31 [ CURRENT_DATE => [ 'datetime' ], { no_parens => 1 } ],
32 [ CURRENT_TIME => [ 'datetime' ], { no_parens => 1 } ],
33 [ CURRENT_TIMESTAMP => [ 'datetime' ], { no_parens => 1 } ],
34 [ TIMEOFDAY => [ 'datetime' ] ],
35  
36 [ PI => [ 'math' ] ],
37 [ RANDOM => [ 'math' ] ],
38  
39 [ CURRENT_USER => [ 'system' ] ],
40 [ SYSTEM_USER => [ 'system' ] ],
41 [ USER => [ 'system' ] ],
42 )
43 {
44 make_function( function => $_->[0],
45 min => 0,
46 max => 0,
47 groups => $_->[1],
48 10 ▶ $_->[2] ? %{ $_->[2] } : (),
Branch: 1 branch
BranchTrueFalseTotal
$_->[2] ? : 3 7 10
49 );
50 }
51  
52 1 foreach ( [ LENGTH => [1], [ 'string' ] ],
53 [ CHAR_LENGTH => [1], [ 'string' ] ],
54 [ CHARACTER_LENGTH => [1], [ 'string' ] ],
55 [ OCTET_LENGTH => [1], [ 'string' ] ],
56 [ TRIM => [1], [ 'string' ] ],
57 [ UPPER => [1], [ 'string' ] ],
58 [ LOWER => [1], [ 'string' ] ],
59 [ INITCAP => [1], [ 'string' ] ],
60 [ ASCII => [1], [ 'string' ] ],
61  
62 [ ABS => [0], [ 'math' ] ],
63 [ CEIL => [0], [ 'math' ] ],
64 [ DEGREES => [0], [ 'math' ] ],
65 [ FLOOR => [0], [ 'math' ] ],
66 [ FACTORIAL => [0], [ 'math' ] ],
67 [ SQRT => [0], [ 'math' ] ],
68 [ CBRT => [0], [ 'math' ] ],
69 [ EXP => [0], [ 'math' ] ],
70 [ LN => [0], [ 'math' ] ],
71 [ RADIANS => [0], [ 'math' ] ],
72  
73 [ ACOS => [0], [ 'math' ] ],
74 [ ASIN => [0], [ 'math' ] ],
75 [ ATAN => [0], [ 'math' ] ],
76 [ COS => [0], [ 'math' ] ],
77 [ COT => [0], [ 'math' ] ],
78 [ SIN => [0], [ 'math' ] ],
79 [ TAN => [0], [ 'math' ] ],
80  
81 [ ISFINITE => [1], [ 'datetime' ] ],
82  
83 [ BROADCAST => [1], [ 'network' ] ],
84 [ HOST => [1], [ 'network' ] ],
85 [ NETMASK => [1], [ 'network' ] ],
86 [ MASKLEN => [1], [ 'network' ] ],
87 [ NETWORK => [1], [ 'network' ] ],
88 [ TEXT => [1], [ 'network' ] ],
89 [ ABBREV => [1], [ 'network' ] ],
90 )
91 {
92 34 make_function( function => $_->[0],
93 min => 1,
94 max => 1,
95 quote => $_->[1],
96 groups => $_->[2],
97 );
98 }
99  
100 1 foreach ( [ TO_ASCII => [1,0], [ 'string' ] ],
101  
102 [ ROUND => [0,0], [ 'math' ] ],
103 [ TRUNC => [0,0], [ 'math' ] ],
104 [ LOG => [0,0], [ 'math' ] ],
105 [ POW => [0,0], [ 'math' ] ],
106  
107 [ TIMESTAMP => [1,1], [ 'datetime' ] ],
108 )
109 {
110 6 make_function( function => $_->[0],
111 min => 1,
112 max => 2,
113 quote => $_->[1],
114 groups => $_->[2],
115 );
116 }
117  
118 1 foreach ( [ STRPOS => [1,1], [ 'string' ] ],
119 [ POSITION => [1,1], [ 'string' ], '%s IN %s' ],
120 [ TO_NUMBER => [1,1], [ 'string' ] ],
121 [ TO_DATE => [1,1], [ 'string' ] ],
122 [ TO_TIMESTAMP => [1,1], [ 'string' ] ],
123 [ REPEAT => [1,0], [ 'string' ] ],
124  
125 [ MOD => [0,0], [ 'math' ] ],
126 [ ATAN2 => [0,0], [ 'math' ] ],
127  
128 [ TO_CHAR => [0,1], [ 'math', 'datetime' ] ],
129  
130 [ DATE_PART => [1,1], [ 'datetime' ] ],
131 [ EXTRACT => [0,1], [ 'datetime' ], '%s FROM %s' ],
132 [ DATE_TRUNC => [1,1], [ 'datetime' ] ],
133  
134 [ NULLIF => [0,0], [ 'control' ] ],
135 )
136 {
137 13 ▶ make_function( function => $_->[0],
Branch: 1 branch
BranchTrueFalseTotal
$_->[3] ? : 2 11 13
138 min => 2,
139 max => 2,
140 quote => $_->[1],
141 groups => $_->[2],
142 $_->[3] ? ( format => $_->[3] ) : (),
143 );
144 }
145  
146 1 foreach ( [ RPAD => [0,0,1], [ 'string' ] ],
147 [ LPAD => [0,0,1], [ 'string' ] ],
148 [ SUBSTR => [0,0,0], [ 'string' ] ],
149 )
150 {
151 3 make_function( function => $_->[0],
152 min => 2,
153 max => 3,
154 quote => $_->[1],
155 groups => $_->[2],
156 );
157 }
158  
159 1 make_function( function => 'COALESCE',
160 min => 2,
161 max => undef,
162 quote => [0,0,0],
163 groups => [ 'control' ],
164 );
165  
166 1 make_function( function => 'OVERLAPS',
167 min => 4,
168 max => 4,
169 quote => [1,1,1,1],
170 groups => [ 'datetime' ],
171 );
172  
173 1 foreach ( [ COUNT => [0], [ 'aggregate', 'common' ] ],
174 [ AVG => [0], [ 'aggregate', 'common' ] ],
175 [ MIN => [0], [ 'aggregate', 'common' ] ],
176 [ MAX => [0], [ 'aggregate', 'common' ] ],
177 [ SUM => [0], [ 'aggregate', 'common' ] ],
178 [ STDDEV => [0], [ 'aggregate' ] ],
179 [ VARIANCE => [0], [ 'aggregate' ] ],
180  
181 [ DISTINCT => [0], [ 'common' ] ],
182 )
183 {
184 8 make_function( function => $_->[0],
185 min => 1,
186 max => 1,
187 quote => $_->[1],
188 groups => $_->[2],
189 );
190 }
191  
192 1 $MADE_FUNCTIONS = 1;
193 }
194  
195 sub init
196 0 ▶{
Subroutine init: not called CC=1 SCAR=6.9
Pod undocumented
197 0 1;
198 }
199  
200 sub new
201 0 ▶{
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
202 0 my $self = shift->SUPER::new(@_);
203  
204 0 $self->{alias_in_having} = 0;
205  
206 0 return $self;
207 }
208  
209 sub limit
210 0 ▶{
Subroutine limit: not called CC=2 SCAR=17.9
Pod documented
211 0 my $self = shift;
212 0 my ($max, $offset) = @_;
213  
214 0 $self->_assert_last_op( qw( from function where and or condition order_by group_by ) );
215  
216 0 $self->{sql} .= " LIMIT $max";
217 0 ▶ $self->{sql} .= " OFFSET $offset" if $offset;
Branch: 1 branch
BranchTrueFalseTotal
if $offset 0 0 0
218  
219 0 $self->{last_op} = 'limit';
220  
221 0 return $self;
222 }
223  
224 sub get_limit
225 0 ▶{
Subroutine get_limit: not called CC=1 SCAR=6.9
Pod documented
226 0 return undef;
227 }
228  
229 0 ▶sub distinct_requires_order_by_in_select { 1 }
Subroutine distinct_requires_order_by_in_select: not called CC=1 SCAR=6.9
Pod undocumented
230  
231 sub sqlmaker_id
232 0 ▶{
Subroutine sqlmaker_id: not called CC=1 SCAR=6.9
Pod documented
233 0 return 'PostgreSQL';
234 }
235  
236 1 1;
237  
238 __END__
« Alzabo/Debug.pm ↑ Summary Alzabo/Runtime/RowState/InCache.pm »