PrettyPrinter/Node/FuncCall.pm

filter: Statementstmt 90.9% 200 / 220 Branchbran 76.4% 81 / 106 Conditioncond 100% 7 / 7 MC/DCmcdc 100% 4 / 4 Subroutinesub 91.6% 22 / 24 Podpod 100% 8 / 8 totaltotal 87.2% 322 / 369 CC 56 SCAR 23.3
CC
56
Cov
86%
frame_clause
19.3
pretty_print
16.0
as_text
10.6
CRAP 10.3
« PrettyPrinter/Node/A_Expr.pm ↑ Summary PrettyPrinter/Node/TransactionStmt.pm »
1 package Pg::SQL::PrettyPrinter::Node::FuncCall;
2  
3 # UTF8 boilerplace, per http://stackoverflow.com/questions/6162484/why-does-modern-perl-avoid-utf-8-by-default/
4 4 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use warnings qw( FATAL utf8 );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use open qw( :std :utf8 );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use Unicode::Normalize qw( NFC );
Subroutine BEGIN: called CC=1 SCAR=0.0
11 4 ▶use Unicode::Collate;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 4 ▶use Encode qw( decode );
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 4 ▶if ( grep /\P{ASCII}/ => @ARGV ) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep /\P{ASCII}/u, @ARGV) 0 4 4
15 0 @ARGV = map { decode( 'UTF-8', $_ ) } @ARGV;
16 }
17  
18 # If there is __DATA__,then uncomment next line:
19 # binmode( DATA, ':encoding(UTF-8)' );
20 # UTF8 boilerplace, per http://stackoverflow.com/questions/6162484/why-does-modern-perl-avoid-utf-8-by-default/
21  
22 # Useful common code
23 4 ▶use autodie;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 4 ▶use Carp qw( carp croak confess cluck );
Subroutine BEGIN: called CC=1 SCAR=0.0
25 4 ▶use English qw( -no_match_vars );
Subroutine BEGIN: called CC=1 SCAR=0.0
26 4 ▶use Data::Dumper qw( Dumper );
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 # give a full stack dump on any untrapped exceptions
29 0 ▶local $SIG{ __DIE__ } = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
30 0 ▶ confess "Uncaught exception: @_" unless $^S;
Branch: 1 branch
BranchTrueFalseTotal
unless $^S 0 0 0
31 4 };
32  
33 # now promote run-time warnings into stackdumped exceptions
34 # *unless* we're in an try block, in which
35 # case just generate a clucking stackdump instead
36 0 ▶local $SIG{ __WARN__ } = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
37 0 ▶ if ( $^S ) { cluck "Trapped warning: @_" }
Branch: 1 branch
BranchTrueFalseTotal
if ($^S) { } 0 0 0
38 0 else { confess "Deadly warning: @_" }
39 4 };
40  
41 # Useful common code
42  
43 4 ▶use parent qw( Pg::SQL::PrettyPrinter::Node );
Subroutine BEGIN: called CC=1 SCAR=0.0
44  
45 # Taken from PostgreSQL sources, from src/include/nodes/parsenodes.h
46 4 our $FRAMEOPTION_NONDEFAULT = 0x00001; # any specified?
47 4 our $FRAMEOPTION_RANGE = 0x00002; # RANGE behavior
48 4 our $FRAMEOPTION_ROWS = 0x00004; # ROWS behavior
49 4 our $FRAMEOPTION_GROUPS = 0x00008; # GROUPS behavior
50 4 our $FRAMEOPTION_BETWEEN = 0x00010; # BETWEEN given?
51 4 our $FRAMEOPTION_START_UNBOUNDED_PRECEDING = 0x00020; # start is U. P.
52 4 our $FRAMEOPTION_END_UNBOUNDED_PRECEDING = 0x00040; # (disallowed)
53 4 our $FRAMEOPTION_START_UNBOUNDED_FOLLOWING = 0x00080; # (disallowed)
54 4 our $FRAMEOPTION_END_UNBOUNDED_FOLLOWING = 0x00100; # end is U. F.
55 4 our $FRAMEOPTION_START_CURRENT_ROW = 0x00200; # start is C. R.
56 4 our $FRAMEOPTION_END_CURRENT_ROW = 0x00400; # end is C. R.
57 4 our $FRAMEOPTION_START_OFFSET_PRECEDING = 0x00800; # start is O. P.
58 4 our $FRAMEOPTION_END_OFFSET_PRECEDING = 0x01000; # end is O. P.
59 4 our $FRAMEOPTION_START_OFFSET_FOLLOWING = 0x02000; # start is O. F.
60 4 our $FRAMEOPTION_END_OFFSET_FOLLOWING = 0x04000; # end is O. F.
61 4 our $FRAMEOPTION_EXCLUDE_CURRENT_ROW = 0x08000; # omit C.R.
62 4 our $FRAMEOPTION_EXCLUDE_GROUP = 0x10000; # omit C.R. & peers
63 4 our $FRAMEOPTION_EXCLUDE_TIES = 0x20000; # omit C.R.'s peers
64  
65 47 ▶sub new {
Subroutine new: called CC=3 SCAR=11.0
Pod documented
66 47 my $class = shift;
67 47 my $self = $class->SUPER::new( @_ );
68 47 bless $self, $class;
69  
70 $self->objectify(
71 'funcname',
72 'args',
73 'agg_filter',
74 'agg_order',
75 47 map { [ 'over', $_ ] } qw( orderClause partitionClause startOffset endOffset )
76 );
77  
78 47 ▶ if ( $self->{ 'func_variadic' } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"func_variadic"}) 4 43 47
79 4 my $last_type = ref $self->{ 'args' }->[ -1 ];
80 4 $last_type =~ s/^Pg::SQL::PrettyPrinter::Node:://;
81 4 ▶ croak( "Function is variadic, but last arg is not an array/subquery: ${last_type}" ) unless $last_type =~ m{\A(?:A_ArrayExpr|SubLink)\z};
Branch: 1 branch
BranchTrueFalseTotal
unless $last_type =~ /\A(?:A_ArrayExpr|SubLink)\z/u 0 4 4
82 }
83  
84 47 return $self;
85 }
86  
87 102 ▶sub func_name {
Subroutine func_name: called CC=2 SCAR=6.9
Pod documented
88 102 my $self = shift;
89 102 ▶ unless ( exists $self->{ '_funcname' } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"_funcname"}) 47 55 102
90 47 $self->{ '_funcname' } = join '.', map { $_->as_ident } @{ $self->{ 'funcname' } };
91 }
92 102 return $self->{ '_funcname' };
93 }
94  
95 58 ▶sub over_clause_as_text {
Subroutine over_clause_as_text: called CC=5 SCAR=16.1
Pod documented
96 58 my $self = shift;
97 58 ▶ return unless exists $self->{ 'over' };
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"over"} 47 11 58
98  
99 # shortcut
100 11 my $O = $self->{ 'over' };
101  
102 # Build the clause from parts, as it's simpler that way.
103 11 my @parts = ();
104  
105 11 ▶ if ( exists $O->{ 'partitionClause' } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $O->{"partitionClause"}) 9 2 11
106 9 push @parts, 'PARTITION BY ' . join( ', ', map { $_->as_text } @{ $O->{ 'partitionClause' } } );
107 }
108 11 ▶ if ( exists $O->{ 'orderClause' } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $O->{"orderClause"}) 9 2 11
109 9 push @parts, 'ORDER BY ' . join( ', ', map { $_->as_text } @{ $O->{ 'orderClause' } } );
110 }
111  
112 # If there is no frame clause it will be empty array, so nothing will get pushed.
113 11 push @parts, $self->frame_clause();
114  
115 # Shortcut for over without clauses
116 11 ▶ return ' OVER ()' if 0 == scalar @parts;
Branch: 1 branch
BranchTrueFalseTotal
if 0 == scalar @parts 1 10 11
117  
118 10 return sprintf( ' OVER ( %s )', join( ' ', @parts ) );
119 }
120  
121 42 ▶sub over_clause_pretty {
Subroutine over_clause_pretty: called CC=6 SCAR=17.9
Pod documented
122 42 my $self = shift;
123 42 ▶ return unless exists $self->{ 'over' };
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"over"} 31 11 42
124  
125 # shortcut
126 11 my $O = $self->{ 'over' };
127  
128 # Build the clause from parts, as it's simpler that way.
129 11 my @parts = ();
130  
131 11 ▶ if ( exists $O->{ 'partitionClause' } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $O->{"partitionClause"}) 9 2 11
132 9 push @parts, 'PARTITION BY ' . join( ', ', map { $_->pretty_print } @{ $O->{ 'partitionClause' } } );
133 }
134 11 ▶ if ( exists $O->{ 'orderClause' } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $O->{"orderClause"}) 9 2 11
135 9 push @parts, 'ORDER BY ' . join( ', ', map { $_->pretty_print } @{ $O->{ 'orderClause' } } );
136 }
137  
138 # If there is no frame clause it will be empty array, so nothing will get pushed.
139 11 push @parts, $self->frame_clause();
140  
141 # Shortcut for over without clauses
142 11 ▶ return ' OVER ()' if 0 == scalar @parts;
Branch: 1 branch
BranchTrueFalseTotal
if 0 == scalar @parts 1 10 11
143  
144 # Shortcut for over with just 1 clause
145 10 ▶ return sprintf( ' OVER ( %s )', $parts[ 0 ] ) if 1 == scalar @parts;
Branch: 1 branch
BranchTrueFalseTotal
if 1 == scalar @parts 2 8 10
146  
147 8 my @lines = ();
148 8 push @lines, ' OVER (';
149 8 push @lines, map { $self->increase_indent( $_ ) } @parts;
150 8 push @lines, ')';
151 8 return join( "\n", @lines );
152 }
153  
154 22 ▶sub frame_clause {
Subroutine frame_clause: called CC=18 SCAR=29.6
Pod documented
155 22 my $self = shift;
156  
157 # shortcuts
158 22 my $O = $self->{ 'over' };
159 22 my $FO = $O->{ 'frameOptions' };
160  
161 # Make sure it's called for FuncCalls with some frameOptions.
162 22 ▶ return unless defined $FO;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $FO 0 22 22
163  
164 # Make sure the frameOptions are not default.
165 22 ▶ return unless $FO & $FRAMEOPTION_NONDEFAULT;
Branch: 1 branch
BranchTrueFalseTotal
unless $FO & $Pg::SQL::PrettyPrinter::Node::FuncCall::FRAMEOPTION_NONDEFAULT 8 14 22
166  
167 14 my @elements = ();
168  
169 # Frame based off what? range? rows? groups?
170 14 ▶ if ( $FO & $FRAMEOPTION_RANGE ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($FO & $Pg::SQL::PrettyPrinter::Node::FuncCall::FRAMEOPTION_RANGE) { } 4 10 14
elsif ($FO & $Pg::SQL::PrettyPrinter::Node::FuncCall::FRAMEOPTION_ROWS) { } 8 2 10
elsif ($FO & $Pg::SQL::PrettyPrinter::Node::FuncCall::FRAMEOPTION_GROUPS) { } 2 0 2
171 4 push @elements, 'RANGE';
172 }
173 elsif ( $FO & $FRAMEOPTION_ROWS ) {
174 8 push @elements, 'ROWS';
175 }
176 elsif ( $FO & $FRAMEOPTION_GROUPS ) {
177 2 push @elements, 'GROUPS';
178 }
179 else {
180 0 croak( "Bad (#1) frameOptions: $FO" );
181 }
182  
183 # Calculate start clause, as it's used in both between and just-start frames
184 14 my $start_clause;
185 14 ▶ if ( $FO & $FRAMEOPTION_START_UNBOUNDED_PRECEDING ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($FO & $Pg::SQL::PrettyPrinter::Node::FuncCall::FRAMEOPTION_START_UNBOUNDED_PRECEDING) { } 4 10 14
elsif ($FO & $Pg::SQL::PrettyPrinter::Node::FuncCall::FRAMEOPTION_START_CURRENT_ROW) { } 2 8 10
elsif ($FO & $Pg::SQL::PrettyPrinter::Node::FuncCall::FRAMEOPTION_START_OFFSET_PRECEDING) { } 6 2 8
elsif ($FO & $Pg::SQL::PrettyPrinter::Node::FuncCall::FRAMEOPTION_START_OFFSET_FOLLOWING) { } 2 0 2
186 4 $start_clause = 'UNBOUNDED PRECEDING';
187 }
188 elsif ( $FO & $FRAMEOPTION_START_CURRENT_ROW ) {
189 2 $start_clause = 'CURRENT ROW';
190 }
191 elsif ( $FO & $FRAMEOPTION_START_OFFSET_PRECEDING ) {
192 6 $start_clause = $self->{ 'over' }->{ 'startOffset' }->as_text . ' PRECEDING';
193 }
194 elsif ( $FO & $FRAMEOPTION_START_OFFSET_FOLLOWING ) {
195 2 $start_clause = $self->{ 'over' }->{ 'startOffset' }->as_text . ' FOLLOWING';
196 }
197 else {
198 0 croak( "Bad (#2) frameOptions: $FO" );
199 }
200  
201 14 ▶ if ( $FO & $FRAMEOPTION_BETWEEN ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($FO & $Pg::SQL::PrettyPrinter::Node::FuncCall::FRAMEOPTION_BETWEEN) { } 4 10 14
202  
203 # It's frame with BETWEEN operation. It needs end_clause and proper format ...
204 4 my $end_clause = '';
205 4 ▶ if ( $FO & $FRAMEOPTION_END_UNBOUNDED_FOLLOWING ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($FO & $Pg::SQL::PrettyPrinter::Node::FuncCall::FRAMEOPTION_END_UNBOUNDED_FOLLOWING) { } 2 2 4
elsif ($FO & $Pg::SQL::PrettyPrinter::Node::FuncCall::FRAMEOPTION_END_CURRENT_ROW) { } 0 2 2
elsif ($FO & $Pg::SQL::PrettyPrinter::Node::FuncCall::FRAMEOPTION_END_OFFSET_PRECEDING) { } 0 2 2
elsif ($FO & $Pg::SQL::PrettyPrinter::Node::FuncCall::FRAMEOPTION_END_OFFSET_FOLLOWING) { } 2 0 2
206 2 $end_clause = 'UNBOUNDED FOLLOWING';
207 }
208 elsif ( $FO & $FRAMEOPTION_END_CURRENT_ROW ) {
209 0 $end_clause = 'CURRENT ROW';
210 }
211 elsif ( $FO & $FRAMEOPTION_END_OFFSET_PRECEDING ) {
212 0 $end_clause = $self->{ 'over' }->{ 'endOffset' }->as_text . ' PRECEDING';
213 }
214 elsif ( $FO & $FRAMEOPTION_END_OFFSET_FOLLOWING ) {
215 2 $end_clause = $self->{ 'over' }->{ 'endOffset' }->as_text . ' FOLLOWING';
216 }
217 else {
218 0 croak( "Bad (#3) frameOptions: $FO" );
219 }
220  
221 # Put the elements of between clause together.
222 4 push @elements, 'BETWEEN';
223 4 push @elements, $start_clause;
224 4 push @elements, 'AND';
225 4 push @elements, $end_clause;
226 }
227 else {
228 # If it's not BETWEEN frame, just put start clause to output
229 10 push @elements, $start_clause;
230 }
231  
232 # Handle excludes in the frame.
233 14 ▶ if ( $FO & $FRAMEOPTION_EXCLUDE_CURRENT_ROW ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($FO & $Pg::SQL::PrettyPrinter::Node::FuncCall::FRAMEOPTION_EXCLUDE_CURRENT_ROW) { } 2 12 14
elsif ($FO & $Pg::SQL::PrettyPrinter::Node::FuncCall::FRAMEOPTION_EXCLUDE_GROUP) { } 2 10 12
elsif ($FO & $Pg::SQL::PrettyPrinter::Node::FuncCall::FRAMEOPTION_EXCLUDE_TIES) { } 2 8 10
234 2 push @elements, 'EXCLUDE CURRENT ROW';
235 }
236 elsif ( $FO & $FRAMEOPTION_EXCLUDE_GROUP ) {
237 2 push @elements, 'EXCLUDE GROUP';
238 }
239 elsif ( $FO & $FRAMEOPTION_EXCLUDE_TIES ) {
240 2 push @elements, 'EXCLUDE TIES';
241 }
242  
243 14 return join( ' ', @elements );
244 }
245  
246 58 ▶sub as_text {
Subroutine as_text: called CC=10 SCAR=23.6
Pod documented
247 58 my $self = shift;
248  
249 58 ▶ my $suffix = $self->over_clause_as_text // '';
Condition100%2/2
$self->over_clause_as_text // ""
l!l
1147
MC/DC100%1/1
$self->over_clause_as_text // ""
$self->over_clause_as_text
Truth table100%2/2
A
A= $self->over_clause_as_text
Aresult
11
00
250 58 ▶ if ( exists $self->{ 'agg_filter' } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"agg_filter"}) 0 58 58
251 0 $suffix .= ' FILTER ( WHERE ' . $self->{ 'agg_filter' }->as_text . ' )';
252 }
253 58 my $agg_order = $self->get_agg_order();
254  
255 58 ▶ if ( $self->{ 'agg_star' } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"agg_star"}) 8 50 58
256 8 ▶ my $internal = $agg_order ? " * ${agg_order} " : '*';
Branch: 1 branch
BranchTrueFalseTotal
$agg_order ? : 0 8 8
257 8 return sprintf( '%s(%s)%s', $self->func_name, $internal, $suffix );
258 }
259 50 ▶ unless ( exists $self->{ 'args' } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"args"}) 3 47 50
260 3 ▶ return $self->func_name . '()' . $suffix unless $agg_order;
Branch: 1 branch
BranchTrueFalseTotal
unless $agg_order 3 0 3
261 0 return $self->func_name . "( ${agg_order} )" . $suffix;
262 }
263  
264 47 my @args_as_text = map { $_->as_text } @{ $self->{ 'args' } };
265 47 ▶ if ( $self->{ 'func_variadic' } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"func_variadic"}) 4 43 47
266 4 $args_as_text[ -1 ] = 'VARIADIC ' . $args_as_text[ -1 ];
267 }
268 47 my $args_str = join( ', ', @args_as_text );
269 47 ▶ $args_str .= ' ' . $agg_order if $agg_order;
Branch: 1 branch
BranchTrueFalseTotal
if $agg_order 0 47 47
270 47 ▶ $args_str = 'DISTINCT ' . $args_str if $self->{ 'agg_distinct' };
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"agg_distinct"} 0 47 47
271 47 return $self->func_name . '( ' . $args_str . ' )' . $suffix;
272 }
273  
274 100 ▶sub get_agg_order {
Subroutine get_agg_order: called CC=2 SCAR=10.1
Pod documented
275 100 my $self = shift;
276 100 ▶ return '' unless exists $self->{ 'agg_order' };
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"agg_order"} 100 0 100
277 0 return sprintf( 'ORDER BY %s', join( ', ', map { $_->as_text } @{ $self->{ 'agg_order' } } ) );
278 }
279  
280 42 ▶sub pretty_print {
Subroutine pretty_print: called CC=15 SCAR=27.7
Pod documented
281 42 my $self = shift;
282  
283 42 ▶ my $suffix = $self->over_clause_pretty // '';
Condition100%2/2
$self->over_clause_pretty // ""
l!l
1131
MC/DC100%1/1
$self->over_clause_pretty // ""
$self->over_clause_pretty
Truth table100%2/2
A
A= $self->over_clause_pretty
Aresult
11
00
284 42 ▶ if ( exists $self->{ 'agg_filter' } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"agg_filter"}) 0 42 42
285 0 $suffix .= ' FILTER ( WHERE ' . $self->{ 'agg_filter' }->as_text . ' )';
286 }
287 42 my $agg_order = $self->get_agg_order();
288  
289 42 ▶ if ( $self->{ 'agg_star' } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"agg_star"}) 7 35 42
290 7 ▶ my $internal = $agg_order ? " * ${agg_order} " : '*';
Branch: 1 branch
BranchTrueFalseTotal
$agg_order ? : 0 7 7
291 7 return sprintf( '%s(%s)%s', $self->func_name, $internal, $suffix );
292 }
293 35 ▶ unless ( exists $self->{ 'args' } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"args"}) 3 32 35
294 3 ▶ return $self->func_name . '()' . $suffix unless $agg_order;
Branch: 1 branch
BranchTrueFalseTotal
unless $agg_order 3 0 3
295 0 return $self->func_name . "( ${agg_order} )" . $suffix;
296 }
297  
298 32 my @args_as_text = map { $_->as_text } @{ $self->{ 'args' } };
299 32 ▶ if ( $self->{ 'func_variadic' } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"func_variadic"}) 4 28 32
300 4 $args_as_text[ -1 ] = 'VARIADIC ' . $args_as_text[ -1 ];
301 }
302 32 my $args_str = join( ', ', @args_as_text );
303 32 ▶ $args_str .= ' ' . $agg_order if $agg_order;
Branch: 1 branch
BranchTrueFalseTotal
if $agg_order 0 32 32
304 32 ▶ if ( ( 1 == scalar @{ $self->{ 'args' } } )
Branch: 1 branch
BranchTrueFalseTotal
if (1 == scalar @{$self->{"args"};} and 40 > length $args_str) 19 13 32
Condition100%3/3
1 == scalar @{$self->{"args"};} and 40 > length $args_str
!ll&&!rl&&r
11219
MC/DC100%2/2
1 == scalar @{$self->{"args"};} and 40 > length $args_str
1 == scalar @{$self->{"args"};} 40 > length $args_str
Truth table100%3/3
A and B
A= 1 == scalar @{$self->{"args"};}B= 40 > length $args_str
ABresult
0X0
100
111
305 && ( 40 > length( $args_str ) ) )
306 {
307 19 ▶ if ( $self->{ 'agg_distinct' } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"agg_distinct"}) 0 19 19
308 0 $args_str = 'DISTINCT ' . $args_str;
309 }
310 19 return $self->func_name . '( ' . $args_str . ' )' . $suffix;
311 }
312 13 my @lines = ();
313 13 push @lines, $self->func_name . '(';
314 13 my @args_pp = map { $_->pretty_print } @{ $self->{ 'args' } };
315 13 ▶ if ( $self->{ 'func_variadic' } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"func_variadic"}) 3 10 13
316 3 $args_pp[ -1 ] = 'VARIADIC ' . $args_pp[ -1 ];
317 }
318 13 ▶ if ( $self->{ 'agg_distinct' } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"agg_distinct"}) 0 13 13
319 0 $args_pp[ 0 ] = 'DISTINCT ' . $args_pp[ 0 ];
320 }
321 13 push @lines, map { $self->increase_indent( $_ ) . ',' } @args_pp;
322 13 $lines[ -1 ] =~ s/,\z//;
323 13 ▶ push @lines, $self->increase_indent( $agg_order ) if $agg_order;
Branch: 1 branch
BranchTrueFalseTotal
if $agg_order 0 13 13
324 13 push @lines, ')' . $suffix;
325 13 return join( "\n", @lines );
326 }
327  
328 4 1;
« PrettyPrinter/Node/A_Expr.pm ↑ Summary PrettyPrinter/Node/TransactionStmt.pm »