[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:10: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);
First of all, never use `map` in void context for side effects, use `for` instead.
Secondly, this all could be simplified to:
```perl
my @fields = @{$item{'parens_field_list(?)'} || []};
$select_sql->{columns}->[$_]->{alias} = $fields[$_]
for 0..$#fields;
```
--
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#pullrequestreview-31888045
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/dbix-class-devel/attachments/20170410/52aa0955/attachment.htm>
More information about the DBIx-Class-Devel
mailing list