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

Dagfinn Ilmari Mannsåker notifications at github.com
Mon Apr 10 16:18:19 GMT 2017


ilmari 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);

More importantly, this is unnecessary if you instead store `$item{'parens_field_list(?)'}` in `$views{$view_name}{fields}` and use that in preference to the select aliases the `->add_view` call.

-- 
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_r110699383
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/dbix-class-devel/attachments/20170410/da1a9c94/attachment-0001.htm>


More information about the DBIx-Class-Devel mailing list