Methods update/delete on resultset use now new as_query method to updated/delete...
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / Cursor.pm
index 60df379..454738c 100644 (file)
@@ -53,7 +53,7 @@ sub new {
 
 =over 4
 
-=item Arguments: none
+=item Arguments: See L<DBIx::Class::ResultSet/as_query>
 
 =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