use Carp::Always;
BEGIN {
- $ENV{DBIC_TRACE} = 1;
+ #$ENV{DBIC_TRACE} = 1;
use_ok('DBIx::Class::ResultSource::View');
}
-### SANITY
+#################### SANITY
my $view = DBIx::Class::ResultSource::View->new( { name => 'Quux' } );
can_ok( $view, $_ ) for qw/new from deploy_depends_on/;
-### DEPS
+#################### DEPS
+
#if (-e "t/var/viewdeps.db") {
#ok(unlink("t/var/viewdeps.db"),"Deleted old DB OK");
#}
+
my @sql_files = glob("t/sql/ViewDeps*.sql");
for (@sql_files) {
ok( unlink($_), "Deleted old SQL $_ OK" );
my $deps_ref = {
map {
- $schema->resultset($_)->result_source->source_name =>
+ $schema->resultset($_)->result_source->name =>
$schema->resultset($_)->result_source->deploy_depends_on
}
grep {
} @{ [ $schema->sources ] }
};
-diag( Dwarn $deps_ref);
+#diag( Dwarn $deps_ref);
my @sorted_sources = sort {
keys %{ $deps_ref->{$a} || {} } <=> keys %{ $deps_ref->{$b} || {} }
}
keys %$deps_ref;
-diag( Dwarn @sorted_sources );
+#diag( Dwarn @sorted_sources );
-### DEPLOY
+#################### DEPLOY
my $ddl_dir = "t/sql";
$schema->create_ddl_dir( [ 'PostgreSQL', 'MySQL', 'SQLite' ], 0.1, $ddl_dir );
$schema->deploy( { add_drop_table => 1 } );
-### DOES ORDERING WORK?
+#################### DOES ORDERING WORK?
+
+my $tr = $schema->{sqlt};
+#diag("My TR isa: ", ref $tr);
+#diag( Dwarn keys %{$tr->{views}});
+my @keys = keys %{$tr->{views}};
+
+
+my @sqlt_sources =
+sort {
+ $tr->{views}->{$a}->{order} cmp $tr->{views}->{$b}->{order}
+}
+@keys;
-my $tr = SQL::Translator->new( add_drop_table => 1 );
-$tr->{parser_args}->{'DBIx::Class::Schema'} = $schema;
-my $sqlt = SQL::Translator::Parser::DBIx::Class::parse( $tr, $schema );
+#diag(Dwarn @sqlt_sources);
-diag( Dwarn $sqlt); # Nope. A 1.
+is_deeply(\@sorted_sources,\@sqlt_sources,"SQLT view order triumphantly matchs our order.");
done_testing;