File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
lib/SQL/Translator/Producer Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -158,6 +158,11 @@ sub create_view {
158158 if exists ($extra -> {if_not_exists }) && $extra -> {if_not_exists };
159159 $create_view .= " ${view_name} " ;
160160
161+ if (my @fields = $view -> fields) {
162+ my $field_list = join ' , ' , map { _generator-> quote($_ ) } @fields ;
163+ $create_view .= " ( ${field_list} )" ;
164+ }
165+
161166 if (my $sql = $view -> sql) {
162167 $create_view .= " AS\n ${sql} " ;
163168 }
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ $SQL::Translator::Producer::SQLite::NO_QUOTES = 0;
2525 my $view1_sql1 = [ SQL::Translator::Producer::SQLite::create_view($view1 , $create_opts ) ];
2626
2727 my $view_sql_replace = [
28- ' CREATE TEMPORARY VIEW IF NOT EXISTS "view_foo" AS
28+ ' CREATE TEMPORARY VIEW IF NOT EXISTS "view_foo" ( "id", "name" ) AS
2929 SELECT id, name FROM thing'
3030 ];
3131 is_deeply($view1_sql1 , $view_sql_replace , ' correct "CREATE TEMPORARY VIEW" SQL' );
@@ -38,7 +38,7 @@ $SQL::Translator::Producer::SQLite::NO_QUOTES = 0;
3838
3939 my $view1_sql2 = [ SQL::Translator::Producer::SQLite::create_view($view2 , $create_opts ) ];
4040 my $view_sql_noreplace = [
41- ' CREATE VIEW "view_foo" AS
41+ ' CREATE VIEW "view_foo" ( "id", "name" ) AS
4242 SELECT id, name FROM thing'
4343 ];
4444 is_deeply($view1_sql2 , $view_sql_noreplace , ' correct "CREATE VIEW" SQL' );
You can’t perform that action at this time.
0 commit comments