[Bast-commits] r6410 - in DBIx-Class/0.08/trunk/lib/DBIx/Class: .
Storage
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Mon May 25 06:48:38 GMT 2009
Author: ribasushi
Date: 2009-05-25 06:48:38 +0000 (Mon, 25 May 2009)
New Revision: 6410
Modified:
DBIx-Class/0.08/trunk/lib/DBIx/Class/SQLAHacks.pm
DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
Log:
Factor out the order_by sqlahacks resolver
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/SQLAHacks.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/SQLAHacks.pm 2009-05-25 02:00:15 UTC (rev 6409)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/SQLAHacks.pm 2009-05-25 06:48:38 UTC (rev 6410)
@@ -259,22 +259,34 @@
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') {
+ $$_
}
- } @{ $order }];
+ elsif (ref ($_) eq 'HASH') {
+ $self->_resolve_order_hash($_)
+ }
+ 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 }) {
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm 2009-05-25 02:00:15 UTC (rev 6409)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/DBI.pm 2009-05-25 06:48:38 UTC (rev 6410)
@@ -1187,7 +1187,7 @@
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")
More information about the Bast-commits
mailing list