[Bast-commits] r8141 - in DBIx-Class/0.08/branches/sqlt_parser_view:
lib/SQL/Translator/Parser/DBIx t t/lib/DBICTest
t/lib/DBICTest/Schema
abraxxa at dev.catalyst.perl.org
abraxxa at dev.catalyst.perl.org
Fri Dec 18 13:34:14 GMT 2009
Author: abraxxa
Date: 2009-12-18 13:34:14 +0000 (Fri, 18 Dec 2009)
New Revision: 8141
Removed:
DBIx-Class/0.08/branches/sqlt_parser_view/t/lib/DBICTest/Schema/NoViewDefinition.pm
Modified:
DBIx-Class/0.08/branches/sqlt_parser_view/lib/SQL/Translator/Parser/DBIx/Class.pm
DBIx-Class/0.08/branches/sqlt_parser_view/t/99dbic_sqlt_parser.t
DBIx-Class/0.08/branches/sqlt_parser_view/t/lib/DBICTest/Schema.pm
Log:
throw_exception if view_definition is missing instead of silent skipping + test changes
Modified: DBIx-Class/0.08/branches/sqlt_parser_view/lib/SQL/Translator/Parser/DBIx/Class.pm
===================================================================
--- DBIx-Class/0.08/branches/sqlt_parser_view/lib/SQL/Translator/Parser/DBIx/Class.pm 2009-12-18 11:51:16 UTC (rev 8140)
+++ DBIx-Class/0.08/branches/sqlt_parser_view/lib/SQL/Translator/Parser/DBIx/Class.pm 2009-12-18 13:34:14 UTC (rev 8141)
@@ -289,7 +289,8 @@
# Its possible to have multiple DBIC source using same table
next if $views{$view_name}++;
- next unless $source->view_definition;
+ $dbicschema->throw_exception ("view $view_name is missing a view_definition")
+ unless $source->view_definition;
my $view = $schema->add_view (
name => $view_name,
Modified: DBIx-Class/0.08/branches/sqlt_parser_view/t/99dbic_sqlt_parser.t
===================================================================
--- DBIx-Class/0.08/branches/sqlt_parser_view/t/99dbic_sqlt_parser.t 2009-12-18 11:51:16 UTC (rev 8140)
+++ DBIx-Class/0.08/branches/sqlt_parser_view/t/99dbic_sqlt_parser.t 2009-12-18 13:34:14 UTC (rev 8141)
@@ -63,24 +63,41 @@
}
{
- #my $sqlt_schema = create_schema({ schema => $schema, args => { parser_args => { } } });
- my $sqlt_schema = create_schema({ schema => $schema });
-
- my @views = $sqlt_schema->get_views;
+ {
+ package # hide from PAUSE
+ DBICTest::Schema::NoViewDefinition;
- # the following views are skipped:
- # Year1999CDs is virtual
- # NoViewDefinition has no view_definition
- is(scalar @views, 1, "number of views ok");
+ use base qw/DBICTest::BaseResult/;
- foreach my $view (@views) {
- ok($view->is_valid, "view " . $view->name . " is valid");
+ __PACKAGE__->table_class('DBIx::Class::ResultSource::View');
+ __PACKAGE__->table('noviewdefinition');
+
+ 1;
}
- my @expected_view_names = (qw/ year2000cds /);
- my @view_names = sort map { $_->name } @views;
+ my $schema_invalid_view = $schema->clone;
+ $schema_invalid_view->register_class('NoViewDefinition', 'DBICTest::Schema::NoViewDefinition');
- is_deeply( @view_names, @expected_view_names, "all expected views included int SQL::Translator schema" );
+ eval {
+ my $sqlt_schema = create_schema({ schema => $schema_invalid_view });
+ };
+ like($@, qr/view noviewdefinition is missing a view_definition/, "parser detects views with a view_definition");
+
+# my @views = $sqlt_schema->get_views;
+#
+# # the following views are skipped:
+# # Year1999CDs is virtual
+# # NoViewDefinition has no view_definition
+# is(scalar @views, 1, "number of views ok");
+#
+# foreach my $view (@views) {
+# ok($view->is_valid, "view " . $view->name . " is valid");
+# }
+#
+# my @expected_view_names = (qw/ year2000cds /);
+# my @view_names = sort map { $_->name } @views;
+#
+# is_deeply( @view_names, @expected_view_names, "all expected views included int SQL::Translator schema" );
}
done_testing;
@@ -101,7 +118,7 @@
my $sqlt = SQL::Translator->new( $sqltargs );
$sqlt->parser('SQL::Translator::Parser::DBIx::Class');
- return $sqlt->translate({ data => $schema }) or die $sqlt->error;
+ return $sqlt->translate({ data => $schema }) || die $sqlt->error;
}
sub get_table {
Deleted: DBIx-Class/0.08/branches/sqlt_parser_view/t/lib/DBICTest/Schema/NoViewDefinition.pm
===================================================================
--- DBIx-Class/0.08/branches/sqlt_parser_view/t/lib/DBICTest/Schema/NoViewDefinition.pm 2009-12-18 11:51:16 UTC (rev 8140)
+++ DBIx-Class/0.08/branches/sqlt_parser_view/t/lib/DBICTest/Schema/NoViewDefinition.pm 2009-12-18 13:34:14 UTC (rev 8141)
@@ -1,9 +0,0 @@
-package # hide from PAUSE
- DBICTest::Schema::NoViewDefinition;
-
-use base qw/DBICTest::BaseResult/;
-
-__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
-__PACKAGE__->table('noviewdefinition');
-
-1;
Modified: DBIx-Class/0.08/branches/sqlt_parser_view/t/lib/DBICTest/Schema.pm
===================================================================
--- DBIx-Class/0.08/branches/sqlt_parser_view/t/lib/DBICTest/Schema.pm 2009-12-18 11:51:16 UTC (rev 8140)
+++ DBIx-Class/0.08/branches/sqlt_parser_view/t/lib/DBICTest/Schema.pm 2009-12-18 13:34:14 UTC (rev 8141)
@@ -22,7 +22,6 @@
Year1999CDs
CustomSql
Money
- NoViewDefinition
/,
{ 'DBICTest::Schema' => [qw/
LinerNotes
More information about the Bast-commits
mailing list