From: Devin Austin Date: Wed, 19 Jan 2011 20:13:57 +0000 (-0700) Subject: first attempt at getting resultset load order correct, tests pass X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0a35df1c685b438ba6c876d9de7197a52b2445dd;p=dbsrgits%2FDBIx-Class.git first attempt at getting resultset load order correct, tests pass --- diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index e8920b0..6703a0f 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -1889,7 +1889,7 @@ sub inject_resultset_components { my @components = @{shift @_}; # this generation of class bit needs to go into CCC - my $class = $self->resultset_class . '::' . rand(100); + my $class = $self->resultset_class . "::WITH::" . join ("::", @components); Class::C3::Componentised->inject_base($class, $self->resultset_class); $self->resultset_class($class); diff --git a/t/lib/A/MoarUseless.pm b/t/lib/A/MoarUseless.pm new file mode 100644 index 0000000..ce2faeb --- /dev/null +++ b/t/lib/A/MoarUseless.pm @@ -0,0 +1,3 @@ +package A::MoarUseless; + +1; diff --git a/t/lib/A/MoarUselessRSLoader.pm b/t/lib/A/MoarUselessRSLoader.pm new file mode 100644 index 0000000..e4b46cd --- /dev/null +++ b/t/lib/A/MoarUselessRSLoader.pm @@ -0,0 +1,7 @@ +package A::MoarUselessRSLoader; + +use Class::C3::Componentised::LoadActions; + +AFTER_APPLY { $_[0]->result_source_instance->inject_resultset_components(['+A::MoarUseless']) }; + +1; diff --git a/t/lib/DBICTest/Schema/Artist.pm b/t/lib/DBICTest/Schema/Artist.pm index 530ee89..7d6a262 100644 --- a/t/lib/DBICTest/Schema/Artist.pm +++ b/t/lib/DBICTest/Schema/Artist.pm @@ -65,7 +65,7 @@ __PACKAGE__->has_many( ); __PACKAGE__->many_to_many('artworks', 'artwork_to_artist', 'artwork'); -__PACKAGE__->result_source_instance->inject_resultset_components(['+A::Useless']); +__PACKAGE__->result_source_instance->inject_resultset_components(['+A::Useless', '+A::MoarUseless']); sub sqlt_deploy_hook { my ($self, $sqlt_table) = @_; diff --git a/t/resultset/components.t b/t/resultset/components.t index cd637e9..3f66e6d 100644 --- a/t/resultset/components.t +++ b/t/resultset/components.t @@ -5,12 +5,25 @@ use Test::More; use lib qw(t/lib); use DBICTest; - +use Data::Dumper; my $schema = DBICTest->init_schema; isa_ok $schema->resultset('Artist'), 'A::Useless', 'Artist RS'; ok !$schema->resultset('CD')->isa('A::Useless'), 'CD RS is not A::Useless'; +my @classes = ('DBICTest::BaseResultSet::WITH::+A::Useless::+A::MoarUseless', + 'A::Useless', + 'A::MoarUseless', + 'DBICTest::BaseResultSet', + 'DBIx::Class::ResultSet', + 'DBIx::Class', + 'DBIx::Class::Componentised', + 'Class::C3::Componentised', + 'Class::Accessor::Grouped'); +warn "classes: " . Dumper \@classes; + +is_deeply(mro::get_linear_isa(ref $schema->resultset('Artist')), \@classes, 'Proper ISA Stack Order'); + isa_ok $schema->resultset('Employee'), 'A::Useless', 'Employee RS'; done_testing;