[Bast-commits] r9188 - in DBIx-Class/0.08/trunk: . lib/DBIx/Class t
castaway at dev.catalyst.perl.org
castaway at dev.catalyst.perl.org
Tue Apr 20 06:06:26 GMT 2010
Author: castaway
Date: 2010-04-20 07:06:26 +0100 (Tue, 20 Apr 2010)
New Revision: 9188
Modified:
DBIx-Class/0.08/trunk/Changes
DBIx-Class/0.08/trunk/lib/DBIx/Class/Schema.pm
DBIx-Class/0.08/trunk/t/39load_namespaces_1.t
Log:
Warn if a class found in ResultSet/ is not a subclass of ::ResultSet
Modified: DBIx-Class/0.08/trunk/Changes
===================================================================
--- DBIx-Class/0.08/trunk/Changes 2010-04-18 21:06:29 UTC (rev 9187)
+++ DBIx-Class/0.08/trunk/Changes 2010-04-20 06:06:26 UTC (rev 9188)
@@ -1,5 +1,6 @@
Revision history for DBIx::Class
+ - Add a warning to load_namespaces if a class in ResultSet/ is not a subclass of DBIx::Class::ResultSet
- InflateColumn::DateTime support for MSSQL via DBD::Sybase
- millisecond precision support for MSSQL datetimes for
InflateColumn::DateTime
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Schema.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Schema.pm 2010-04-18 21:06:29 UTC (rev 9187)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Schema.pm 2010-04-20 06:06:26 UTC (rev 9188)
@@ -271,6 +271,10 @@
}
elsif($rs_class ||= $default_resultset_class) {
$class->ensure_class_loaded($rs_class);
+ if(!$rs_class->isa("DBIx::Class::ResultSet")) {
+ carp "load_namespaces found ResultSet class $rs_class that does not subclass DBIx::Class::ResultSet";
+ }
+
$class->_ns_get_rsrc_instance ($result_class)->resultset_class($rs_class);
}
Modified: DBIx-Class/0.08/trunk/t/39load_namespaces_1.t
===================================================================
--- DBIx-Class/0.08/trunk/t/39load_namespaces_1.t 2010-04-18 21:06:29 UTC (rev 9187)
+++ DBIx-Class/0.08/trunk/t/39load_namespaces_1.t 2010-04-20 06:06:26 UTC (rev 9188)
@@ -7,8 +7,6 @@
use lib qw(t/lib);
use DBICTest; # do not remove even though it is not used
-plan tests => 8;
-
my $warnings;
eval {
local $SIG{__WARN__} = sub { $warnings .= shift };
@@ -16,9 +14,11 @@
use base qw/DBIx::Class::Schema/;
__PACKAGE__->load_namespaces;
};
-ok(!$@) or diag $@;
-like($warnings, qr/load_namespaces found ResultSet class C with no corresponding Result class/);
+ok(!$@, 'load_namespaces doesnt die') or diag $@;
+like($warnings, qr/load_namespaces found ResultSet class C with no corresponding Result class/, 'Found warning about extra ResultSet classes');
+like($warnings, qr/load_namespaces found ResultSet class DBICNSTest::ResultSet::D that does not subclass DBIx::Class::ResultSet/, 'Found warning about ResultSets with incorrect subclass');
+
my $source_a = DBICNSTest->source('A');
isa_ok($source_a, 'DBIx::Class::ResultSource::Table');
my $rset_a = DBICNSTest->resultset('A');
@@ -31,5 +31,7 @@
for my $moniker (qw/A B/) {
my $class = "DBICNSTest::Result::$moniker";
- ok(!defined($class->result_source_instance->source_name));
+ ok(!defined($class->result_source_instance->source_name), "Source name of $moniker not defined");
}
+
+done_testing;
More information about the Bast-commits
mailing list