From: Amiri Barksdale at Home Date: Sun, 13 Jun 2010 00:10:31 +0000 (-0700) Subject: Change API of deploy_depends_on: pass it source names. Fix optional deps on 105view_d... X-Git-Tag: v0.08124~114^2~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7c4ade2a750b5299842e8f55f5bdcd1488168867;p=dbsrgits%2FDBIx-Class.git Change API of deploy_depends_on: pass it source names. Fix optional deps on 105view_deps.t. Catch warning in 105view_deps.t. --- diff --git a/lib/DBIx/Class/ResultSource/View.pm b/lib/DBIx/Class/ResultSource/View.pm index 2771ca9..91e59db 100644 --- a/lib/DBIx/Class/ResultSource/View.pm +++ b/lib/DBIx/Class/ResultSource/View.pm @@ -4,6 +4,7 @@ use strict; use warnings; use DBIx::Class::ResultSet; +use Devel::Dwarn; use base qw/DBIx::Class/; __PACKAGE__->load_components(qw/ResultSource/); @@ -132,11 +133,11 @@ syntaxes. =head2 deploy_depends_on __PACKAGE__->result_source_instance->deploy_depends_on( - "MyDB::Schema::Result::Year","MyDB::Schema::Result::CD" + ["Year","CD"] ); Specify the views (and only the views) that this view depends on. -Pass this an array reference. +Pass this an array reference of source names. =head1 OVERRIDDEN METHODS @@ -164,12 +165,10 @@ The constructor. sub new { my ( $self, @args ) = @_; my $new = $self->next::method(@args); - $new->{deploy_depends_on} - = { - map { $_->result_source_instance->name => 1 } - @{ $new->{deploy_depends_on}||[] } - } - unless ref $new->{deploy_depends_on} eq 'HASH'; + $new->{deploy_depends_on} = + { map { $_ => 1 } + @{ $new->{deploy_depends_on} || [] } } + unless ref $new->{deploy_depends_on} eq 'HASH'; return $new; } diff --git a/lib/SQL/Translator/Parser/DBIx/Class.pm b/lib/SQL/Translator/Parser/DBIx/Class.pm index bd3d3ba..cbeaf86 100644 --- a/lib/SQL/Translator/Parser/DBIx/Class.pm +++ b/lib/SQL/Translator/Parser/DBIx/Class.pm @@ -399,7 +399,7 @@ sub _resolve_view_deps { return {}; } my ($new_source_name) = - grep { $view->schema->source($_)->name eq $dep } + grep { $view->schema->source($_)->source_name eq $dep } @{ [ $view->schema->sources ] }; my $subdeps = _resolve_view_deps( $view->schema->source($new_source_name), diff --git a/t/105view_deps.t b/t/105view_deps.t index d53dc79..b740c58 100644 --- a/t/105view_deps.t +++ b/t/105view_deps.t @@ -5,11 +5,16 @@ use warnings; use Test::More; use Test::Exception; +use Test::Warn; use lib qw(t/lib); use ViewDeps; use ViewDepsBad; BEGIN { + require DBIx::Class; + plan skip_all => + 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('deploy') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('deploy'); use_ok('DBIx::Class::ResultSource::View'); } @@ -65,7 +70,7 @@ ok( $schema2, 'Connected to ViewDepsBad schema OK' ); #################### DEPLOY2 -$schema2->deploy( { add_drop_table => 1 } ); +warnings_exist { $schema2->deploy( { add_drop_table => 1 } ); } [qr/no such table: main.aba_name_artists/], "Deploying the bad schema produces a warning: aba_name_artists was not created."; #################### DOES ORDERING WORK 2? diff --git a/t/lib/ViewDeps/Result/AbNameArtists.pm b/t/lib/ViewDeps/Result/AbNameArtists.pm index 3651a5b..fab3a7c 100644 --- a/t/lib/ViewDeps/Result/AbNameArtists.pm +++ b/t/lib/ViewDeps/Result/AbNameArtists.pm @@ -11,7 +11,7 @@ __PACKAGE__->result_source_instance->view_definition( "SELECT id,name FROM a_name_artists WHERE name like 'ab%'" ); __PACKAGE__->result_source_instance->deploy_depends_on( - ["ViewDeps::Result::ANameArtists"] + ["ANameArtists"] ); __PACKAGE__->add_columns( diff --git a/t/lib/ViewDeps/Result/AbaNameArtists.pm b/t/lib/ViewDeps/Result/AbaNameArtists.pm index fc989f6..d0a1f04 100644 --- a/t/lib/ViewDeps/Result/AbaNameArtists.pm +++ b/t/lib/ViewDeps/Result/AbaNameArtists.pm @@ -10,7 +10,7 @@ __PACKAGE__->table('aba_name_artists'); __PACKAGE__->result_source_instance->view_definition( "SELECT id,name FROM ab_name_artists WHERE name like 'aba%'" ); __PACKAGE__->result_source_instance->deploy_depends_on( - ["ViewDeps::Result::AbNameArtists"] ); + ["AbNameArtists"] ); __PACKAGE__->add_columns( id => { data_type => 'integer', is_auto_increment => 1 }, diff --git a/t/lib/ViewDeps/Result/AbaNameArtistsAnd2010CDsWithManyTracks.pm b/t/lib/ViewDeps/Result/AbaNameArtistsAnd2010CDsWithManyTracks.pm index 83c651b..4395923 100644 --- a/t/lib/ViewDeps/Result/AbaNameArtistsAnd2010CDsWithManyTracks.pm +++ b/t/lib/ViewDeps/Result/AbaNameArtistsAnd2010CDsWithManyTracks.pm @@ -11,7 +11,7 @@ __PACKAGE__->result_source_instance->view_definition( "SELECT aba.id,aba.name,cd.title,cd.year,cd.number_tracks FROM aba_name_artists aba JOIN year_2010_cds_with_many_tracks cd on (aba.id = cd.artist)" ); __PACKAGE__->result_source_instance->deploy_depends_on( - ["ViewDeps::Result::AbNameArtists","ViewDeps::Result::Year2010CDsWithManyTracks"] ); + ["AbNameArtists","Year2010CDsWithManyTracks"] ); __PACKAGE__->add_columns( id => { data_type => 'integer', is_auto_increment => 1 }, diff --git a/t/lib/ViewDeps/Result/Year2010CDsWithManyTracks.pm b/t/lib/ViewDeps/Result/Year2010CDsWithManyTracks.pm index c6e4144..c7ccfcb 100644 --- a/t/lib/ViewDeps/Result/Year2010CDsWithManyTracks.pm +++ b/t/lib/ViewDeps/Result/Year2010CDsWithManyTracks.pm @@ -12,7 +12,7 @@ __PACKAGE__->result_source_instance->view_definition( ); __PACKAGE__->result_source_instance->deploy_depends_on( - ["ViewDeps::Result::Year2010CDs"] ); + ["Year2010CDs"] ); __PACKAGE__->add_columns( id => { data_type => 'integer', is_auto_increment => 1 }, diff --git a/t/lib/ViewDepsBad/Result/AbNameArtists.pm b/t/lib/ViewDepsBad/Result/AbNameArtists.pm index 181d4ec..358abaa 100644 --- a/t/lib/ViewDepsBad/Result/AbNameArtists.pm +++ b/t/lib/ViewDepsBad/Result/AbNameArtists.pm @@ -11,7 +11,7 @@ __PACKAGE__->result_source_instance->view_definition( "SELECT id,name FROM a_name_artists WHERE name like 'ab%'" ); __PACKAGE__->result_source_instance->deploy_depends_on( - ["ViewDepsBad::Result::ANameArtists"] + ["ANameArtists"] ); __PACKAGE__->add_columns( diff --git a/t/lib/ViewDepsBad/Result/AbaNameArtists.pm b/t/lib/ViewDepsBad/Result/AbaNameArtists.pm index 715d56d..c1e6239 100644 --- a/t/lib/ViewDepsBad/Result/AbaNameArtists.pm +++ b/t/lib/ViewDepsBad/Result/AbaNameArtists.pm @@ -10,7 +10,7 @@ __PACKAGE__->table('aba_name_artists'); __PACKAGE__->result_source_instance->view_definition( "SELECT id,name FROM ab_name_artists WHERE name like 'aba%'" ); __PACKAGE__->result_source_instance->deploy_depends_on( - ["ViewDepsBad::Result::AbNameArtists", "ViewDepsBad::Result::AbaNameArtistsAnd2010CDsWithManyTracks"] ); + ["AbNameArtists", "AbaNameArtistsAnd2010CDsWithManyTracks"] ); __PACKAGE__->add_columns( id => { data_type => 'integer', is_auto_increment => 1 }, diff --git a/t/lib/ViewDepsBad/Result/AbaNameArtistsAnd2010CDsWithManyTracks.pm b/t/lib/ViewDepsBad/Result/AbaNameArtistsAnd2010CDsWithManyTracks.pm index 8751d57..b90669f 100644 --- a/t/lib/ViewDepsBad/Result/AbaNameArtistsAnd2010CDsWithManyTracks.pm +++ b/t/lib/ViewDepsBad/Result/AbaNameArtistsAnd2010CDsWithManyTracks.pm @@ -11,7 +11,7 @@ __PACKAGE__->result_source_instance->view_definition( "SELECT aba.id,aba.name,cd.title,cd.year,cd.number_tracks FROM aba_name_artists aba JOIN year_2010_cds_with_many_tracks cd on (aba.id = cd.artist)" ); __PACKAGE__->result_source_instance->deploy_depends_on( - ["ViewDepsBad::Result::AbNameArtists","ViewDepsBad::Result::Year2010CDsWithManyTracks"] ); + ["AbNameArtists","Year2010CDsWithManyTracks"] ); __PACKAGE__->add_columns( id => { data_type => 'integer', is_auto_increment => 1 }, diff --git a/t/lib/ViewDepsBad/Result/Year2010CDsWithManyTracks.pm b/t/lib/ViewDepsBad/Result/Year2010CDsWithManyTracks.pm index 9a4900f..349addb 100644 --- a/t/lib/ViewDepsBad/Result/Year2010CDsWithManyTracks.pm +++ b/t/lib/ViewDepsBad/Result/Year2010CDsWithManyTracks.pm @@ -12,7 +12,7 @@ __PACKAGE__->result_source_instance->view_definition( ); __PACKAGE__->result_source_instance->deploy_depends_on( - ["ViewDepsBad::Result::Year2010CDs"] ); + ["Year2010CDs"] ); __PACKAGE__->add_columns( id => { data_type => 'integer', is_auto_increment => 1 },