- Chris To <christot@users.sourceforge.net>
- Jason Williams <smdwilliams@users.sourceforge.net>
- Ying Zhang <zyolive@yahoo.com>
+- Guillermo Roditi <groditi@cpan.org>
If you would like to contribute to the project, you can send patches
to the developers mailing list:
+# ----------------------------------------------------------
+#
+# ----------------------------------------------------------
+* Added support for CREATE VIEW + tests in the sqlite producer (groditi)
# ----------------------------------------------------------
# 0.09001 2008-08-19
push @table_defs, $create, map( { "$_;" } @defs), "";
}
+ for my $view ( $schema->get_views ) {
+ push @table_defs, create_view($view, {no_comments => $no_comments,});
+ }
+
# $create .= "COMMIT;\n";
return wantarray ? ($create, @table_defs, "COMMIT;\n") : join("\n", ($create, @table_defs, "COMMIT;\n"));
return $name;
}
+sub create_view {
+ my ($view, $options) = @_;
+
+ my $view_name = $view->name;
+ debug("PKG: Looking at view '${view_name}'\n");
+
+ # Header. Should this look like what mysqldump produces?
+ my $extra = $view->extra;
+ my $create = '';
+ $create .= "--\n-- View: ${view_name}\n--\n" unless $options->{no_comments};
+ $create .= 'CREATE';
+ $create .= " TEMPORARY" if exists($extra->{temporary}) && $extra->{temporary};
+ $create .= ' VIEW';
+ $create .= " IF NOT EXISTS" if exists($extra->{if_not_exists}) && $extra->{if_not_exists};
+ $create .= " ${view_name}";
+
+ if( my $sql = $view->sql ){
+ $create .= " AS (\n ${sql}\n )";
+ }
+ $create .= ";\n\n";
+ return $create;
+}
+
+
sub create_table
{
my ($table, $options) = @_;