[DBIx-Class-Devel] [dbsrgits/sql-translator] MySQL Parser understands VIEWs with a field list. (#87)

Adam Herzog notifications at github.com
Mon Apr 10 18:10:09 GMT 2017


adherzog commented on this pull request.



> @@ -332,6 +332,13 @@ create : CREATE or_replace(?) create_view_option(s?) /view/i NAME parens_field_l
         my $view_name   = $item{'NAME'};
         my $select_sql  = $item{'view_select_statement'};
         my $options     = $item{'create_view_option(s?)'};
+        my $field_list  = $item{'parens_field_list(?)'};
+
+        # Map fields as aliases on the select columns
+        my @fields = ( $field_list->[0] ) ? @{ $field_list->[0] } : ();
+        map { $select_sql->{'columns'}->[$_]->{'alias'} = $fields[$_] }
+            ( 0 .. $#fields )
+            if (@fields);

If we store the fields in the `%views` hash instead of setting the column aliases, then the generated SQL won't include the aliases.

I've used your simplified code (though I'm using `$item{'parens_field_list(?)'}[0]` instead of `$item{'parens_field_list(?)'}`, since it seems to be an arrayref within an arrayref) and left the rest the same. 

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/dbsrgits/sql-translator/pull/87#discussion_r110724426
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/dbix-class-devel/attachments/20170410/54031758/attachment.htm>


More information about the DBIx-Class-Devel mailing list