line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pg::SQL::PrettyPrinter::Node::SelectStmt; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# UTF8 boilerplace, per http://stackoverflow.com/questions/6162484/why-does-modern-perl-avoid-utf-8-by-default/ |
4
|
10
|
|
|
10
|
|
6374
|
use v5.26; |
|
10
|
|
|
|
|
50
|
|
5
|
10
|
|
|
10
|
|
56
|
use strict; |
|
10
|
|
|
|
|
22
|
|
|
10
|
|
|
|
|
230
|
|
6
|
10
|
|
|
10
|
|
56
|
use warnings; |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
305
|
|
7
|
10
|
|
|
10
|
|
49
|
use warnings qw( FATAL utf8 ); |
|
10
|
|
|
|
|
22
|
|
|
10
|
|
|
|
|
356
|
|
8
|
10
|
|
|
10
|
|
55
|
use utf8; |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
53
|
|
9
|
10
|
|
|
10
|
|
299
|
use open qw( :std :utf8 ); |
|
10
|
|
|
|
|
34
|
|
|
10
|
|
|
|
|
61
|
|
10
|
10
|
|
|
10
|
|
1655
|
use Unicode::Normalize qw( NFC ); |
|
10
|
|
|
|
|
42
|
|
|
10
|
|
|
|
|
673
|
|
11
|
10
|
|
|
10
|
|
169
|
use Unicode::Collate; |
|
10
|
|
|
|
|
74
|
|
|
10
|
|
|
|
|
432
|
|
12
|
10
|
|
|
10
|
|
67
|
use Encode qw( decode ); |
|
10
|
|
|
|
|
23
|
|
|
10
|
|
|
|
|
637
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
if ( grep /\P{ASCII}/ => @ARGV ) { |
15
|
|
|
|
|
|
|
@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
|
10
|
|
|
10
|
|
2809
|
use autodie; |
|
10
|
|
|
|
|
26
|
|
|
10
|
|
|
|
|
71
|
|
24
|
10
|
|
|
10
|
|
55173
|
use Carp qw( carp croak confess cluck ); |
|
10
|
|
|
|
|
40
|
|
|
10
|
|
|
|
|
840
|
|
25
|
10
|
|
|
10
|
|
84
|
use English qw( -no_match_vars ); |
|
10
|
|
|
|
|
29
|
|
|
10
|
|
|
|
|
73
|
|
26
|
10
|
|
|
10
|
|
3936
|
use Data::Dumper qw( Dumper ); |
|
10
|
|
|
|
|
22
|
|
|
10
|
|
|
|
|
2240
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# give a full stack dump on any untrapped exceptions |
29
|
|
|
|
|
|
|
local $SIG{ __DIE__ } = sub { |
30
|
|
|
|
|
|
|
confess "Uncaught exception: @_" unless $^S; |
31
|
|
|
|
|
|
|
}; |
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
|
|
|
|
|
|
|
local $SIG{ __WARN__ } = sub { |
37
|
|
|
|
|
|
|
if ( $^S ) { cluck "Trapped warning: @_" } |
38
|
|
|
|
|
|
|
else { confess "Deadly warning: @_" } |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Useful common code |
42
|
|
|
|
|
|
|
|
43
|
10
|
|
|
10
|
|
79
|
use parent qw( Pg::SQL::PrettyPrinter::Node ); |
|
10
|
|
|
|
|
19
|
|
|
10
|
|
|
|
|
67
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub new { |
46
|
118
|
|
|
118
|
1
|
4131
|
my $class = shift; |
47
|
118
|
|
|
|
|
458
|
my $self = $class->SUPER::new( @_ ); |
48
|
118
|
|
|
|
|
269
|
bless $self, $class; |
49
|
|
|
|
|
|
|
|
50
|
118
|
|
|
|
|
626
|
$self->objectify( |
51
|
|
|
|
|
|
|
'valuesLists', |
52
|
|
|
|
|
|
|
[ 'withClause', 'ctes' ], |
53
|
|
|
|
|
|
|
); |
54
|
118
|
100
|
|
|
|
749
|
if ( $self->setop ) { |
55
|
5
|
|
|
|
|
22
|
$self->init_setop; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
else { |
58
|
113
|
|
|
|
|
286
|
$self->init_plain; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
118
|
|
|
|
|
293
|
return $self; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub setop { |
65
|
168
|
|
|
168
|
1
|
297
|
my $self = shift; |
66
|
168
|
100
|
|
|
|
573
|
return if $self->{ 'op' } eq 'SETOP_NONE'; |
67
|
41
|
|
|
|
|
75
|
my $op = $self->{ 'op' }; |
68
|
41
|
|
|
|
|
125
|
$op =~ s/^SETOP_//; |
69
|
41
|
100
|
|
|
|
147
|
$op .= ' ALL' if $self->{ 'all' }; |
70
|
41
|
|
|
|
|
252
|
return $op; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub init_setop { |
74
|
5
|
|
|
5
|
1
|
9
|
my $self = shift; |
75
|
5
|
|
|
|
|
12
|
for my $element ( qw( rarg larg ) ) { |
76
|
10
|
|
|
|
|
38
|
$self->{ $element } = $self->make_from( { 'SelectStmt' => $self->{ $element } } ); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub init_plain { |
81
|
113
|
|
|
113
|
1
|
201
|
my $self = shift; |
82
|
|
|
|
|
|
|
|
83
|
113
|
|
|
|
|
343
|
$self->objectify( qw( targetList fromClause whereClause groupClause havingClause sortClause limitCount limitOffset distinctClause lockingClause ) ); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub as_text { |
87
|
121
|
|
|
121
|
1
|
409
|
my $self = shift; |
88
|
121
|
100
|
|
|
|
325
|
if ( exists $self->{ 'valuesLists' } ) { |
89
|
16
|
|
|
|
|
34
|
return sprintf( 'VALUES %s', join( ', ', map { $_->as_text } @{ $self->{ 'valuesLists' } } ) ); |
|
20
|
|
|
|
|
67
|
|
|
16
|
|
|
|
|
42
|
|
90
|
|
|
|
|
|
|
} |
91
|
105
|
|
|
|
|
206
|
my $prefix = ''; |
92
|
105
|
100
|
|
|
|
260
|
if ( exists $self->{ 'withClause' } ) { |
93
|
2
|
|
|
|
|
6
|
$prefix = 'WITH '; |
94
|
2
|
100
|
|
|
|
13
|
$prefix .= 'RECURSIVE ' if $self->{ 'withClause' }->{ 'recursive' }; |
95
|
2
|
|
|
|
|
13
|
$prefix .= join( ', ', map { $_->as_text } @{ $self->{ 'withClause' }->{ 'ctes' } } ) . ' '; |
|
4
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
5
|
|
96
|
|
|
|
|
|
|
} |
97
|
105
|
100
|
|
|
|
379
|
return $prefix . ( $self->{ 'op' } eq 'SETOP_NONE' ? $self->as_text_plain : $self->as_text_setop ); |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub as_text_setop { |
101
|
5
|
|
|
5
|
1
|
11
|
my $self = shift; |
102
|
5
|
|
|
|
|
9
|
my @elements = (); |
103
|
5
|
100
|
100
|
|
|
24
|
if ( ( $self->{ 'larg' }->setop // '' ) eq $self->setop ) { |
104
|
1
|
|
|
|
|
5
|
push @elements, $self->{ 'larg' }->as_text; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
else { |
107
|
4
|
|
|
|
|
25
|
push @elements, '(', $self->{ 'larg' }->as_text, ')'; |
108
|
|
|
|
|
|
|
} |
109
|
5
|
|
|
|
|
15
|
push @elements, $self->setop; |
110
|
5
|
50
|
100
|
|
|
17
|
if ( ( $self->{ 'rarg' }->setop // '' ) eq $self->setop ) { |
111
|
0
|
|
|
|
|
0
|
push @elements, $self->{ 'rarg' }->as_text; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
else { |
114
|
5
|
|
|
|
|
13
|
push @elements, '(', $self->{ 'rarg' }->as_text, ')'; |
115
|
|
|
|
|
|
|
} |
116
|
5
|
|
|
|
|
36
|
return join( " ", @elements ); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub as_text_plain { |
120
|
100
|
|
|
100
|
1
|
177
|
my $self = shift; |
121
|
100
|
|
|
|
|
186
|
my $query = 'SELECT '; |
122
|
100
|
100
|
|
|
|
233
|
if ( exists $self->{ 'distinctClause' } ) { |
123
|
2
|
100
|
|
|
|
8
|
if ( 0 == scalar @{ $self->{ 'distinctClause' } } ) { |
|
2
|
|
|
|
|
20
|
|
124
|
1
|
|
|
|
|
3
|
$query .= 'DISTINCT '; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
else { |
127
|
|
|
|
|
|
|
$query .= sprintf( |
128
|
|
|
|
|
|
|
'DISTINCT ON ( %s ) ', |
129
|
1
|
|
|
|
|
4
|
join( ', ', map { $_->as_text } @{ $self->{ 'distinctClause' } } ) |
|
2
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
3
|
|
130
|
|
|
|
|
|
|
); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
} |
133
|
100
|
|
|
|
|
183
|
$query .= join( ', ', map { $_->as_text } @{ $self->{ 'targetList' } } ); |
|
239
|
|
|
|
|
625
|
|
|
100
|
|
|
|
|
267
|
|
134
|
100
|
100
|
|
|
|
314
|
if ( exists $self->{ 'fromClause' } ) { |
135
|
62
|
|
|
|
|
131
|
$query .= ' FROM ' . join( ', ', map { $_->as_text } @{ $self->{ 'fromClause' } } ); |
|
64
|
|
|
|
|
212
|
|
|
62
|
|
|
|
|
145
|
|
136
|
|
|
|
|
|
|
} |
137
|
100
|
100
|
|
|
|
283
|
if ( exists $self->{ 'whereClause' } ) { |
138
|
10
|
|
|
|
|
51
|
$query .= ' WHERE ' . $self->{ 'whereClause' }->as_text; |
139
|
|
|
|
|
|
|
} |
140
|
100
|
100
|
|
|
|
244
|
if ( exists $self->{ 'groupClause' } ) { |
141
|
5
|
|
|
|
|
10
|
$query .= ' GROUP BY ' . join( ', ', map { $_->as_text } @{ $self->{ 'groupClause' } } ); |
|
6
|
|
|
|
|
21
|
|
|
5
|
|
|
|
|
12
|
|
142
|
|
|
|
|
|
|
} |
143
|
100
|
100
|
|
|
|
267
|
if ( exists $self->{ 'havingClause' } ) { |
144
|
1
|
|
|
|
|
6
|
$query .= ' HAVING ' . $self->{ 'havingClause' }->as_text; |
145
|
|
|
|
|
|
|
} |
146
|
100
|
100
|
|
|
|
227
|
if ( exists $self->{ 'sortClause' } ) { |
147
|
12
|
|
|
|
|
23
|
$query .= ' ORDER BY ' . join( ', ', map { $_->as_text } @{ $self->{ 'sortClause' } } ); |
|
22
|
|
|
|
|
63
|
|
|
12
|
|
|
|
|
30
|
|
148
|
|
|
|
|
|
|
} |
149
|
100
|
100
|
|
|
|
245
|
if ( exists $self->{ 'limitCount' } ) { |
150
|
10
|
|
|
|
|
40
|
$query .= ' LIMIT ' . $self->{ 'limitCount' }->as_text; |
151
|
|
|
|
|
|
|
} |
152
|
100
|
100
|
|
|
|
271
|
if ( exists $self->{ 'limitOffset' } ) { |
153
|
1
|
|
|
|
|
6
|
$query .= ' OFFSET ' . $self->{ 'limitOffset' }->as_text; |
154
|
|
|
|
|
|
|
} |
155
|
100
|
100
|
|
|
|
235
|
if ( exists $self->{ 'lockingClause' } ) { |
156
|
|
|
|
|
|
|
$query .= ' ' . join( |
157
|
|
|
|
|
|
|
' ', |
158
|
9
|
|
|
|
|
15
|
map { $_->as_text } @{ $self->{ 'lockingClause' } } |
|
10
|
|
|
|
|
27
|
|
|
9
|
|
|
|
|
18
|
|
159
|
|
|
|
|
|
|
); |
160
|
|
|
|
|
|
|
} |
161
|
100
|
|
|
|
|
486
|
return $query; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub pretty_print { |
165
|
116
|
|
|
116
|
1
|
46060
|
my $self = shift; |
166
|
116
|
100
|
|
|
|
351
|
if ( exists $self->{ 'valuesLists' } ) { |
167
|
16
|
|
|
|
|
67
|
my @lines = (); |
168
|
16
|
|
|
|
|
52
|
push @lines, 'VALUES'; |
169
|
16
|
|
|
|
|
33
|
push @lines, map { $self->increase_indent( $_->as_text ) . ',' } @{ $self->{ 'valuesLists' } }; |
|
20
|
|
|
|
|
66
|
|
|
16
|
|
|
|
|
57
|
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
# Remove unnecessary trailing , in last element |
172
|
16
|
|
|
|
|
88
|
$lines[ -1 ] =~ s/,\z//; |
173
|
16
|
|
|
|
|
94
|
return join( "\n", @lines ); |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
100
|
100
|
|
|
|
460
|
my $main_body = $self->{ 'op' } eq 'SETOP_NONE' ? $self->pretty_print_plain : $self->pretty_print_setop; |
177
|
100
|
100
|
|
|
|
455
|
return $main_body unless exists $self->{ 'withClause' }; |
178
|
|
|
|
|
|
|
|
179
|
2
|
|
|
|
|
5
|
my @cte_def = (); |
180
|
|
|
|
|
|
|
|
181
|
2
|
|
|
|
|
6
|
push @cte_def, map { $_->pretty_print . ',' } @{ $self->{ 'withClause' }->{ 'ctes' } }; |
|
4
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
7
|
|
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
# Remove unnecessary trailing , in last element |
184
|
2
|
|
|
|
|
11
|
$cte_def[ -1 ] =~ s/,\z//; |
185
|
2
|
100
|
|
|
|
11
|
if ( $self->{ 'withClause' }->{ 'recursive' } ) { |
186
|
1
|
|
|
|
|
11
|
$cte_def[ 0 ] = 'WITH RECURSIVE ' . $cte_def[ 0 ]; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
else { |
189
|
1
|
|
|
|
|
3
|
$cte_def[ 0 ] = 'WITH ' . $cte_def[ 0 ]; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
2
|
|
|
|
|
6
|
my @lines = (); |
193
|
2
|
|
|
|
|
6
|
push @lines, join( ' ', @cte_def ); |
194
|
2
|
|
|
|
|
4
|
push @lines, $main_body; |
195
|
2
|
|
|
|
|
10
|
return join( "\n", @lines ); |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub pretty_print_setop { |
199
|
5
|
|
|
5
|
1
|
11
|
my $self = shift; |
200
|
5
|
|
|
|
|
11
|
my @elements = (); |
201
|
5
|
100
|
100
|
|
|
14
|
if ( ( $self->{ 'larg' }->setop // '' ) eq $self->setop ) { |
202
|
1
|
|
|
|
|
6
|
push @elements, $self->{ 'larg' }->pretty_print; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
else { |
205
|
4
|
|
|
|
|
9
|
push @elements, '('; |
206
|
4
|
|
|
|
|
14
|
push @elements, $self->increase_indent( $self->{ 'larg' }->pretty_print ); |
207
|
4
|
|
|
|
|
10
|
push @elements, ')'; |
208
|
|
|
|
|
|
|
} |
209
|
5
|
|
|
|
|
15
|
push @elements, $self->setop; |
210
|
5
|
50
|
100
|
|
|
12
|
if ( ( $self->{ 'rarg' }->setop // '' ) eq $self->setop ) { |
211
|
0
|
|
|
|
|
0
|
push @elements, $self->{ 'rarg' }->pretty_print; |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
else { |
214
|
5
|
|
|
|
|
13
|
push @elements, '('; |
215
|
5
|
|
|
|
|
12
|
push @elements, $self->increase_indent( $self->{ 'rarg' }->pretty_print ); |
216
|
5
|
|
|
|
|
16
|
push @elements, ')'; |
217
|
|
|
|
|
|
|
} |
218
|
5
|
|
|
|
|
27
|
return join( "\n", @elements ); |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
sub pretty_print_plain { |
222
|
95
|
|
|
95
|
1
|
178
|
my $self = shift; |
223
|
95
|
|
|
|
|
230
|
my @lines = ( 'SELECT' ); |
224
|
|
|
|
|
|
|
|
225
|
95
|
100
|
|
|
|
238
|
if ( exists $self->{ 'distinctClause' } ) { |
226
|
2
|
100
|
|
|
|
6
|
if ( 0 == scalar @{ $self->{ 'distinctClause' } } ) { |
|
2
|
|
|
|
|
8
|
|
227
|
1
|
|
|
|
|
3
|
$lines[ 0 ] .= ' DISTINCT'; |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
else { |
230
|
|
|
|
|
|
|
push @lines, sprintf( |
231
|
|
|
|
|
|
|
$self->increase_indent( 'DISTINCT ON ( %s )' ), |
232
|
1
|
|
|
|
|
5
|
join( ', ', map { $_->pretty_print } @{ $self->{ 'distinctClause' } } ) |
|
2
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
5
|
|
233
|
|
|
|
|
|
|
); |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
|
237
|
95
|
|
|
|
|
168
|
for my $i ( 0 .. $#{ $self->{ 'targetList' } } ) { |
|
95
|
|
|
|
|
324
|
|
238
|
232
|
|
|
|
|
359
|
my $is_last = $i == $#{ $self->{ 'targetList' } }; |
|
232
|
|
|
|
|
498
|
|
239
|
232
|
|
|
|
|
499
|
my $target = $self->{ 'targetList' }->[ $i ]; |
240
|
232
|
|
|
|
|
607
|
my $pretty = $self->increase_indent( $target->pretty_print() ); |
241
|
232
|
100
|
|
|
|
641
|
$pretty .= ',' unless $is_last; |
242
|
232
|
|
|
|
|
588
|
push @lines, $pretty; |
243
|
|
|
|
|
|
|
} |
244
|
95
|
100
|
|
|
|
266
|
if ( exists $self->{ 'fromClause' } ) { |
245
|
57
|
|
|
|
|
114
|
push @lines, 'FROM'; |
246
|
57
|
|
|
|
|
101
|
push @lines, map { $self->increase_indent( $_->pretty_print ) . ',' } @{ $self->{ 'fromClause' } }; |
|
59
|
|
|
|
|
201
|
|
|
57
|
|
|
|
|
137
|
|
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
# Remove unnecessary trailing , in last element |
249
|
57
|
|
|
|
|
289
|
$lines[ -1 ] =~ s/,\z//; |
250
|
|
|
|
|
|
|
} |
251
|
95
|
100
|
|
|
|
269
|
if ( exists $self->{ 'whereClause' } ) { |
252
|
9
|
|
|
|
|
21
|
push @lines, 'WHERE'; |
253
|
9
|
|
|
|
|
45
|
push @lines, $self->increase_indent( $self->{ 'whereClause' }->pretty_print ); |
254
|
|
|
|
|
|
|
} |
255
|
95
|
100
|
|
|
|
263
|
if ( exists $self->{ 'groupClause' } ) { |
256
|
5
|
|
|
|
|
12
|
push @lines, 'GROUP BY'; |
257
|
5
|
|
|
|
|
13
|
push @lines, map { $self->increase_indent( $_->pretty_print ) . ',' } @{ $self->{ 'groupClause' } }; |
|
6
|
|
|
|
|
19
|
|
|
5
|
|
|
|
|
14
|
|
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
# Remove unnecessary trailing , in last element |
260
|
5
|
|
|
|
|
24
|
$lines[ -1 ] =~ s/,\z//; |
261
|
|
|
|
|
|
|
} |
262
|
95
|
100
|
|
|
|
234
|
if ( exists $self->{ 'havingClause' } ) { |
263
|
1
|
|
|
|
|
4
|
push @lines, 'HAVING'; |
264
|
1
|
|
|
|
|
5
|
push @lines, $self->increase_indent( $self->{ 'havingClause' }->pretty_print ); |
265
|
|
|
|
|
|
|
} |
266
|
95
|
100
|
|
|
|
252
|
if ( exists $self->{ 'sortClause' } ) { |
267
|
12
|
|
|
|
|
25
|
push @lines, 'ORDER BY'; |
268
|
12
|
|
|
|
|
27
|
push @lines, map { $self->increase_indent( $_->pretty_print ) . ',' } @{ $self->{ 'sortClause' } }; |
|
22
|
|
|
|
|
67
|
|
|
12
|
|
|
|
|
28
|
|
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
# Remove unnecessary trailing , in last element |
271
|
12
|
|
|
|
|
53
|
$lines[ -1 ] =~ s/,\z//; |
272
|
|
|
|
|
|
|
} |
273
|
|
|
|
|
|
|
|
274
|
95
|
100
|
|
|
|
233
|
if ( exists $self->{ 'limitCount' } ) { |
275
|
10
|
|
|
|
|
37
|
push @lines, 'LIMIT ' . $self->{ 'limitCount' }->pretty_print; |
276
|
|
|
|
|
|
|
} |
277
|
95
|
100
|
|
|
|
225
|
if ( exists $self->{ 'limitOffset' } ) { |
278
|
1
|
|
|
|
|
4
|
push @lines, 'OFFSET ' . $self->{ 'limitOffset' }->pretty_print; |
279
|
|
|
|
|
|
|
} |
280
|
95
|
100
|
|
|
|
202
|
if ( exists $self->{ 'lockingClause' } ) { |
281
|
9
|
|
|
|
|
14
|
push @lines, map { $_->pretty_print } @{ $self->{ 'lockingClause' } }; |
|
10
|
|
|
|
|
29
|
|
|
9
|
|
|
|
|
16
|
|
282
|
|
|
|
|
|
|
} |
283
|
|
|
|
|
|
|
|
284
|
95
|
|
|
|
|
380
|
return join( "\n", @lines ); |
285
|
|
|
|
|
|
|
} |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
1; |