Use fully-qualified result class names instead of source names in deploy_depends_on.
Amiri Barksdale at Home [Tue, 15 Jun 2010 02:16:57 +0000 (19:16 -0700)]
lib/DBIx/Class/ResultSource/View.pm
lib/SQL/Translator/Parser/DBIx/Class.pm
t/lib/ViewDeps/Result/AbNameArtists.pm
t/lib/ViewDeps/Result/AbaNameArtists.pm
t/lib/ViewDeps/Result/AbaNameArtistsAnd2010CDsWithManyTracks.pm
t/lib/ViewDeps/Result/Year2010CDsWithManyTracks.pm
t/lib/ViewDepsBad/Result/AbNameArtists.pm
t/lib/ViewDepsBad/Result/AbaNameArtists.pm
t/lib/ViewDepsBad/Result/AbaNameArtistsAnd2010CDsWithManyTracks.pm
t/lib/ViewDepsBad/Result/Year2010CDsWithManyTracks.pm

index 5bb5e5d..4410563 100644 (file)
@@ -132,11 +132,11 @@ syntaxes.
 =head2 deploy_depends_on 
 
   __PACKAGE__->result_source_instance->deploy_depends_on(
-      ["Year","CD"]
+      ["MyDB::Schema::Result::Year","MyDB::Schema::Result::CD"]
       );
 
 Specify the views (and only the views) that this view depends on.
-Pass this an array reference of source names.
+Pass this an array reference of fully qualified result classes.
 
 =head1 OVERRIDDEN METHODS
 
index cbeaf86..b2ba72c 100644 (file)
@@ -393,13 +393,13 @@ sub _resolve_view_deps {
 
     # copy and bump all deps by one (so we can reconstruct the chain)
     my %seen = map { $_ => $seen->{$_} + 1 } ( keys %$seen );
-    $seen{ $view->source_name } = 1;
+    $seen{ $view->result_class } = 1;
     for my $dep ( keys %{ $view->{deploy_depends_on} } ) {
         if ( $seen->{$dep} ) {
             return {};
         }
         my ($new_source_name) =
-          grep { $view->schema->source($_)->source_name eq $dep }
+          grep { $view->schema->source($_)->result_class eq $dep }
           @{ [ $view->schema->sources ] };
         my $subdeps =
           _resolve_view_deps( $view->schema->source($new_source_name),
index fab3a7c..3651a5b 100644 (file)
@@ -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(
-    ["ANameArtists"]
+    ["ViewDeps::Result::ANameArtists"]
 );
 
 __PACKAGE__->add_columns(
index d0a1f04..fc989f6 100644 (file)
@@ -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(
-    ["AbNameArtists"] );
+    ["ViewDeps::Result::AbNameArtists"] );
 
 __PACKAGE__->add_columns(
     id   => { data_type => 'integer', is_auto_increment => 1 },
index 4395923..83c651b 100644 (file)
@@ -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(
-    ["AbNameArtists","Year2010CDsWithManyTracks"] );
+    ["ViewDeps::Result::AbNameArtists","ViewDeps::Result::Year2010CDsWithManyTracks"] );
 
 __PACKAGE__->add_columns(
     id            => { data_type => 'integer', is_auto_increment => 1 },
index c7ccfcb..c6e4144 100644 (file)
@@ -12,7 +12,7 @@ __PACKAGE__->result_source_instance->view_definition(
 );
 
 __PACKAGE__->result_source_instance->deploy_depends_on(
-    ["Year2010CDs"] );
+    ["ViewDeps::Result::Year2010CDs"] );
 
 __PACKAGE__->add_columns(
     id            => { data_type => 'integer', is_auto_increment => 1 },
index 358abaa..181d4ec 100644 (file)
@@ -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(
-    ["ANameArtists"]
+    ["ViewDepsBad::Result::ANameArtists"]
 );
 
 __PACKAGE__->add_columns(
index c1e6239..715d56d 100644 (file)
@@ -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(
-    ["AbNameArtists", "AbaNameArtistsAnd2010CDsWithManyTracks"] );
+    ["ViewDepsBad::Result::AbNameArtists", "ViewDepsBad::Result::AbaNameArtistsAnd2010CDsWithManyTracks"] );
 
 __PACKAGE__->add_columns(
     id   => { data_type => 'integer', is_auto_increment => 1 },
index b90669f..8751d57 100644 (file)
@@ -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(
-    ["AbNameArtists","Year2010CDsWithManyTracks"] );
+    ["ViewDepsBad::Result::AbNameArtists","ViewDepsBad::Result::Year2010CDsWithManyTracks"] );
 
 __PACKAGE__->add_columns(
     id            => { data_type => 'integer', is_auto_increment => 1 },
index 349addb..9a4900f 100644 (file)
@@ -12,7 +12,7 @@ __PACKAGE__->result_source_instance->view_definition(
 );
 
 __PACKAGE__->result_source_instance->deploy_depends_on(
-    ["Year2010CDs"] );
+    ["ViewDepsBad::Result::Year2010CDs"] );
 
 __PACKAGE__->add_columns(
     id            => { data_type => 'integer', is_auto_increment => 1 },