=over 4
-=item Arguments: none
+=item Arguments: See L<DBIx::Class::ResultSet/as_query>
=item Return Value: \[ $sql, @bind ]
=cut
sub as_query {
- my $self = shift;
+ my ( $self, $opts ) = @_;
+
+ $self->throw_exception( "as_query needs a hashref" )
+ if defined $opts and ref $opts ne 'HASH';
+
+ $opts->{skip_parens} ||= 0;
my $storage = $self->{storage};
my $sql_maker = $storage->sql_maker;
my @args = $storage->_select_args(@{$self->{args}});
my ($sql, $bind) = $storage->_prep_for_execute(@args[0 .. 2], [@args[4 .. $#args]]);
- return \[ "($sql)", @$bind ];
+ $sql = "($sql)" unless $opts->{skip_parens};
+ return \[ $sql, @$bind ];
}
=head2 next