Merge 're_refactor_bugfix' into 'DBIx-Class-current'
Luke Saunders [Wed, 7 Jun 2006 05:49:10 +0000 (06:49 +0100)]
Changes
lib/DBIx/Class/Componentised.pm
lib/DBIx/Class/Core.pm
lib/DBIx/Class/DB.pm
t/05components.t

diff --git a/Changes b/Changes
index 78309b9..6df8074 100644 (file)
--- a/Changes
+++ b/Changes
@@ -2,6 +2,7 @@ Revision history for DBIx::Class
 
 0.06999_02 sometime?
         - Fixed up POD::Coverage tests, filled in some POD holes
+        - Added a warning for incorrect component order in load_components
        - Fixed resultset bugs to do with related searches
 
 0.06999_01 2006-05-28 17:19:30
index e23a0b4..412958f 100644 (file)
@@ -12,8 +12,19 @@ sub inject_base {
   {
     no strict 'refs';
     foreach my $to (reverse @to_inject) {
-       unshift( @{"${target}::ISA"}, $to )
-         unless ($target eq $to || $target->isa($to));
+      my @comps = qw(DigestColumns ResultSetManager Ordered UTF8Columns);
+           # Add components here that need to be loaded before Core
+      foreach my $first_comp (@comps) {
+        if ($to eq 'DBIx::Class::Core' &&
+            $target->isa("DBIx::Class::${first_comp}")) {
+          warn "Possible incorrect order of components in ".
+               "${target}::load_components($first_comp) call: Core loaded ".
+               "before $first_comp. See the documentation for ".
+               "DBIx::Class::$first_comp for more information";
+        }
+      }
+      unshift( @{"${target}::ISA"}, $to )
+        unless ($target eq $to || $target->isa($to));
     }
   }
 
@@ -54,8 +65,8 @@ sub ensure_class_loaded {
   eval "require $f_class";
   my $err = $@;
   Class::Inspector->loaded($f_class)
-      or die $err || "require $f_class was successful but the package".
-                     "is not defined";
+    or die $err || "require $f_class was successful but the package".
+                   "is not defined";
 }
 
 1;
index 87e7dce..4f9a59c 100644 (file)
@@ -42,6 +42,8 @@ The core modules currently are:
 
 =item L<DBIx::Class::Relationship>
 
+=item L<DBIx::Class::PK::Auto>
+
 =item L<DBIx::Class::PK>
 
 =item L<DBIx::Class::Row>
index 07c8924..0fb7e8a 100644 (file)
@@ -176,9 +176,6 @@ Alias for L<txn_commit>
 
 Alias for L<txn_rollback>
 
-
-1;
-
 =head1 AUTHORS
 
 Matt S. Trout <mst@shadowcatsystems.co.uk>
@@ -189,3 +186,4 @@ You may distribute this code under the same terms as Perl itself.
 
 =cut
 
+1;
index 4b063bf..567bc1b 100644 (file)
@@ -7,7 +7,7 @@ use Test::More;
 use lib qw(t/lib);
 use DBICTest::ForeignComponent;
 
-plan tests => 2;
+plan tests => 5;
 
 #   Tests if foreign component was loaded by calling foreign's method
 ok( DBICTest::ForeignComponent->foreign_test_method, 'foreign component' );
@@ -34,3 +34,31 @@ is_deeply( \@DBICTest::_InjectBaseTest::ISA,
     /],
     'inject_base filters duplicates'
 );
+
+# Test for a warning with incorrect order in load_components
+my @warnings = ();
+{
+  package A::Test;
+  our @ISA = 'DBIx::Class';
+  {
+    local $SIG{__WARN__} = sub { push @warnings, shift};
+    __PACKAGE__->load_components(qw(Core UTF8Columns));
+  }
+}
+like( $warnings[0], qr/Core loaded before UTF8Columns/,
+      'warning issued for incorrect order in load_components()' );
+is( scalar @warnings, 1,
+    'only one warning issued for incorrect load_components call' );
+
+# Test that no warning is issued for the correct order in load_components
+{
+  @warnings = ();
+  package B::Test;
+  our @ISA = 'DBIx::Class';
+  {
+    local $SIG{__WARN__} = sub { push @warnings, shift };
+    __PACKAGE__->load_components(qw(UTF8Columns Core));
+  }
+}
+is( scalar @warnings, 0,
+    'warning not issued for correct order in load_components()' );