From: Rafael Kitover Date: Thu, 25 Mar 2010 00:24:09 +0000 (+0000) Subject: remove _get_mssql_version X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ff153e241d4990c6332359d942385d11019f0018;p=dbsrgits%2FDBIx-Class-Historic.git remove _get_mssql_version --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 1463df4..e9190a2 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -19,7 +19,7 @@ use Sub::Name (); __PACKAGE__->mk_group_accessors('simple' => qw/_connect_info _dbi_connect_info _dbh _sql_maker _sql_maker_opts _conn_pid _conn_tid transaction_depth _dbh_autocommit _driver_determined savepoints - _server_info/ + __server_info/ ); # the values for these accessors are picked out (and deleted) from @@ -942,11 +942,19 @@ sub _populate_server_info { $info{dbms_ver} = $dbms_ver if defined $dbms_ver; - $self->_server_info(\%info); + $self->__server_info(\%info); return \%info; } +sub _server_info { + my $self = shift; + + $self->_get_dbh; + + return $self->__server_info(@_); +} + sub _determine_driver { my ($self) = @_; diff --git a/lib/DBIx/Class/Storage/DBI/MSSQL.pm b/lib/DBIx/Class/Storage/DBI/MSSQL.pm index ce714d4..5f17153 100644 --- a/lib/DBIx/Class/Storage/DBI/MSSQL.pm +++ b/lib/DBIx/Class/Storage/DBI/MSSQL.pm @@ -232,24 +232,14 @@ sub build_datetime_parser { sub sqlt_type { 'SQLServer' } -sub _get_mssql_version { - my $self = shift; - - my $data = $self->_get_dbh->selectrow_hashref('xp_msver ProductVersion'); - - if ($data->{Character_Value} =~ /^(\d+)\./) { - return $1; - } else { - $self->throw_exception(q{Your ProductVersion's Character_Value is missing or malformed!}); - } -} - sub sql_maker { my $self = shift; unless ($self->_sql_maker) { unless ($self->{_sql_maker_opts}{limit_dialect}) { - my $version = eval { $self->_get_mssql_version; } || 0; + + my ($version) = $self->_server_info->{dbms_ver} =~ /^(\d+)/; + $version ||= 0; $self->{_sql_maker_opts} = { limit_dialect => ($version >= 9 ? 'RowNumberOver' : 'Top'), 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 cd0fa57..f8cfdfc 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm @@ -175,14 +175,6 @@ sub connect_call_use_MARS { } } -sub _get_mssql_version { - my $self = shift; - - my ($version) = $self->_server_info->{dbms_ver} =~ /^(\d+)/; - - return $version; -} - 1; =head1 AUTHOR diff --git a/lib/DBIx/Class/Storage/DBI/SQLite.pm b/lib/DBIx/Class/Storage/DBI/SQLite.pm index ec7f1bf..c8461f6 100644 --- a/lib/DBIx/Class/Storage/DBI/SQLite.pm +++ b/lib/DBIx/Class/Storage/DBI/SQLite.pm @@ -50,7 +50,7 @@ sub deployment_statements { $sqltargs ||= {}; - my $sqlite_version = $self->_get_dbh->{sqlite_version}; + my $sqlite_version = $self->_server_info->{dbms_ver}; # numify, SQLT does a numeric comparison $sqlite_version =~ s/^(\d+) \. (\d+) (?: \. (\d+))? .*/${1}.${2}/x; diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm b/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm index 0173fac..7983473 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/Microsoft_SQL_Server.pm @@ -55,6 +55,25 @@ sub _dbh_rollback { $dbh->do('ROLLBACK'); } +sub _populate_server_info { + my $self = shift; + + my $info = $self->next::method(@_); + + my $product_version = $self->_get_dbh->selectrow_hashref('xp_msver ProductVersion'); + + if ((my $version = $data->{Character_Value}) =~ /^(\d+)\./) { + $info->{dbms_ver} = $version; + } else { + $self->throw_exception(q{ +MSSQL Version Retrieval Failed, Your ProductVersion's Character_Value is missing +or malformed! + }); + } + + return $info; +} + 1; =head1 NAME