From: Johannes Plunien Date: Wed, 7 Nov 2007 17:19:10 +0000 (+0000) Subject: moved sequence relatied insert code from DBI::Oracle::Generic to DBI so it'll work... X-Git-Tag: v0.08240~533^2~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a982c05194b0b716883a53c675521a9902d4681a;p=dbsrgits%2FDBIx-Class.git moved sequence relatied insert code from DBI::Oracle::Generic to DBI so it'll work for other storage engines too --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 874d3a4..0676d38 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1019,6 +1019,16 @@ sub insert { my $ident = $source->from; my $bind_attributes = $self->source_bind_attributes($source); + foreach my $col ( $source->columns ) { + if ( !defined $to_insert->{$col} ) { + my $col_info = $source->column_info($col); + + if ( $col_info->{auto_nextval} ) { + $to_insert->{$col} = $self->_sequence_fetch( 'nextval', $col_info->{sequence} || $self->_dbh_get_autoinc_seq($self->dbh, $source) ); + } + } + } + $self->_execute('insert' => [], $source, $bind_attributes, $to_insert); return $to_insert; diff --git a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm index 808e20f..a786659 100644 --- a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm +++ b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm @@ -63,26 +63,6 @@ sub _dbh_get_autoinc_seq { $self->throw_exception("Unable to find a sequence INSERT trigger on table '" . $source->name . "'."); } -=head2 insert - -Fetch nextval from sequence and handle insert statement. - -=cut - -sub insert { - my ( $self, $source, $to_insert ) = @_; - foreach my $col ( $source->columns ) { - if ( !defined $to_insert->{$col} ) { - my $col_info = $source->column_info($col); - - if ( $col_info->{auto_nextval} ) { - $to_insert->{$col} = $self->_sequence_fetch( 'nextval', $col_info->{sequence} || $self->_dbh_get_autoinc_seq($self->dbh, $source) ); - } - } - } - $self->next::method( $source, $to_insert ); -} - sub _sequence_fetch { my ( $self, $type, $seq ) = @_; my ($id) = $self->dbh->selectrow_array("SELECT ${seq}.${type} FROM DUAL");