use warnings;
use DBIx::Class::ResultSet;
+use Devel::Dwarn;
use base qw/DBIx::Class/;
__PACKAGE__->load_components(qw/ResultSource/);
=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
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;
}
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),
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');
}
#################### 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?
"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(
__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 },
"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 },
);
__PACKAGE__->result_source_instance->deploy_depends_on(
- ["ViewDeps::Result::Year2010CDs"] );
+ ["Year2010CDs"] );
__PACKAGE__->add_columns(
id => { data_type => 'integer', is_auto_increment => 1 },
"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(
__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 },
"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 },
);
__PACKAGE__->result_source_instance->deploy_depends_on(
- ["ViewDepsBad::Result::Year2010CDs"] );
+ ["Year2010CDs"] );
__PACKAGE__->add_columns(
id => { data_type => 'integer', is_auto_increment => 1 },