don't gensym for unqualified versions of already selected columns
Matt S Trout [Mon, 7 Oct 2013 00:58:36 +0000 (00:58 +0000)]
lib/Data/Query/Renderer/SQL/Slice/SubqueryRemap.pm

index 631b6be..7f70046 100644 (file)
@@ -51,9 +51,15 @@ sub _subquery_remap {
 
   my %alias_map = map {
     if (is_Alias and is_Identifier $_->{from}) {
-      +(join('.',@{$_->{from}{elements}}) => Identifier($_->{to}))
+      +(
+        join('.',@{$_->{from}{elements}}) => Identifier($_->{to}),
+        $_->{from}{elements}[-1] => Identifier($_->{to}),
+      )
     } elsif (is_Identifier) {
-      +(join('.',@{$_->{elements}}) => $_)
+      +(
+        join('.',@{$_->{elements}}) => $_,
+        $_->{elements}[-1] => $_,
+      )
     } else {
       +()
     }