Simplify DBIHacks order_by scan generator
Peter Rabbitson [Mon, 21 Sep 2015 23:35:29 +0000 (01:35 +0200)]
There is no need to call out all the way to _extract_order_criteria -
we can do the necessary mangling ourselves

lib/DBIx/Class/Storage/DBIHacks.pm

index b0dfe43..33698c4 100644 (file)
@@ -439,8 +439,12 @@ sub _resolve_aliastypes_from_select_args {
           { ($sql_maker->_recurse_fields($_))[0] }
           @{$attrs->{select}}
     ],
-    ordering => [
-      map { $_->[0] } $self->_extract_order_criteria ($attrs->{order_by}, $sql_maker),
+    ordering => [ map
+      {
+        ( my $sql = (ref $_ ? $_->[0] : $_) ) =~ s/ \s+ (?: ASC | DESC ) \s* \z //xi;
+        $sql;
+      }
+      $sql_maker->_order_by_chunks( $attrs->{order_by} ),
     ],
   };