X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FCursor.pm;h=454738cebbe7c4c44f39828963a801fe772d2c75;hb=0f6fc7050c1f6120a1bae77ec57def4e965ac332;hp=60df3792a0e262ec9e19cba2c72a42bfe8456398;hpb=e10ae5b2fe46e1ba718c918d61d4539afcc97763;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/Cursor.pm b/lib/DBIx/Class/Storage/DBI/Cursor.pm index 60df379..454738c 100644 --- a/lib/DBIx/Class/Storage/DBI/Cursor.pm +++ b/lib/DBIx/Class/Storage/DBI/Cursor.pm @@ -53,7 +53,7 @@ sub new { =over 4 -=item Arguments: none +=item Arguments: See L =item Return Value: \[ $sql, @bind ] @@ -64,7 +64,12 @@ Returns the SQL statement and bind vars associated with the invocant. =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; @@ -72,7 +77,8 @@ sub as_query { 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