X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSQLAHacks.pm;h=5c374b0766570fdd5fd24690444be3746f4bf998;hb=c2ecf953198fc6c43edae1b39de4cc86debcb11b;hp=ac3ae4ad39a5a47b92bcd161ebb4ebf3c4b15255;hpb=1f36ab6755c16cae2d4c3d0099d68cd11948f0ff;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/lib/DBIx/Class/SQLAHacks.pm b/lib/DBIx/Class/SQLAHacks.pm index ac3ae4a..5c374b0 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 (<_order_by ($order), + ); +} + # Crappy Top based Limit/Offset support. Legacy from MSSQL. sub _Top { my ( $self, $sql, $order, $rows, $offset ) = @_; @@ -383,7 +407,7 @@ sub _recurse_fields { $self->_sqlcase($func), $self->_recurse_fields($args), $as - ? sprintf (' %s %s', $self->_sqlcase('as'), $as) + ? sprintf (' %s %s', $self->_sqlcase('as'), $self->_quote ($as) ) : '' );