[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:00:03 GMT 2017


ilmari commented on this pull request.



> @@ -326,7 +326,7 @@ create : CREATE PROCEDURE NAME not_delimiter "$delimiter"
 PROCEDURE : /procedure/i
     | /function/i
 
-create : CREATE or_replace(?) create_view_option(s?) /view/i NAME /as/i view_select_statement "$delimiter"
+create : CREATE or_replace(?) create_view_option(s?) /view/i NAME parens_field_list(?) /as/i view_select_statement "$delimiter"

If you don't specify a field list it generates it from the column aliases, but if you specify both, the list overrides the aliases:

```
mysql> create table foo (id integer primary key);
mysql> insert into foo values (42);
mysql> create view baz (wibble) as select id as fleem from foo;
mysql> select * from baz;
+--------+
| wibble |
+--------+
|     42 |
+--------+
mysql> show create view baz\G
*************************** 1. row ***************************
                View: baz
         Create View: CREATE ALGORITHM=UNDEFINED DEFINER=`ilmari`@`%` SQL SECURITY DEFINER VIEW `baz` AS select `foo`.`id` AS `wibble` from `foo`
```

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


More information about the DBIx-Class-Devel mailing list