push @arg_final, $arg;
}
}
- my @sql = ('(', map +($self->_render($_), $op_name), @arg_final);
- $sql[-1] = ')'; # replace final AND or whatever with )
- \@sql;
+ [ '(',
+ intersperse(
+ $self->_format_keyword($op_name),
+ map $self->_render($_), @arg_final
+ ),
+ ')'
+ ];
}
sub _handle_op_type_in {
my ($self, $op, $dq) = @_;
my ($lhs, @in) = @{$dq->{args}};
- my @rhs = ('(', map +($self->_render($_), ','), @in);
- $rhs[-1] = ')';
- [ $self->_render($lhs), $op, @rhs ];
+ [ $self->_render($lhs),
+ $op,
+ '(',
+ intersperse(',', map $self->_render($_), @in),
+ ')'
+ ];
}
sub _handle_op_type_between {
};
[
"$ident(",
- (map $self->_render($_), @args),
+ intersperse(',', map $self->_render($_), @args),
')'
]
}
# it is, in fact, completely valid for there to be nothing for us
# to project from since many databases handle 'SELECT 1;' fine
- my @select = map [
- ($_->{type} eq DQ_ALIAS
- ? $self->_render_alias($_, $self->_format_keyword('AS'))
- : $self->_render($_)
- ),
- ','
- ], @{$dq->{select}};
-
- # we put the commas inside the [] for each entry as a hint to the pretty
- # printer downstream so now we need to eliminate the comma from the last
- # entry - we know there always is one due to the die guard at the top
-
- pop @{$select[-1]};
+ my @select = intersperse(',',
+ map +($_->{type} eq DQ_ALIAS
+ ? $self->_render_alias($_, $self->_format_keyword('AS'))
+ : $self->_render($_)), @{$dq->{select}}
+ );
return [
$self->_format_keyword('SELECT'),