From: Peter Rabbitson Date: Sun, 7 Jun 2009 08:26:06 +0000 (+0000) Subject: The way we generate create view statements is not standards compliant (per RhodiumToa... X-Git-Tag: v0.11008~163^2~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f59b2c0e0d3cad2e98ed0eb440720f85a8f33a6f;p=dbsrgits%2FSQL-Translator.git The way we generate create view statements is not standards compliant (per RhodiumToad in #postgresql) --- diff --git a/lib/SQL/Translator/Producer/PostgreSQL.pm b/lib/SQL/Translator/Producer/PostgreSQL.pm index 3417540..35de753 100644 --- a/lib/SQL/Translator/Producer/PostgreSQL.pm +++ b/lib/SQL/Translator/Producer/PostgreSQL.pm @@ -448,7 +448,7 @@ sub create_view { } if ( my $sql = $view->sql ) { - $create .= " AS (\n ${sql}\n )"; + $create .= " AS\n ${sql}\n"; } if ( $extra->{check_option} ) { diff --git a/t/46xml-to-pg.t b/t/46xml-to-pg.t index 44ef2ad..3df7849 100644 --- a/t/46xml-to-pg.t +++ b/t/46xml-to-pg.t @@ -58,9 +58,9 @@ CREATE TABLE "Another" ( ); DROP VIEW "email_list"; -CREATE VIEW "email_list" ( "email" ) AS ( +CREATE VIEW "email_list" ( "email" ) AS SELECT email FROM Basic WHERE (email IS NOT NULL) - ); +; ALTER TABLE "Basic" ADD FOREIGN KEY ("another_id") REFERENCES "Another" ("id") DEFERRABLE; diff --git a/t/47postgres-producer.t b/t/47postgres-producer.t index 6201091..c4bb28d 100644 --- a/t/47postgres-producer.t +++ b/t/47postgres-producer.t @@ -235,9 +235,9 @@ my $view1 = SQL::Translator::Schema::View->new( my $create_opts = { add_replace_view => 1, no_comments => 1 }; my $view1_sql1 = SQL::Translator::Producer::PostgreSQL::create_view($view1, $create_opts); -my $view_sql_replace = "CREATE VIEW view_foo ( id, name ) AS ( +my $view_sql_replace = "CREATE VIEW view_foo ( id, name ) AS SELECT id, name FROM thing - )"; +"; is($view1_sql1, $view_sql_replace, 'correct "CREATE OR REPLACE VIEW" SQL'); my $view2 = SQL::Translator::Schema::View->new( @@ -251,7 +251,7 @@ my $view2 = SQL::Translator::Schema::View->new( my $create2_opts = { add_replace_view => 1, no_comments => 1 }; my $view2_sql1 = SQL::Translator::Producer::PostgreSQL::create_view($view2, $create2_opts); -my $view2_sql_replace = "CREATE TEMPORARY VIEW view_foo2 AS ( +my $view2_sql_replace = "CREATE TEMPORARY VIEW view_foo2 AS SELECT id, name FROM thing - ) WITH CASCADED CHECK OPTION"; + WITH CASCADED CHECK OPTION"; is($view2_sql1, $view2_sql_replace, 'correct "CREATE OR REPLACE VIEW" SQL 2');