From: Rafael Kitover Date: Sat, 6 Mar 2010 16:48:18 +0000 (+0000) Subject: remove that code for non-pk autoincs from Row, move to ::DBI::InterBase X-Git-Tag: v0.08121~73^2~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=95570280e2003f08075f5195b5932c46c3155af2;p=dbsrgits%2FDBIx-Class.git remove that code for non-pk autoincs from Row, move to ::DBI::InterBase --- diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index fef3034..ebde5d9 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -347,27 +347,6 @@ sub insert { $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} = {}; diff --git a/lib/DBIx/Class/Storage/DBI/InterBase.pm b/lib/DBIx/Class/Storage/DBI/InterBase.pm index 6fd783f..7487bd9 100644 --- a/lib/DBIx/Class/Storage/DBI/InterBase.pm +++ b/lib/DBIx/Class/Storage/DBI/InterBase.pm @@ -18,9 +18,9 @@ DBIx::Class::Storage::DBI::InterBase - Driver for the Firebird RDBMS =head1 DESCRIPTION -This class implements autoincrements for Firebird using C, sets the -limit dialect to C and provides -L support. +This class implements autoincrements for Firebird using C as well as +L sets the limit dialect to +C and provides L support. You need to use either the L option or @@ -40,6 +40,8 @@ sub _prep_for_execute { 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 @@ sub _prep_for_execute { if (@auto_inc_cols) { $args->[1]{returning} = \@auto_inc_cols; - $self->_auto_incs([]); $self->_auto_incs->[0] = \@auto_inc_cols; } } @@ -155,6 +156,21 @@ sub last_insert_id { 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 {