X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FMSSQL.pm;h=a147091eec8046d5244507edf5b90b56cdfb558e;hb=3e4a74aa6eeb3ad2b9d5979ec7d41adc6efe9be2;hp=fc505fae8c68654f221f3a28f99a044bf3fe6129;hpb=b928a9d581500f03057ead793395bba573709797;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/MSSQL.pm b/lib/DBIx/Class/Storage/DBI/MSSQL.pm index fc505fa..a147091 100644 --- a/lib/DBIx/Class/Storage/DBI/MSSQL.pm +++ b/lib/DBIx/Class/Storage/DBI/MSSQL.pm @@ -27,6 +27,22 @@ __PACKAGE__->datetime_parser_type ( __PACKAGE__->new_guid('NEWID()'); +sub __sql_server_x_or_higher { + my ($self, $version) = @_; + + if (exists $_[0]->_server_info->{normalized_dbms_version}) { + if ($_[0]->_server_info->{normalized_dbms_version} >= $version) { + return 1 + } else { + return 0 + } + } + return undef; +} + +sub _sql_server_2005_or_higher { shift->__sql_server_x_or_higher(9) } +sub _sql_server_2012_or_higher { shift->__sql_server_x_or_higher(11) } + sub _prep_for_execute { my $self = shift; my ($op, $ident, $args) = @_; @@ -53,7 +69,7 @@ sub _prep_for_execute { my ($sql, $bind) = $self->next::method (@_); # SELECT SCOPE_IDENTITY only works within a statement scope. We - # must try to always use this particular idiom frist, as it is the + # must try to always use this particular idiom first, as it is the # only one that guarantees retrieving the correct id under high # concurrency. When this fails we will fall back to whatever secondary # retrieval method is specified in _identity_method, but at this @@ -151,12 +167,9 @@ sub sqlt_type { 'SQLServer' } sub sql_limit_dialect { my $self = shift; - my $supports_rno = 0; + my $supports_rno = $self->_sql_server_2005_or_higher; - if (exists $self->_server_info->{normalized_dbms_version}) { - $supports_rno = 1 if $self->_server_info->{normalized_dbms_version} >= 9; - } - else { + unless (defined $supports_rno) { # User is connecting via DBD::Sybase and has no permission to run # stored procedures like xp_msver, or version detection failed for some # other reason.