X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FMSSQL.pm;h=59408681fce6a6ac4ab57a287d4f2bb39b8e89de;hb=548d162784058df6a57a524618337060663f9323;hp=5f17153fe5f566c6396998c388c31c7044bb5fe1;hpb=faeb2407c49717d38874b21749659ac2c632bad7;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/MSSQL.pm b/lib/DBIx/Class/Storage/DBI/MSSQL.pm index 5f17153..5940868 100644 --- a/lib/DBIx/Class/Storage/DBI/MSSQL.pm +++ b/lib/DBIx/Class/Storage/DBI/MSSQL.pm @@ -3,7 +3,7 @@ package DBIx::Class::Storage::DBI::MSSQL; use strict; use warnings; -use base qw/DBIx::Class::Storage::DBI/; +use base qw/DBIx::Class::Storage::DBI::UniqueIdentifier/; use mro 'c3'; use List::Util(); @@ -66,43 +66,12 @@ sub insert_bulk { } } -# support MSSQL GUID column types - sub insert { my $self = shift; my ($source, $to_insert) = @_; my $supplied_col_info = $self->_resolve_column_info($source, [keys %$to_insert] ); - my %guid_cols; - my @pk_cols = $source->primary_columns; - my %pk_cols; - @pk_cols{@pk_cols} = (); - - my @pk_guids = grep { - $source->column_info($_)->{data_type} - && - $source->column_info($_)->{data_type} =~ /^uniqueidentifier/i - } @pk_cols; - - my @auto_guids = grep { - $source->column_info($_)->{data_type} - && - $source->column_info($_)->{data_type} =~ /^uniqueidentifier/i - && - $source->column_info($_)->{auto_nextval} - } grep { not exists $pk_cols{$_} } $source->columns; - - my @get_guids_for = - grep { not exists $to_insert->{$_} } (@pk_guids, @auto_guids); - - my $updated_cols = {}; - - for my $guid_col (@get_guids_for) { - my ($new_guid) = $self->_get_dbh->selectrow_array('SELECT NEWID()'); - $updated_cols->{$guid_col} = $to_insert->{$guid_col} = $new_guid; - } - my $is_identity_insert = (List::Util::first { $_->{is_auto_increment} } (values %$supplied_col_info) ) ? 1 : 0; @@ -111,13 +80,12 @@ sub insert { $self->_set_identity_insert ($source->name); } - $updated_cols = { %$updated_cols, %{ $self->next::method(@_) } }; + my $updated_cols = $self->next::method(@_); if ($is_identity_insert) { $self->_unset_identity_insert ($source->name); } - return $updated_cols; } @@ -363,7 +331,7 @@ different/better way to get the same result - please file a bugreport. =head1 AUTHOR -See L. +See L and L. =head1 LICENSE