5 use Test::More tests => 2;
6 use Test::SQL::Translator qw(maybe_plan);
9 use SQL::Translator::Schema::View;
10 use SQL::Translator::Producer::SQLite;
13 my $view1 = SQL::Translator::Schema::View->new(
15 fields => [qw/id name/],
16 sql => 'SELECT id, name FROM thing',
22 my $create_opts = { no_comments => 1 };
24 [ SQL::Translator::Producer::SQLite::create_view( $view1, $create_opts ) ];
26 my $view_sql_replace = [ "CREATE TEMPORARY VIEW IF NOT EXISTS 'view_foo' AS
27 SELECT id, name FROM thing" ];
28 is_deeply( $view1_sql1, $view_sql_replace, 'correct "CREATE TEMPORARY VIEW" SQL' );
30 my $view2 = SQL::Translator::Schema::View->new(
32 fields => [qw/id name/],
33 sql => 'SELECT id, name FROM thing',
37 [ SQL::Translator::Producer::SQLite::create_view( $view2, $create_opts ) ];
38 my $view_sql_noreplace = [ "CREATE VIEW 'view_foo' AS
39 SELECT id, name FROM thing" ];
40 is_deeply( $view1_sql2, $view_sql_noreplace, 'correct "CREATE VIEW" SQL' );