From: Rafael Kitover Date: Sat, 28 Nov 2009 08:17:05 +0000 (+0000) Subject: backcompat mode now runs more than once X-Git-Tag: 0.04999_13~23^2~16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0101254328299030c7ab921ac546b6b91ad3ded3;p=dbsrgits%2FDBIx-Class-Schema-Loader.git backcompat mode now runs more than once --- diff --git a/Makefile.PL b/Makefile.PL index 7baf854..58f13ae 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -27,6 +27,8 @@ requires 'Class::Unload' => 0; 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 diff --git a/TODO-BACKCOMPAT b/TODO-BACKCOMPAT index 54376f4..96bf2ad 100644 --- a/TODO-BACKCOMPAT +++ b/TODO-BACKCOMPAT @@ -8,7 +8,6 @@ SL Backcompat Plan: *** 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 @@ SL Backcompat Plan: * 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 diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index de54546..2e39d31 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -33,7 +33,6 @@ __PACKAGE__->mk_ro_accessors(qw/ moniker_map inflect_singular inflect_plural - naming debug dump_directory dump_overwrite @@ -51,6 +50,10 @@ __PACKAGE__->mk_ro_accessors(qw/ 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 @@ sub new { $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 new { 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 @@ sub _check_back_compat { 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 @@ sub _write_classfile { } $text .= $self->_sig_comment( - $DBIx::Class::Schema::Loader::VERSION, + $self->version_to_dump, POSIX::strftime('%Y-%m-%d %H:%M:%S', localtime) );