[Bast-commits] r8908 - in DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class: . Storage/DBI

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Sat Mar 6 16:48:18 GMT 2010


Author: caelum
Date: 2010-03-06 16:48:18 +0000 (Sat, 06 Mar 2010)
New Revision: 8908

Modified:
   DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/Row.pm
   DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/Storage/DBI/InterBase.pm
Log:
remove that code for non-pk autoincs from Row, move to ::DBI::InterBase

Modified: DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/Row.pm
===================================================================
--- DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/Row.pm	2010-03-06 12:18:01 UTC (rev 8907)
+++ DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/Row.pm	2010-03-06 16:48:18 UTC (rev 8908)
@@ -347,27 +347,6 @@
     $self->store_column($auto_pri[$_] => $ids[$_]) for 0 .. $#ids;
   }
 
-  # get non-PK auto-incs
-  {
-    my $rsrc = $self->result_source;
-    my %pk;
-    @pk{ $rsrc->primary_columns } = (); 
-
-    my @non_pk_autoincs = grep {
-      (not exists $pk{$_})
-      && (not defined $self->get_column($_))
-      && $rsrc->column_info($_)->{is_auto_increment}
-    } $rsrc->columns;
-
-    if (@non_pk_autoincs) {
-      my @ids = $rsrc->storage->last_insert_id($rsrc, @non_pk_autoincs);
-
-      if (@ids == @non_pk_autoincs) {
-        $self->store_column($non_pk_autoincs[$_] => $ids[$_]) for 0 .. $#ids;
-      }
-    }
-  }
-
   $self->{_dirty_columns} = {};
   $self->{related_resultsets} = {};
 

Modified: DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/Storage/DBI/InterBase.pm
===================================================================
--- DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/Storage/DBI/InterBase.pm	2010-03-06 12:18:01 UTC (rev 8907)
+++ DBIx-Class/0.08/branches/storage-interbase/lib/DBIx/Class/Storage/DBI/InterBase.pm	2010-03-06 16:48:18 UTC (rev 8908)
@@ -18,9 +18,9 @@
 
 =head1 DESCRIPTION
 
-This class implements autoincrements for Firebird using C<RETURNING>, sets the
-limit dialect to C<FIRST X SKIP X> and provides
-L<DBIx::Class::InflateColumn::DateTime> support.
+This class implements autoincrements for Firebird using C<RETURNING> as well as
+L<auto_nextval|DBIx::Class::ResultSource/auto_nextval> sets the limit dialect to
+C<FIRST X SKIP X> and provides L<DBIx::Class::InflateColumn::DateTime> support.
 
 You need to use either the
 L<disable_sth_caching|DBIx::Class::Storage::DBI/disable_sth_caching> option or
@@ -40,6 +40,8 @@
   my ($op, $extra_bind, $ident, $args) = @_;
 
   if ($op eq 'insert') {
+    $self->_auto_incs([]);
+
     my @pk = $ident->_pri_cols;
     my %pk;
     @pk{@pk} = ();
@@ -59,7 +61,6 @@
     if (@auto_inc_cols) {
       $args->[1]{returning} = \@auto_inc_cols;
 
-      $self->_auto_incs([]);
       $self->_auto_incs->[0] = \@auto_inc_cols;
     }
   }
@@ -155,6 +156,21 @@
   return @result;
 }
 
+sub insert {
+  my $self = shift;
+
+  my $updated_cols = $self->next::method(@_);
+
+  if ($self->_auto_incs->[0]) {
+    my %auto_incs;
+    @auto_incs{ @{ $self->_auto_incs->[0] } } = @{ $self->_auto_incs->[1] };
+
+    $updated_cols = { %$updated_cols, %auto_incs };
+  }
+
+  return $updated_cols;
+}
+
 # this sub stolen from DB2
 
 sub _sql_maker_opts {




More information about the Bast-commits mailing list