1 package # Hide from PAUSE
2 DBIx::Class::SQLAHacks::MSSQL;
7 use base qw( DBIx::Class::SQLAHacks );
8 use Carp::Clan qw/^DBIx::Class|^SQL::Abstract/;
10 # an MSSQL-specific implementation of the Row-Number-Over limiting
13 sub _MSRowNumberOver {
14 my ($self, $sql, $order, $rows, $offset ) = @_;
16 # get the order_by only (or make up an order if none exists)
17 my $order_by = $self->_order_by(
18 (delete $order->{order_by}) || \ '(SELECT (1))'
22 my $group_having = $self->_order_by($order);
24 $sql = sprintf (<<'EOS', $order_by, $sql, $group_having, $offset + 1, $offset + $rows, );
27 SELECT orig_query.*, ROW_NUMBER() OVER(%s ) AS rno__row__index FROM (%s%s) orig_query
28 ) rno_subq WHERE rno__row__index BETWEEN %d AND %d
32 $sql =~ s/\s*\n\s*/ /g; # easier to read in the debugger