From: Peter Rabbitson Date: Sat, 5 Dec 2009 10:44:25 +0000 (+0000) Subject: DB2 and MSSQL have different default order syntaxes X-Git-Tag: v0.08116~103^2~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=84ddb3da1f8d9e733d4aef1f3ce47653b6431111;p=dbsrgits%2FDBIx-Class.git DB2 and MSSQL have different default order syntaxes --- diff --git a/Makefile.PL b/Makefile.PL index 5b8ae47..86497df 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -144,6 +144,7 @@ resources 'MailingList' => 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/db no_index 'DBIx::Class::SQLAHacks'; no_index 'DBIx::Class::SQLAHacks::MySQL'; +no_index 'DBIx::Class::SQLAHacks::MSSQL'; no_index 'DBIx::Class::SQLAHacks::OracleJoins'; no_index 'DBIx::Class::Storage::DBI::AmbiguousGlob'; no_index 'DBIx::Class::Storage::DBIHacks'; diff --git a/lib/DBIx/Class/SQLAHacks.pm b/lib/DBIx/Class/SQLAHacks.pm index 3208a76..02c336c 100644 --- a/lib/DBIx/Class/SQLAHacks.pm +++ b/lib/DBIx/Class/SQLAHacks.pm @@ -53,7 +53,7 @@ sub _RowNumberOver { # get the order_by only (or make up an order if none exists) my $order_by = $self->_order_by( - (delete $order->{order_by}) || \ '(SELECT (1))' + (delete $order->{order_by}) || $self->_rno_default_order ); # whatever is left @@ -71,6 +71,11 @@ EOS return $sql; } +# some databases are happy with OVER (), some need OVER (ORDER BY (SELECT (1)) ) +sub _rno_default_order { + return undef; +} + # Crappy Top based Limit/Offset support. Legacy from MSSQL. sub _Top { my ( $self, $sql, $order, $rows, $offset ) = @_; diff --git a/lib/DBIx/Class/SQLAHacks/MSSQL.pm b/lib/DBIx/Class/SQLAHacks/MSSQL.pm new file mode 100644 index 0000000..f1af970 --- /dev/null +++ b/lib/DBIx/Class/SQLAHacks/MSSQL.pm @@ -0,0 +1,14 @@ +package # Hide from PAUSE + DBIx::Class::SQLAHacks::MSSQL; + +use base qw( DBIx::Class::SQLAHacks ); +use Carp::Clan qw/^DBIx::Class|^SQL::Abstract/; + +# +# MSSQL does not support ... OVER() ... RNO limits +# +sub _rno_default_order { + return \ '(SELECT(1))'; +} + +1;