From: Amiri Barksdale at Home Date: Mon, 3 Jan 2011 22:13:03 +0000 (-0800) Subject: Fix view ordering by requiring ddo declaration in result class X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c965b761a26805b669f939e4813d67fae094b644;p=dbsrgits%2FDBIx-Class-ResultSource-MultipleTableInheritance.git Fix view ordering by requiring ddo declaration in result class --- diff --git a/lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm b/lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm index ba2ec52..16a90af 100644 --- a/lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm +++ b/lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm @@ -153,7 +153,7 @@ method attach_additional_sources () { $table->add_relationship( 'parent_'.$add->name, $add->source_name, \%pk_join ); - $self->deploy_depends_on->{$add->result_class} = 1; + $self->deploy_depends_on->{$add->result_class} = 1 if $add->isa('DBIx::Class::ResultSource::View'); } $table->add_columns( map { ($_ => { %{$self->column_info($_)} }) } diff --git a/t/02view_def.t b/t/02view_def.t index 4b5d2c9..3017243 100644 --- a/t/02view_def.t +++ b/t/02view_def.t @@ -5,7 +5,6 @@ use File::Temp; use Test::More qw(no_plan); use Test::Exception; use LoadTest; -use Devel::Dwarn; BEGIN { $ENV{DBIC_TRACE} = 0; @@ -24,6 +23,7 @@ dies_ok { LoadTest->source('Foo')->view_definition } my $schema = LoadTest->connect( $dsn, $user, $pass ); $schema->storage->ensure_connected; +$schema->storage->dbh->{Warn} = 0; my $dir = "t/sql"; # tempdir(CLEANUP => 0); diff --git a/t/03insert.t b/t/03insert.t index f25270c..2293d75 100644 --- a/t/03insert.t +++ b/t/03insert.t @@ -4,6 +4,7 @@ use lib 't/lib'; use Test::More qw(no_plan); use Test::Exception; use CafeInsertion; +use Devel::Dwarn; BEGIN { $ENV{DBIC_TRACE} = 0; @@ -19,6 +20,7 @@ EOM my $schema = CafeInsertion->connect( $dsn, $user, $pass ); $schema->storage->ensure_connected; $schema->storage->_use_insert_returning(0); +$schema->storage->dbh->{Warn} = 0; my $dir = "t/sql"; # tempdir(CLEANUP => 0); $schema->create_ddl_dir( ['PostgreSQL'], 0.1, $dir ); @@ -33,8 +35,13 @@ isa_ok( my ( $drink, $drink1 ); lives_ok { - $drink = $schema->resultset('Sumatra') - ->create( { sweetness => 4, aroma => 'earthy', flavor => 'great' } ); + $drink = $schema->resultset('Sumatra')->create( + { sweetness => 4, + fat_free => 1, + aroma => 'earthy', + flavor => 'great' + } + ); } "I can call a create on a view sumatra"; @@ -44,11 +51,10 @@ lives_ok { "I can do it for the other view, too"; my $sqlt_object = $schema->{sqlt}; - is_deeply( [ map { $_->name } $sqlt_object->get_views ], [ qw/ - coffee + coffee sumatra / ], diff --git a/t/04no_sequence_defined.t b/t/04no_sequence_defined.t index 04dc763..dedb510 100644 --- a/t/04no_sequence_defined.t +++ b/t/04no_sequence_defined.t @@ -43,3 +43,13 @@ lives_ok { } "I can do it for the other view, too"; +my $sqlt_object = $schema->{sqlt}; +is_deeply( + [ map { $_->name } $sqlt_object->get_views ], + [ qw/ + salad + mesclun + / + ], + "SQLT view order triumphantly matches our order." +); diff --git a/t/lib/CafeInsertion/Result/Coffee.pm b/t/lib/CafeInsertion/Result/Coffee.pm index 0dc65b0..c3f2e27 100644 --- a/t/lib/CafeInsertion/Result/Coffee.pm +++ b/t/lib/CafeInsertion/Result/Coffee.pm @@ -8,6 +8,7 @@ use aliased 'DBIx::Class::ResultSource::MultipleTableInheritance' => 'MTI'; __PACKAGE__->table_class(MTI); __PACKAGE__->table('coffee'); + __PACKAGE__->add_columns( "id", { data_type => "integer", diff --git a/t/lib/CafeInsertion/Result/Cream.pm b/t/lib/CafeInsertion/Result/Cream.pm new file mode 100644 index 0000000..93efeb1 --- /dev/null +++ b/t/lib/CafeInsertion/Result/Cream.pm @@ -0,0 +1,20 @@ +package # hide from PAUSE + CafeInsertion::Result::Cream; + +use strict; +use warnings; +use parent 'DBIx::Class::Core'; + +__PACKAGE__->table('cream'); + +__PACKAGE__->add_columns( + id => { + data_type => 'integer', + is_auto_increment => 1, + }, + fat_free => { data_type => 'boolean', default => 0 } +); + +__PACKAGE__->set_primary_key('id'); + +1; diff --git a/t/lib/CafeInsertion/Result/Sumatra.pm b/t/lib/CafeInsertion/Result/Sumatra.pm index 3c6c7b7..09cfc94 100644 --- a/t/lib/CafeInsertion/Result/Sumatra.pm +++ b/t/lib/CafeInsertion/Result/Sumatra.pm @@ -8,8 +8,9 @@ use parent 'CafeInsertion::Result::Coffee'; require CafeInsertion::Result::Sugar; __PACKAGE__->table('sumatra'); +__PACKAGE__->result_source_instance->deploy_depends_on(["CafeInsertion::Result::Coffee"]); __PACKAGE__->result_source_instance->add_additional_parents( - "CafeInsertion::Result::Sugar"); + "CafeInsertion::Result::Sugar","CafeInsertion::Result::Cream"); __PACKAGE__->add_columns( "aroma", { data_type => "text" } ); __PACKAGE__->has_many( diff --git a/t/lib/LoadTest/Result/Bar.pm b/t/lib/LoadTest/Result/Bar.pm index e236be3..a06ab16 100644 --- a/t/lib/LoadTest/Result/Bar.pm +++ b/t/lib/LoadTest/Result/Bar.pm @@ -8,7 +8,7 @@ use parent 'LoadTest::Result::Foo'; require LoadTest::Result::Mixin; __PACKAGE__->table('bar'); - +__PACKAGE__->result_source_instance->deploy_depends_on(["LoadTest::Result::Foo"]); __PACKAGE__->result_source_instance->add_additional_parents( "LoadTest::Result::Mixin" ); diff --git a/t/lib/LoadTest/Result/JustATable.pm b/t/lib/LoadTest/Result/JustATable.pm index 1bf4e54..d05669d 100644 --- a/t/lib/LoadTest/Result/JustATable.pm +++ b/t/lib/LoadTest/Result/JustATable.pm @@ -12,11 +12,11 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key('id'); -__PACKAGE__->has_many( - 'bars', - 'LoadTest::Result::Bar', - { 'foreign.b' => 'self.id' } -); +#__PACKAGE__->has_many( + #'bars', + #'LoadTest::Result::Bar', + #{ 'foreign.b' => 'self.id' } +#); 1; diff --git a/t/lib/NoSequenceSalad/Result/Mesclun.pm b/t/lib/NoSequenceSalad/Result/Mesclun.pm index e36e42a..0ccd9d7 100644 --- a/t/lib/NoSequenceSalad/Result/Mesclun.pm +++ b/t/lib/NoSequenceSalad/Result/Mesclun.pm @@ -8,6 +8,7 @@ use parent 'NoSequenceSalad::Result::Salad'; require NoSequenceSalad::Result::Dressing; __PACKAGE__->table('mesclun'); +__PACKAGE__->result_source_instance->deploy_depends_on(["NoSequenceSalad::Result::Salad"]); __PACKAGE__->result_source_instance->add_additional_parent( NoSequenceSalad::Result::Dressing->result_source_instance ); __PACKAGE__->add_columns( "spiciness", { data_type => "integer" } );