X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FODBC%2FMicrosoft_SQL_Server.pm;h=b2db13f5facb085c6dfd56b1162718ca91de2d70;hb=6298a324307439b76419d0f5db453b0d10f10517;hp=e65654895cb1336f574b69cd96ab34d47ac71063;hpb=1d342d91aeb39ea8a6efd0b69e861ac643bc513f;p=dbsrgits%2FDBIx-Class-Historic.git 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 e656548..b2db13f 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm @@ -2,95 +2,187 @@ package DBIx::Class::Storage::DBI::ODBC::Microsoft_SQL_Server; use strict; use warnings; -use base qw/DBIx::Class::Storage::DBI/; +use base qw/DBIx::Class::Storage::DBI::MSSQL/; +use mro 'c3'; +use Scalar::Util 'reftype'; +use Try::Tiny; +use namespace::clean; -sub _prep_for_execute { - my $self = shift; - my ($op, $extra_bind, $ident, $args) = @_; +__PACKAGE__->mk_group_accessors(simple => qw/ + _using_dynamic_cursors +/); - my ($sql, $bind) = $self->SUPER::_prep_for_execute(@_); - $sql .= ';SELECT SCOPE_IDENTITY()' if $op eq 'insert'; +=head1 NAME - return ($sql, $bind); -} +DBIx::Class::Storage::DBI::ODBC::Microsoft_SQL_Server - Support specific +to Microsoft SQL Server over ODBC -sub insert { - my ($self, $source, $to_insert) = @_; +=head1 DESCRIPTION - my $bind_attributes = $self->source_bind_attributes($source); - my (undef, $sth) = $self->_execute( 'insert' => [], $source, $bind_attributes, $to_insert); - $self->{_scope_identity} = $sth->fetchrow_array; +This class implements support specific to Microsoft SQL Server over ODBC. It is +loaded automatically by by DBIx::Class::Storage::DBI::ODBC when it detects a +MSSQL back-end. - return $to_insert; -} +Most of the functionality is provided from the superclass +L. + +=head1 MULTIPLE ACTIVE STATEMENTS + +The following options are alternative ways to enable concurrent executing +statement support. Each has its own advantages and drawbacks. + +=head2 connect_call_use_dynamic_cursors + +Use as: + + on_connect_call => 'use_dynamic_cursors' + +in your L as one way to enable multiple +concurrent statements. -sub last_insert_id { shift->{_scope_identity} } +Will add C<< odbc_cursortype => 2 >> to your DBI connection attributes. See +L for more information. -sub sqlt_type { 'SQLServer' } +Alternatively, you can add it yourself and dynamic cursor support will be +automatically enabled. -sub _sql_maker_opts { - my ( $self, $opts ) = @_; +If you're using FreeTDS, C must be set to at least C<8.0>. - if ( $opts ) { - $self->{_sql_maker_opts} = { %$opts }; - } +This will not work with CODE ref connect_info's. - return { limit_dialect => 'Top', %{$self->{_sql_maker_opts}||{}} }; +B this will break C, and C