[Bast-commits] r7971 - in branches/DBIx-Class-Schema-Loader/back-compat: . lib/DBIx/Class/Schema/Loader

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Sat Nov 28 08:17:05 GMT 2009


Author: caelum
Date: 2009-11-28 08:17:05 +0000 (Sat, 28 Nov 2009)
New Revision: 7971

Modified:
   branches/DBIx-Class-Schema-Loader/back-compat/Makefile.PL
   branches/DBIx-Class-Schema-Loader/back-compat/TODO-BACKCOMPAT
   branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/Base.pm
Log:
backcompat mode now runs more than once

Modified: branches/DBIx-Class-Schema-Loader/back-compat/Makefile.PL
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/Makefile.PL	2009-11-28 07:44:01 UTC (rev 7970)
+++ branches/DBIx-Class-Schema-Loader/back-compat/Makefile.PL	2009-11-28 08:17:05 UTC (rev 7971)
@@ -27,6 +27,8 @@
 
 install_script 'script/dbicdump';
 
+tests_recursive;
+
 # This is my manual hack for better feature control
 #  If you want to change the default answer for a feature,
 #  set the appropriate environment variable, like

Modified: branches/DBIx-Class-Schema-Loader/back-compat/TODO-BACKCOMPAT
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/TODO-BACKCOMPAT	2009-11-28 07:44:01 UTC (rev 7970)
+++ branches/DBIx-Class-Schema-Loader/back-compat/TODO-BACKCOMPAT	2009-11-28 08:17:05 UTC (rev 7971)
@@ -8,7 +8,6 @@
 *** 0.04006 mode
 
 * use the detector and compat relbuilder ilmari already wrote for static schemas
-* make sure results are not singularized
 * add a loud warning that says that we're running in backcompat mode, and refers
   to the ::Manual::UpgradingFrom4006 POD.
 
@@ -21,11 +20,6 @@
 * need to run in 0.04006 mode (by seeding with a Schema.pm generated by
   0.04006, activation of backcompat mode should be minimally invasive.)
 
-*** common tests
-
-* should be all based off a static schema, because dynamic schemas will be
-  in 0.04006 mode
-
 *** Schema::Loader::Base
 
 * 'naming' accessor should be a Class::Accessor::Grouped 'inherited' type

Modified: branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/Base.pm
===================================================================
--- branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/Base.pm	2009-11-28 07:44:01 UTC (rev 7970)
+++ branches/DBIx-Class-Schema-Loader/back-compat/lib/DBIx/Class/Schema/Loader/Base.pm	2009-11-28 08:17:05 UTC (rev 7971)
@@ -33,7 +33,6 @@
                                 moniker_map
                                 inflect_singular
                                 inflect_plural
-                                naming
                                 debug
                                 dump_directory
                                 dump_overwrite
@@ -51,6 +50,10 @@
                                 monikers
                              /);
 
+__PACKAGE__->mk_accessors(qw/
+                                version_to_dump
+/);
+
 =head1 NAME
 
 DBIx::Class::Schema::Loader::Base - Base DBIx::Class::Schema::Loader Implementation.
@@ -322,6 +325,8 @@
 
     $self->{dump_directory} ||= $self->{temp_directory};
 
+    $self->version_to_dump($DBIx::Class::Schema::Loader::VERSION);
+
     $self->_check_back_compat;
 
     $self;
@@ -330,6 +335,17 @@
 sub _check_back_compat {
     my ($self) = @_;
 
+# dynamic schemas will always be in 0.04006 mode
+    if ($self->{dynamic}) {
+        no strict 'refs';
+        my $class = ref $self || $self;
+        unshift @{"${class}::ISA"},
+            'DBIx::Class::Schema::Loader::Compat::v0_040';
+        Class::C3::reinitialize;
+        return;
+    }
+
+# otherwise check if we need backcompat mode for a static schema
     my $filename = $self->_get_dump_filename($self->schema_class);
     return unless -e $filename;
 
@@ -337,14 +353,17 @@
         or croak "Cannot open '$filename' for reading: $!";
 
     while (<$fh>) {
-        if (/^# Created by DBIx::Class::Schema::Loader (v\d+)\.(\d+)/) {
-            my $ver = "${1}_${2}";
+        if (/^# Created by DBIx::Class::Schema::Loader v((\d+)\.(\d+))/) {
+            my $real_ver = $1;
+            my $ver      = "v${2}_${3}";
             while (1) {
                 my $compat_class = "DBIx::Class::Schema::Loader::Compat::${ver}";
                 if ($self->load_optional_class($compat_class)) {
                     no strict 'refs';
                     my $class = ref $self || $self;
                     unshift @{"${class}::ISA"}, $compat_class;
+                    Class::C3::reinitialize;
+                    $self->version_to_dump($real_ver);
                     last;
                 }
                 $ver =~ s/\d\z// or last;
@@ -663,7 +682,7 @@
     }
 
     $text .= $self->_sig_comment(
-      $DBIx::Class::Schema::Loader::VERSION, 
+      $self->version_to_dump,
       POSIX::strftime('%Y-%m-%d %H:%M:%S', localtime)
     );
 




More information about the Bast-commits mailing list