From: Peter Rabbitson Date: Tue, 1 Sep 2009 14:51:58 +0000 (+0000) Subject: Fix insert_bulk with rebless X-Git-Tag: v0.08111~39 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=486170095cfeae848c19cb04b024aa3b8bb808db;p=dbsrgits%2FDBIx-Class.git Fix insert_bulk with rebless --- diff --git a/Changes b/Changes index 0faba32..4a8e98e 100644 --- a/Changes +++ b/Changes @@ -4,6 +4,7 @@ Revision history for DBIx::Class coderef, allowing better intergration with Catalyst - Fixed a complex prefetch + regular join regression introduced in 0.08108 + - Fixed insert_bulk rebless handling - SQLT related fixes: - sqlt_type is now called on the correct storage object - hooks can now see the correct producer_type diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 436f540..ae7cb85 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1303,13 +1303,18 @@ sub insert { ## only prepped once. sub insert_bulk { my ($self, $source, $cols, $data) = @_; + +# redispatch to insert_bulk method of storage we reblessed into, if necessary + if (not $self->_driver_determined) { + $self->_determine_driver; + goto $self->can('insert_bulk'); + } + my %colvalues; my $table = $source->from; @colvalues{@$cols} = (0..$#$cols); my ($sql, @bind) = $self->sql_maker->insert($table, \%colvalues); - $self->_determine_driver; - $self->_query_start( $sql, @bind ); my $sth = $self->sth($sql); diff --git a/t/746mssql.t b/t/746mssql.t index 40a6157..4b5a3c1 100644 --- a/t/746mssql.t +++ b/t/746mssql.t @@ -198,6 +198,7 @@ SQL }); lives_ok ( sub { + my $schema = DBICTest::Schema->connect($dsn, $user, $pass); $schema->populate ('Owners', [ [qw/id name /], [qw/1 wiggle/], @@ -219,6 +220,7 @@ lives_ok ( sub { }, 'populate with PKs supplied ok' ); lives_ok ( sub { + my $schema = DBICTest::Schema->connect($dsn, $user, $pass); $schema->populate ('BooksInLibrary', [ [qw/source owner title /], [qw/Library 1 secrets0/],