[Bast-commits] r5947 - in DBIx-Class/0.08/branches/prepare_cached/lib/DBIx/Class: . Storage

solomon at dev.catalyst.perl.org solomon at dev.catalyst.perl.org
Wed Apr 22 21:47:21 GMT 2009


Author: solomon
Date: 2009-04-22 22:47:21 +0100 (Wed, 22 Apr 2009)
New Revision: 5947

Modified:
   DBIx-Class/0.08/branches/prepare_cached/lib/DBIx/Class/Row.pm
   DBIx-Class/0.08/branches/prepare_cached/lib/DBIx/Class/Storage/DBI.pm
Log:
Progress on making prepare_cached work on insert/update/delete statements and backward compatibility; far from complete

Modified: DBIx-Class/0.08/branches/prepare_cached/lib/DBIx/Class/Row.pm
===================================================================
--- DBIx-Class/0.08/branches/prepare_cached/lib/DBIx/Class/Row.pm	2009-04-22 17:51:54 UTC (rev 5946)
+++ DBIx-Class/0.08/branches/prepare_cached/lib/DBIx/Class/Row.pm	2009-04-22 21:47:21 UTC (rev 5947)
@@ -19,7 +19,7 @@
       : sub () { 0 };
 }
 
-__PACKAGE__->mk_group_accessors('simple' => qw/_source_handle/);
+__PACKAGE__->mk_group_accessors('simple' => qw/_source_handle prepare_cached/);
 
 =head1 NAME
 
@@ -155,6 +155,10 @@
     $new->result_source($source);
   }
 
+  if (my $prepare_cached = delete $attrs->{-prepare_cached}) {
+    $new->prepare_cached($prepare_cached);
+  }
+
   if (my $related = delete $attrs->{-from_resultset}) {
     @{$new->{_ignore_at_insert}={}}{@$related} = ();
   }
@@ -325,7 +329,7 @@
     no warnings 'uninitialized';
     warn "MC $self inserting (".join(', ', $self->get_columns).")\n";
   };
-  my $updated_cols = $source->storage->insert($source, { $self->get_columns });
+  my $updated_cols = $source->storage->insert($source, { $self->get_columns }, $self->prepare_cached);
   foreach my $col (keys %$updated_cols) {
     $self->store_column($col, $updated_cols->{$col});
   }
@@ -488,7 +492,7 @@
   my %to_update = $self->get_dirty_columns;
   return $self unless keys %to_update;
   my $rows = $self->result_source->storage->update(
-               $self->result_source, \%to_update,
+               $self->result_source, $self->prepare_cached, \%to_update,
                $self->{_orig_ident} || $ident_cond
              );
   if ($rows == 0) {
@@ -553,7 +557,7 @@
               unless exists $self->{_column_data}{$column};
     }
     $self->result_source->storage->delete(
-      $self->result_source, $ident_cond);
+      $self->result_source, $self->prepare_cached, $ident_cond);
     $self->in_storage(undef);
   } else {
     $self->throw_exception("Can't do class delete without a ResultSource instance")

Modified: DBIx-Class/0.08/branches/prepare_cached/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/branches/prepare_cached/lib/DBIx/Class/Storage/DBI.pm	2009-04-22 17:51:54 UTC (rev 5946)
+++ DBIx-Class/0.08/branches/prepare_cached/lib/DBIx/Class/Storage/DBI.pm	2009-04-22 21:47:21 UTC (rev 5947)
@@ -20,7 +20,7 @@
 # the values for these accessors are picked out (and deleted) from
 # the attribute hashref passed to connect_info
 my @storage_options = qw/
-  on_connect_do on_disconnect_do prepare_cached unsafe auto_savepoint
+  on_connect_do on_disconnect_do disable_sth_caching prepare_cached unsafe auto_savepoint
 /;
 __PACKAGE__->mk_group_accessors('simple' => @storage_options);
 
@@ -652,8 +652,6 @@
 
   $self->prepare_cached(1); # Default prepare_cached to enabled
   if(keys %attrs) {
-    $attrs{prepare_cached} = ! $attrs{disable_sth_caching}
-      if exists $attrs{disable_sth_caching};
     $self->$_(delete $attrs{$_})
       for grep {exists $attrs{$_}} (@storage_options, 'cursor_class');   # @storage_options is declared at the top of the module
     $self->_sql_maker_opts->{$_} = delete $attrs{$_}
@@ -1279,7 +1277,7 @@
 }
 
 sub insert {
-  my ($self, $source, $to_insert) = @_;
+  my ($self, $source, $to_insert, $prepare_cached) = @_;
   
   my $ident = $source->from; 
   my $bind_attributes = $self->source_bind_attributes($source);
@@ -1295,7 +1293,7 @@
     }
   }
 
-  $self->_execute('insert' => [], $source, $bind_attributes, $self->prepare_cached, $to_insert);
+  $self->_execute('insert' => [], $source, $bind_attributes, $prepare_cached, $to_insert);
 
   return $to_insert;
 }
@@ -1356,19 +1354,21 @@
 sub update {
   my $self = shift @_;
   my $source = shift @_;
+  my $prepare_cached = shift @_;
   my $bind_attributes = $self->source_bind_attributes($source);
   
-  return $self->_execute('update' => [], $source, $bind_attributes, $self->prepare_cached, @_);
+  return $self->_execute('update' => [], $source, $bind_attributes, $prepare_cached, @_);
 }
 
 
 sub delete {
   my $self = shift @_;
   my $source = shift @_;
+  my $prepare_cached = shift @_;
   
   my $bind_attrs = {}; ## If ever it's needed...
   
-  return $self->_execute('delete' => [], $source, $bind_attrs, $self->prepare_cached, @_);
+  return $self->_execute('delete' => [], $source, $bind_attrs, $prepare_cached, @_);
 }
 
 sub _select {




More information about the Bast-commits mailing list