From: Ash Berlin Date: Tue, 11 Mar 2008 15:03:34 +0000 (+0000) Subject: Fix errors from resultset components (and move tests into t/90ensure_class_loaded... X-Git-Tag: v0.08240~535 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a63219bc9b7102be940ea56af8e6cd77960a1c63;p=dbsrgits%2FDBIx-Class.git Fix errors from resultset components (and move tests into t/90ensure_class_loaded since its testing same sort of things) --- diff --git a/Changes b/Changes index 3a9c537..0d95297 100644 --- a/Changes +++ b/Changes @@ -3,6 +3,7 @@ Revision history for DBIx::Class - is_deferable support on relations used by the SQL::Translator parser (Anders Nor Berle) - Refactored DBIx::Class::Schema::Versioned + - Syntax errors from resultset components are now reported correctly 0.08010 2008-03-01 10:30 - Fix t/94versioning.t so it passes with latest SQL::Translator diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 775d032..b30efa2 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -2132,7 +2132,12 @@ See L for details. sub throw_exception { my $self=shift; - $self->_source_handle->schema->throw_exception(@_); + if (ref $self) { + $self->_source_handle->schema->throw_exception(@_) + } else { + croak(@_); + } + } # XXX: FIXME: Attributes docs need clearing up diff --git a/t/90ensure_class_loaded.t b/t/90ensure_class_loaded.t index c901d06..3fc828e 100644 --- a/t/90ensure_class_loaded.t +++ b/t/90ensure_class_loaded.t @@ -13,7 +13,7 @@ BEGIN { my $schema = DBICTest->init_schema(); -plan tests => 19; +plan tests => 20; # Test ensure_class_found ok( $schema->ensure_class_found('DBIx::Class::Schema'), @@ -72,4 +72,16 @@ ok( Class::Inspector->loaded('DBICTest::FakeComponent'), 'load_optional_class(DBICTest::SyntaxErrorComponent2) threw ok' ); } + +eval { + package Fake::ResultSet; + + use base 'DBIx::Class::ResultSet'; + + __PACKAGE__->load_components('+DBICTest::SyntaxErrorComponent3'); +}; + +# Make sure the errors in components of resultset classes are reported right. +like($@, qr!\Qsyntax error at t/lib/DBICTest/SyntaxErrorComponent3.pm!, "Errors from RS components reported right"); + 1; diff --git a/t/98source_load_error.t b/t/98source_load_error.t deleted file mode 100644 index 620acda..0000000 --- a/t/98source_load_error.t +++ /dev/null @@ -1,15 +0,0 @@ -use strict; -use warnings; - -use Test::More tests => 1; - -use lib qw(t/lib); -eval { - package DBICErrorTest::Schema; - - use base 'DBIx::Class::Schema'; - __PACKAGE__->load_classes('SourceWithError'); -}; - -# Make sure the errors in components of resultset classes are reported right. -like($@, qr!syntax error at t/lib/DBICErrorTest/SyntaxError.pm!); diff --git a/t/lib/DBICErrorTest/ResultSet/WithError.pm b/t/lib/DBICErrorTest/ResultSet/WithError.pm deleted file mode 100644 index 5e7a913..0000000 --- a/t/lib/DBICErrorTest/ResultSet/WithError.pm +++ /dev/null @@ -1,10 +0,0 @@ -package DBICErrorTest::ResultSet::WithError; - -use strict; -use warnings; - -use base 'DBIx::Class::ResultSet'; - -__PACKAGE__->load_components('+DBICErrorTest::SyntaxError'); - -1; diff --git a/t/lib/DBICErrorTest/Schema/SourceWithError.pm b/t/lib/DBICErrorTest/Schema/SourceWithError.pm deleted file mode 100644 index af23af8..0000000 --- a/t/lib/DBICErrorTest/Schema/SourceWithError.pm +++ /dev/null @@ -1,13 +0,0 @@ -package DBICErrorTest::Schema::SourceWithError; - -use strict; -use warnings; - -use base 'DBIx::Class'; -__PACKAGE__->load_components('Core'); -__PACKAGE__->table('foo'); -#__PACKAGE__->load_components('+DBICErrorTest::SyntaxError'); -require DBICErrorTest::ResultSet::WithError; -__PACKAGE__->resultset_class('DBICErrorTest::ResultSet::WithError'); - -1; diff --git a/t/lib/DBICErrorTest/SyntaxError.pm b/t/lib/DBICTest/SyntaxErrorComponent3.pm similarity index 100% rename from t/lib/DBICErrorTest/SyntaxError.pm rename to t/lib/DBICTest/SyntaxErrorComponent3.pm