Skip to content

Commit cd7bc94

Browse files
authored
Merge pull request #387 from bkircher/fixes
fixes
2 parents 3e39cbe + 703afed commit cd7bc94

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

lib/pgFormatter/Beautify.pm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,12 @@ s/AS ('[^\']+')\s*,\s*('[^\']+')/AS CODEPARTB${i}CODEPARTB/is
404404
}
405405
$self->{'query'} = join( '', @temp_content );
406406

407+
# replace all inline dollar-quoted constants
408+
while ( $self->{'query'} =~ s/(\$\$\S[^\n\r]*?\$\$)/AAKEYWCONST${j}AA/s ) {
409+
$self->{'keyword_constant'}{$j} = $1;
410+
$j++;
411+
}
412+
407413
# Store values of code that must not be changed following the given placeholder
408414
if ( $self->{'placeholder'} ) {
409415
if ( !$self->{'multiline'} ) {
@@ -2218,7 +2224,7 @@ sub beautify {
22182224
if ( !$self->{'wrap_after'} && !$self->{'_is_in_overlaps'} );
22192225
$self->_add_token($token);
22202226
$last = $self->_set_last( $token, $last )
2221-
if ( $token ne ')' or uc( $self->_next_token ) ne 'AS' );
2227+
if ( $token ne ')' or (defined $self->_next_token and uc( $self->_next_token ) ne 'AS') );
22222228
$self->{'_is_in_explain'} = 0;
22232229
next;
22242230
}

t/test-files/expected/ex77.sql

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,5 @@ $$
6969
LANGUAGE plpgsql;
7070

7171
SELECT
72-
throws_ok ($$
73-
SELECT
74-
* FROM custom_function ('value1', 'value2');
75-
76-
$$,
77-
'P0001',
78-
'NULL password for new user: app21_user',
79-
$e$ NULL PASSWORD FOR new user: app21_user $e$);
72+
throws_ok ($$select * from custom_function('value1', 'value2');$$, 'P0001', 'NULL password for new user: app21_user', $e$ NULL PASSWORD FOR new user: app21_user $e$);
8073

0 commit comments

Comments
 (0)