From: Rafael Kitover Date: Tue, 14 Jul 2009 14:06:39 +0000 (+0000) Subject: a couple more options for odbc/mssql X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=18ac986d17b9f8f16d29d4a175867b6d8dde32b1;p=dbsrgits%2FDBIx-Class-Historic.git a couple more options for odbc/mssql --- diff --git a/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm b/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm index 6cc5fc4..028d9d6 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm @@ -68,7 +68,7 @@ sub connect_call_use_dynamic_cursors { my $self = shift; if (ref($self->_dbi_connect_info->[0]) eq 'CODE') { - croak 'cannot set DBI attributes on CODE ref connect_infos'; + croak 'cannot set DBI attributes on a CODE ref connect_info'; } my $dbi_attrs = $self->_dbi_connect_info->[-1]; @@ -96,6 +96,53 @@ sub _rebless { $self->_using_dynamic_cursors(0); } +=head2 connect_call_use_server_cursors + +Use as: + + on_connect_call => 'use_server_cursors' + +May allow multiple active select statements. See +L for more information. + +Takes an optional parameter for the value to set the attribute to, default is +C<2>. + +B: this does not work on all versions of SQL Server, and may lock up +your database! + +=cut + +=head2 connect_call_use_mars + +Use as: + + on_connect_call => 'use_mars' + +Use to enable a feature of SQL Server 2005 and later, "Multiple Active Result +Sets". See L +for more information. + +B: This has implications for the way transactions are handled. + +=cut + +sub connect_call_use_mars { + my $self = shift; + + my $dsn = $self->_dbi_connect_info->[0]; + + if (ref($dsn) eq 'CODE') { + croak 'cannot change the DBI DSN on a CODE ref connect_info'; + } + + if ($dsn !~ /MARS_Connection=/) { + $self->_dbi_connect_info->[0] = "$dsn;MARS_Connection=Yes"; + # will take effect next connection + $self->disconnect; + } +} + sub insert_bulk { my $self = shift; my ($source, $cols, $data) = @_;