[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 3 10:03:21 GMT 2017


ilmari requested changes 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"

An explicit field list overrides the names derived from the `SELECT` column list, so the field list needs to be saved here and stored in the `fields` attribute of the `SQL::Translator::Schema::View` object.

> @@ -502,6 +502,19 @@ BEGIN {
     is( join(',', $t2c2->reference_fields), 'id', 'To field "id"' );
 }
 
+# Tests for CREATE VIEW statements that contain a column list
+# after the view name
+{
+    my $tr = SQL::Translator->new();
+    my $data = parse($tr,
+        q[
+            CREATE
+              VIEW view_foo (id, name) AS
+                SELECT id, name FROM thing;
+        ]
+    ) or die $tr->error;

Please also test that the view is in fact correctly parsed and that the column names after the view name take precedence over the ones in the `SELECT` list.

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


More information about the DBIx-Class-Devel mailing list