Merge 'trunk' into 'subclassed_rsset'
Peter Rabbitson [Tue, 21 Apr 2009 10:57:35 +0000 (10:57 +0000)]
r5847@Thesaurus (orig r5846):  ribasushi | 2009-03-30 01:05:37 +0200
Take experimental off TxnScopeGuard
r5848@Thesaurus (orig r5847):  ribasushi | 2009-03-30 01:44:40 +0200
Dev-Release 0.08099_08
r5852@Thesaurus (orig r5851):  castaway | 2009-03-31 08:41:42 +0200
Fix my email address in AUTHOR

r5859@Thesaurus (orig r5858):  plu | 2009-04-07 16:15:32 +0200
Added caveat notes to dual trick in cookbook
r5875@Thesaurus (orig r5874):  arcanez | 2009-04-09 15:35:46 +0200
require DBD::SQLite 1.21+
r5885@Thesaurus (orig r5884):  caelum | 2009-04-13 14:47:47 +0200
add test for connect_info hashref
r5887@Thesaurus (orig r5886):  pcc | 2009-04-13 20:35:51 +0200
Correctly propagate forced left joins through arrayrefs and hashrefs
r5889@Thesaurus (orig r5888):  caelum | 2009-04-15 15:47:53 +0200
duplicate
r5891@Thesaurus (orig r5890):  plu | 2009-04-17 10:10:19 +0200
Added update_or_new to ResultSet.pm
r5903@Thesaurus (orig r5902):  ilmari | 2009-04-18 20:38:44 +0200
Don't warn when reregistering a source under the same name
r5913@Thesaurus (orig r5912):  matthewt | 2009-04-19 16:52:15 +0200
0.08100 release
r5916@Thesaurus (orig r5915):  arcanez | 2009-04-21 00:07:07 +0200
move load_optional_class into Class::C3::Componentised

r5923@Thesaurus (orig r5922):  ribasushi | 2009-04-21 10:37:11 +0200
New SQLite kicks ass - remove some warning silencers and reinstantiate tests
r5924@Thesaurus (orig r5923):  ribasushi | 2009-04-21 10:51:03 +0200
Multiple cdbi-compat test cleanups
Clarify search_like deprecation
r5925@Thesaurus (orig r5924):  ribasushi | 2009-04-21 10:51:59 +0200
More author test-requires
r5926@Thesaurus (orig r5925):  ribasushi | 2009-04-21 10:53:35 +0200
t/ janitorial work

lib/DBIx/Class/Schema.pm
t/39load_namespaces_rt41083.t
t/63register_class.t

index 1c4dd0e..aa32f25 100644 (file)
@@ -1267,25 +1267,27 @@ sub register_extra_source {
 sub _register_source {
   my ($self, $moniker, $source, $params) = @_;
 
+  my $orig_source = $source;
+
   $source = $source->new({ %$source, source_name => $moniker });
+  $source->schema($self);
+  weaken($source->{schema}) if ref($self);
+
+  my $rs_class = $source->result_class;
+
 
   my %reg = %{$self->source_registrations};
   $reg{$moniker} = $source;
   $self->source_registrations(\%reg);
 
-  $source->schema($self);
-  weaken($source->{schema}) if ref($self);
   return if ($params->{extra});
 
-  if ($source->result_class) {
-    my %map = %{$self->class_mappings};
-    if (exists $map{$source->result_class}
-            && $map{$source->result_class} ne $moniker) {
-      warn $source->result_class . ' already has a source, use register_extra_source for additional sources';
-    }
-    $map{$source->result_class} = $moniker;
-    $self->class_mappings(\%map);
+  my %map = %{$self->class_mappings};
+  if (exists $map{$rs_class} and $rs_class->result_source_instance ne $orig_source) {
+    carp "$rs_class already has a source, use register_extra_source for additional sources";
   }
+  $map{$rs_class} = $moniker;
+  $self->class_mappings(\%map);
 }
 
 sub _unregister_source {
index 861658e..c99528b 100644 (file)
@@ -2,30 +2,9 @@
 
 use strict;
 use warnings;
-use Test::More skip_all => 'Postponed until after 0.08100';
 
 use lib 't/lib';
-
-=begin
-
-How did this get back here? The test is borked, there is a branch with
-the correct test and a tentative fix - branches/subclassed_rsset
-
-Make sure to nuke this file when merging, it is only left here to make
-merging of the above branch easier.
-
-
-ribasushi
-
-
-=cut
-
-
-__END__
-
-
-
-plan tests => 15;
+use Test::More tests => 8;
 
 sub _chk_warning {
   defined $_[0]?
@@ -45,16 +24,6 @@ sub _verify_sources {
     \@monikers,
     'List of resultsource registrations',
   );
-
-  my %seen_rc;
-  for my $m (@monikers) {
-    my $src = DBICNSTest::RtBug41083->source ($m);
-    my $rc = $src->result_class;
-
-    ok ( (++$seen_rc{$rc} == 1), "result_class of $m is unique")
-      || diag "Source: $m, result_class: $rc";
-    like ($rc, qr/:: $m $/x, 'result_class matches moniker');
-  }
 }
 
 {
index 513c6d3..e9053a3 100644 (file)
@@ -1,19 +1,14 @@
 use strict;
 use warnings;  
 
-use Test::More tests => 3;
+use Test::More tests => 2;
 use lib qw(t/lib);
 use DBICTest;
 use DBICTest::Schema;
 use DBICTest::Schema::Artist;
 
 DBICTest::Schema::Artist->source_name('MyArtist');
-{
-    my $w;
-    local $SIG{__WARN__} = sub { $w = shift };
-    DBICTest::Schema->register_class('FooA', 'DBICTest::Schema::Artist');
-    like ($w, qr/use register_extra_source/, 'Complain about using register_class on an already-registered class');
-}
+DBICTest::Schema->register_class('FooA', 'DBICTest::Schema::Artist');
 
 my $schema = DBICTest->init_schema();