[Bast-commits] r5808 - in DBIx-Class/0.08/trunk: lib/DBIx/Class t

jmmills at dev.catalyst.perl.org jmmills at dev.catalyst.perl.org
Tue Mar 24 07:49:54 GMT 2009


Author: jmmills
Date: 2009-03-24 07:49:54 +0000 (Tue, 24 Mar 2009)
New Revision: 5808

Modified:
   DBIx-Class/0.08/trunk/lib/DBIx/Class/Schema.pm
   DBIx-Class/0.08/trunk/t/39load_namespaces_rt41083.t
Log:
Fixed _register_source to not produce 'register_extra_source' warnings
when "registering class" isa (or is a sub-class) source class.
This is not exactly an elegant fix as I had to pass a hash key (as _to_register via $params) with the original source class instance; I was not able to determine inheritance via the result_source_instance (ResultSource::Table) object.
 

Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Schema.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Schema.pm	2009-03-24 07:33:31 UTC (rev 5807)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Schema.pm	2009-03-24 07:49:54 UTC (rev 5808)
@@ -1221,7 +1221,9 @@
 
 sub register_class {
   my ($self, $moniker, $to_register) = @_;
-  $self->register_source($moniker => $to_register->result_source_instance);
+  $self->register_source($moniker => $to_register->result_source_instance, {
+    _to_register => $to_register
+  });
 }
 
 =head2 register_source
@@ -1279,7 +1281,11 @@
 
   if ($source->result_class) {
     my %map = %{$self->class_mappings};
-    if (exists $map{$source->result_class}) {
+    my $is_subof = $params->{_to_register} && UNIVERSAL::isa(
+        $params->{_to_register},
+        $source->result_class
+    );
+    if (exists $map{$source->result_class} && !$is_subof) {
       warn $source->result_class . ' already has a source, use register_extra_source for additional sources';
     }
     $map{$source->result_class} = $moniker;

Modified: DBIx-Class/0.08/trunk/t/39load_namespaces_rt41083.t
===================================================================
--- DBIx-Class/0.08/trunk/t/39load_namespaces_rt41083.t	2009-03-24 07:33:31 UTC (rev 5807)
+++ DBIx-Class/0.08/trunk/t/39load_namespaces_rt41083.t	2009-03-24 07:49:54 UTC (rev 5808)
@@ -32,7 +32,7 @@
 };
 ok(!$@) or diag $@;
 ok(_chk_warning($warnings), 'expected no resultset complaint');
-ok(_chk_extra_sources_warning($warnings), 'expected no extra sources complaint');
+ok(_chk_extra_sources_warning($warnings), 'expected no extra sources complaint') or diag($warnings);
 undef $warnings;
 
 eval {
@@ -47,5 +47,5 @@
 };
 ok(!$@) or diag $@;
 ok(_chk_warning($warnings), 'expected no resultset complaint') or diag $warnings;
-ok(_chk_extra_sources_warning($warnings), 'expected no extra sources complaint');
+ok(_chk_extra_sources_warning($warnings), 'expected no extra sources complaint') or diag($warnings);
 undef $warnings;




More information about the Bast-commits mailing list