X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSQLAHacks%2FMSSQL.pm;h=f1af97086cbc7265eed9ae6ba9ea0e618e2cf3ff;hb=4c0c303898ebd56e8e15a6402608be3a23d242ca;hp=20105a85ed2f99ede341714ba6664abbdfe3f2a8;hpb=7275194d91e3410827655eb45199ab4e27e5260e;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/lib/DBIx/Class/SQLAHacks/MSSQL.pm b/lib/DBIx/Class/SQLAHacks/MSSQL.pm index 20105a8..f1af970 100644 --- a/lib/DBIx/Class/SQLAHacks/MSSQL.pm +++ b/lib/DBIx/Class/SQLAHacks/MSSQL.pm @@ -1,46 +1,14 @@ package # Hide from PAUSE DBIx::Class::SQLAHacks::MSSQL; -use warnings; -use strict; - use base qw( DBIx::Class::SQLAHacks ); use Carp::Clan qw/^DBIx::Class|^SQL::Abstract/; -# an MSSQL-specific implementation of the Row-Number-Over limiting -# technique - -sub _MSRowNumberOver { - my ($self, $sql, $order, $rows, $offset ) = @_; - - # get the order_by only - my $order_by = $self->_order_by( - (delete $order->{order_by}) || do { - - # no order was supplied - make something up: - my $rsrc = $self->{_dbic_rs_attrs}{_source_handle}->resolve; - if (my @pk = $rsrc->primary_columns) { - \@pk; - } - else { - [($rsrc->columns)[0]]; - } - } - ); - - # whatever is left - my $group_having = $self->_order_by($order); - - $sql = sprintf (<<'EOS', $order_by, $sql, $group_having, $offset + 1, $offset + $rows, ); - -SELECT * FROM ( - SELECT orig_query.*, ROW_NUMBER() OVER(%s ) AS rno__row__index FROM (%s%s) orig_query -) rno_subq WHERE rno__row__index BETWEEN %d AND %d - -EOS - - $sql =~ s/\s*\n\s*/ /g; # easier to read in the debugger - return $sql; +# +# MSSQL does not support ... OVER() ... RNO limits +# +sub _rno_default_order { + return \ '(SELECT(1))'; } 1;