From: Arthur Axel "fREW" Schmidt Date: Wed, 9 Dec 2009 00:24:45 +0000 (+0000) Subject: fix mssql version check so it's lazier X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=50772633b75596faaec4fc236682d028f2dc31bd;p=dbsrgits%2FDBIx-Class-Historic.git fix mssql version check so it's lazier --- diff --git a/lib/DBIx/Class/Storage/DBI/MSSQL.pm b/lib/DBIx/Class/Storage/DBI/MSSQL.pm index be1c399..dec843f 100644 --- a/lib/DBIx/Class/Storage/DBI/MSSQL.pm +++ b/lib/DBIx/Class/Storage/DBI/MSSQL.pm @@ -235,23 +235,27 @@ sub _get_mssql_version { if ($data->{Character_Value} =~ /^(\d+)\./) { return $1; } else { - $self->throw_exception(q{your MSSQL server doesn't have a version!}); + $self->throw_exception(q{Your ProductVersion's Character_Value is missing or malformed!}); } } -sub _sql_maker_opts { - my ( $self, $opts ) = @_; +sub sql_maker { + my $self = shift; - if ( $opts ) { - $self->{_sql_maker_opts} = { %$opts }; - } + unless ($self->_sql_maker) { + unless ($self->{_sql_maker_opts}{limit_dialect}) { + my $version = $self->_get_mssql_version; - my $version = $self->_get_mssql_version; + $self->{_sql_maker_opts} = { + limit_dialect => ($version >= 9 ? 'RowNumberOver' : 'Top'), + %{$self->{_sql_maker_opts}||{}} + }; + } + + my $maker = $self->next::method (@_); + } - return { - limit_dialect => ($version >= 9 ? 'RowNumberOver' : 'Top'), - %{$self->{_sql_maker_opts}||{}} - }; + return $self->_sql_maker; } 1;