sub _order_directions {
my ($self, $order) = @_;
- $order = $order->{order_by} if ref $order eq 'HASH';
+ return $self->SUPER::_order_directions( $self->_resolve_order($order) );
+}
+
+sub _resolve_order {
+ my ($self, $order) = @_;
+ $order = $order->{order_by} if (ref $order eq 'HASH' and $order->{order_by});
+
if (ref $order eq 'HASH') {
- $order = [$self->_order_directions_hash($order)];
- } elsif (ref $order eq 'ARRAY') {
+ $order = [$self->_resolve_order_hash($order)];
+ }
+ elsif (ref $order eq 'ARRAY') {
$order = [map {
- if (ref $_ eq 'HASH') {
- $self->_order_directions_hash($_);
- } else {
- $_;
+ if (ref ($_) eq 'SCALAR') {
+ $$_
+ }
+ elsif (ref ($_) eq 'HASH') {
+ $self->_resolve_order_hash($_)
}
- } @{ $order }];
+ else {
+ $_
+ }
+ } @$order];
}
- return $self->SUPER::_order_directions($order);
+
+ return $order;
}
-sub _order_directions_hash {
+sub _resolve_order_hash {
my ($self, $order) = @_;
my @new_order;
foreach my $key (keys %{ $order }) {
my $bind_attrs = {}; ## Future support
my @args = ('select', $attrs->{bind}, $ident, $bind_attrs, $select, $condition, $order);
if ($attrs->{software_limit} ||
- $self->sql_maker->_default_limit_syntax eq "GenericSubQ") {
+ $sql_maker->_default_limit_syntax eq "GenericSubQ") {
$attrs->{software_limit} = 1;
} else {
$self->throw_exception("rows attribute must be positive if present")