more fine grained versioning
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / MSSQL.pm
index fc505fa..a147091 100644 (file)
@@ -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.