From: Peter Rabbitson Date: Fri, 8 Jan 2010 22:58:13 +0000 (+0000) Subject: Cleaner RNO sql X-Git-Tag: v0.08116~61^2~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cb478051e04880a5386fb6f753d81fab747be04e;p=dbsrgits%2FDBIx-Class.git Cleaner RNO sql --- diff --git a/lib/DBIx/Class/SQLAHacks.pm b/lib/DBIx/Class/SQLAHacks.pm index ac3ae4a..52a7af6 100644 --- a/lib/DBIx/Class/SQLAHacks.pm +++ b/lib/DBIx/Class/SQLAHacks.pm @@ -51,21 +51,27 @@ sub new { sub _RowNumberOver { my ($self, $sql, $order, $rows, $offset ) = @_; + # get the select to make the final amount of columns equal the original one + my ($select) = $sql =~ /^ \s* SELECT \s+ (.+?) \s+ FROM/ix + or croak "Unrecognizable SELECT: $sql"; + # get the order_by only (or make up an order if none exists) my $order_by = $self->_order_by( (delete $order->{order_by}) || $self->_rno_default_order ); - # whatever is left + # whatever is left of the order_by my $group_having = $self->_order_by($order); my $qalias = $self->_quote ($self->{_dbic_rs_attrs}{alias}); - $sql = sprintf (<<'EOS', $qalias, $order_by, $sql, $group_having, $qalias, $offset + 1, $offset + $rows, ); + $sql = sprintf (<