switch _resolve_aliastypes_from_select_args to calling slightly saner methods
Matt S Trout [Mon, 7 Oct 2013 11:40:53 +0000 (11:40 +0000)]
lib/DBIx/Class/Storage/DBIHacks.pm

index c84701d..70dbfae 100644 (file)
@@ -478,11 +478,20 @@ sub _resolve_aliastypes_from_select_args {
   # generate sql chunks
   my $to_scan = {
     restricting => [
-      $sql_maker->_recurse_where ($where),
-      $sql_maker->_parse_rs_attrs ({ having => $attrs->{having} }),
+      ($where
+        ? ($sql_maker->_recurse_where($where))[0]
+        : ()
+      ),
+      ($attrs->{having}
+        ? ($sql_maker->_recurse_where($attrs->{having}))[0]
+        : ()
+      ),
     ],
     grouping => [
-      $sql_maker->_parse_rs_attrs ({ group_by => $attrs->{group_by} }),
+      ($attrs->{group_by}
+        ? ($sql_maker->_render_sqla(group_by => $attrs->{group_by}))[0]
+        : (),
+      )
     ],
     joining => [
       $sql_maker->_recurse_from (
@@ -491,13 +500,18 @@ sub _resolve_aliastypes_from_select_args {
       ),
     ],
     selecting => [
-      $sql_maker->_recurse_fields ($select),
+      scalar $sql_maker->_render_sqla(select_select => $select),
     ],
     ordering => [
       map { $_->[0] } $self->_extract_order_criteria ($attrs->{order_by}, $sql_maker),
     ],
   };
 
+  # local is not enough - need to ensure the inner objects get rebuilt
+  # with the original quoting setup (or lack thereof)
+  $sql_maker->clear_renderer;
+  $sql_maker->clear_converter;
+
   # throw away empty chunks
   $_ = [ map { $_ || () } @$_ ] for values %$to_scan;