From: Peter Rabbitson Date: Fri, 4 Dec 2009 10:47:22 +0000 (+0000) Subject: Smarter implementation of the select top 100pct subselect handling X-Git-Tag: v0.08116~103^2~15 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b90669955d5e91f63981d01aefc9b252fde4e373;p=dbsrgits%2FDBIx-Class.git Smarter implementation of the select top 100pct subselect handling --- diff --git a/lib/DBIx/Class/Storage/DBI/MSSQL.pm b/lib/DBIx/Class/Storage/DBI/MSSQL.pm index cfbc634..28b87f2 100644 --- a/lib/DBIx/Class/Storage/DBI/MSSQL.pm +++ b/lib/DBIx/Class/Storage/DBI/MSSQL.pm @@ -185,11 +185,21 @@ sub last_insert_id { shift->_identity } sub _select_args_to_query { my $self = shift; + # _select_args does some shady action at a distance + # see DBI.pm for more info my $sql_maker = $self->sql_maker; - my ($op, $bind, $ident, $bind_attrs, $select, $cond, $order) = $self->_select_args(@_); + my ($op, $bind, $ident, $bind_attrs, $select, $cond, $order, $rows, $offset); + { + local $sql_maker->{_dbic_rs_attrs}; + ($op, $bind, $ident, $bind_attrs, $select, $cond, $order, $rows, $offset) = $self->_select_args(@_); + } - if (not scalar $sql_maker->_order_by_chunks ($order->{order_by}) ) { - # no ordering, just short circuit + if ( + ($rows || $offset) + || + not scalar $sql_maker->_order_by_chunks ($order->{order_by}) + ) { + # either limited RS or no ordering, just short circuit return $self->next::method (@_); }