[Bast-commits] r8044 -
DBIx-Class/0.08/branches/mssql_rno_pagination/lib/DBIx/Class/Storage/DBI
frew at dev.catalyst.perl.org
frew at dev.catalyst.perl.org
Tue Dec 8 01:10:08 GMT 2009
Author: frew
Date: 2009-12-08 01:10:06 +0000 (Tue, 08 Dec 2009)
New Revision: 8044
Modified:
DBIx-Class/0.08/branches/mssql_rno_pagination/lib/DBIx/Class/Storage/DBI/MSSQL.pm
Log:
add version check for mssql 2005 and greater
Modified: DBIx-Class/0.08/branches/mssql_rno_pagination/lib/DBIx/Class/Storage/DBI/MSSQL.pm
===================================================================
--- DBIx-Class/0.08/branches/mssql_rno_pagination/lib/DBIx/Class/Storage/DBI/MSSQL.pm 2009-12-07 14:11:25 UTC (rev 8043)
+++ DBIx-Class/0.08/branches/mssql_rno_pagination/lib/DBIx/Class/Storage/DBI/MSSQL.pm 2009-12-08 01:10:06 UTC (rev 8044)
@@ -227,6 +227,18 @@
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 {
+ die q{wtf your server doesn't have a version!};
+ }
+}
+
sub _sql_maker_opts {
my ( $self, $opts ) = @_;
@@ -234,7 +246,12 @@
$self->{_sql_maker_opts} = { %$opts };
}
- return { limit_dialect => 'RowNumberOver', %{$self->{_sql_maker_opts}||{}} };
+ my $version = $self->_get_mssql_version;
+
+ return {
+ limit_dialect => ($version >= 9 ? 'RowNumberOver' : 'Top'),
+ %{$self->{_sql_maker_opts}||{}}
+ };
}
1;
More information about the Bast-commits
mailing list