From: Peter Rabbitson Date: Sun, 6 Sep 2009 18:45:41 +0000 (+0000) Subject: Clearer MSSQL error message X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=64690266e50fb76039861019541730391b5b4006;p=dbsrgits%2FDBIx-Class-Historic.git Clearer MSSQL error message --- diff --git a/lib/DBIx/Class/Storage/DBI/MSSQL.pm b/lib/DBIx/Class/Storage/DBI/MSSQL.pm index c4611b3..886b6fe 100644 --- a/lib/DBIx/Class/Storage/DBI/MSSQL.pm +++ b/lib/DBIx/Class/Storage/DBI/MSSQL.pm @@ -16,10 +16,20 @@ __PACKAGE__->sql_maker_class('DBIx::Class::SQLAHacks::MSSQL'); sub _set_identity_insert { my ($self, $table) = @_; - $self->_get_dbh->do (sprintf + + my $sql = sprintf ( 'SET IDENTITY_INSERT %s ON', - $self->sql_maker->_quote ($table) + $self->sql_maker->_quote ($table), ); + + my $dbh = $self->_get_dbh; + eval { $dbh->do ($sql) }; + if ($@) { + $self->throw_exception (sprintf "Error executing '%s': %s", + $sql, + $dbh->errstr, + ); + } } sub insert_bulk {