From: Brandon Black Date: Tue, 21 Mar 2006 21:20:39 +0000 (+0000) Subject: Class::C3::reinit changes backported from branch for speed reasons, version bumped... X-Git-Tag: 0.03000~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=09d632a1a14215a5b472f04978466fa654bbb768;hp=ac5ad55744b535237c6f5f7cfeb60ae972e8a03a;p=dbsrgits%2FDBIx-Class-Schema-Loader.git Class::C3::reinit changes backported from branch for speed reasons, version bumped, changes updated, needs testing before release --- diff --git a/Changes b/Changes index 8cea979..dfb8f49 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ Revision history for Perl extension DBIx::Class::Schema::Loader +0.02007 Not yet released + - Backported Class::C3::reinitialize changes from branch, + resulting in significantly reduced load time + 0.02006 Fri Mar 17 04:55:55 UTC 2006 - Fix long-standing table/col-name case bugs diff --git a/META.yml b/META.yml index 170818b..3bfd22d 100644 --- a/META.yml +++ b/META.yml @@ -1,6 +1,6 @@ --- name: DBIx-Class-Schema-Loader -version: 0.02006 +version: 0.02007 author: - 'Brandon Black, C' abstract: Dynamic definition of a DBIx::Class::Schema @@ -20,7 +20,7 @@ build_requires: provides: DBIx::Class::Schema::Loader: file: lib/DBIx/Class/Schema/Loader.pm - version: 0.02006 + version: 0.02007 DBIx::Class::Schema::Loader::DB2: file: lib/DBIx/Class/Schema/Loader/DB2.pm DBIx::Class::Schema::Loader::Generic: @@ -33,4 +33,4 @@ provides: file: lib/DBIx/Class/Schema/Loader/Writing.pm DBIx::Class::Schema::Loader::mysql: file: lib/DBIx/Class/Schema/Loader/mysql.pm -generated_by: Module::Build version 0.2612 +generated_by: Module::Build version 0.2611 diff --git a/lib/DBIx/Class/Schema/Loader.pm b/lib/DBIx/Class/Schema/Loader.pm index 20b014a..aa62e41 100644 --- a/lib/DBIx/Class/Schema/Loader.pm +++ b/lib/DBIx/Class/Schema/Loader.pm @@ -10,7 +10,7 @@ use UNIVERSAL::require; # Always remember to do all digits for the version even if they're 0 # i.e. first release of 0.XX *must* be 0.XX000. This avoids fBSD ports # brain damage and presumably various other packaging systems too -our $VERSION = '0.02006'; +our $VERSION = '0.02007'; __PACKAGE__->mk_classaccessor('loader'); diff --git a/lib/DBIx/Class/Schema/Loader/Generic.pm b/lib/DBIx/Class/Schema/Loader/Generic.pm index 5112862..b9ff28e 100644 --- a/lib/DBIx/Class/Schema/Loader/Generic.pm +++ b/lib/DBIx/Class/Schema/Loader/Generic.pm @@ -380,7 +380,6 @@ sub _load_classes { $self->{_tables} = \@tables; foreach my $table (@tables) { - my ($db_schema, $tbl) = split /\./, $table; if($tbl) { $table = $self->drop_db_schema ? $tbl : $table; @@ -390,6 +389,15 @@ sub _load_classes { my $table_moniker = $self->_table2moniker($db_schema, $tbl); my $table_class = $schema . q{::} . $table_moniker; + $self->classes->{$lc_table} = $table_class; + $self->monikers->{$lc_table} = $table_moniker; + $self->classes->{$table} = $table_class; + $self->monikers->{$table} = $table_moniker; + + no warnings 'redefine'; + local *Class::C3::reinitialize = sub { }; + use warnings; + { no strict 'refs'; @{"${table_class}::ISA"} = qw/DBIx::Class/; } @@ -399,6 +407,13 @@ sub _load_classes { $table_class->load_resultset_components(@{$self->resultset_components}) if @{$self->resultset_components}; $self->_inject($table_class, @{$self->left_base_classes}); + } + + Class::C3::reinitialize; + + foreach my $table (@tables) { + my $table_class = $self->classes->{$table}; + my $table_moniker = $self->monikers->{$table}; warn qq/\# Initializing table "$table" as "$table_class"\n/ if $self->debug; @@ -417,10 +432,6 @@ sub _load_classes { if $self->debug && @$pks; $schema->register_class($table_moniker, $table_class); - $self->classes->{$lc_table} = $table_class; - $self->monikers->{$lc_table} = $table_moniker; - $self->classes->{$table} = $table_class; - $self->monikers->{$table} = $table_moniker; } }