#(exists $b->deploy_depends_on->{$a->source_name} ? 1 : 0)
#}
#map { $dbicschema->source($_) } (sort keys %view_monikers);
-
- #my @view_sources =
- #grep { $_->can('view_definition') } # make sure it's a view
- #map { $dbicschema->source($_) } # have to get a source
- #map { $tables{$_}{source}{source_name} } # have to get a sourcename
- #sort {
- #keys %{ $dependencies->{$a} || {} }
- #<=>
- #keys %{ $dependencies->{$b} || {} }
- #||
- #$a cmp $b
- #}
- #keys %$dependencies;
my @view_sources =
sort {
$a cmp $b
}
map { $dbicschema->source($_) } (sort keys %view_monikers);
-
- print STDERR Dumper @view_sources;
+
+
+ print STDERR "View monikers: ", Dumper %view_monikers;
+ print STDERR "Source name of view source: ", $_->source_name, "\n" for @view_sources;
print STDERR Dumper "Dependencies: ", $dependencies;
foreach my $source (@view_sources)
my $view = DBIx::Class::ResultSource::View->new( { name => 'Quux' } );
-isa_ok( $view, 'DBIx::Class::ResultSource', 'A new view');
-isa_ok( $view, 'DBIx::Class', 'A new view also');
+isa_ok( $view, 'DBIx::Class::ResultSource', 'A new view' );
+isa_ok( $view, 'DBIx::Class', 'A new view also' );
can_ok( $view, $_ ) for qw/new from deploy_depends_on/;
my $schema = ViewDeps->connect;
ok( $schema, 'Connected to ViewDeps schema OK' );
my $bar_rs = $schema->resultset('Bar');
+
#diag(DwarnS $bar_rs->result_source);
-my @bar_deps = keys %{ $schema->resultset('Bar')->result_source->deploy_depends_on };
+my @bar_deps
+ = keys %{ $schema->resultset('Bar')->result_source->deploy_depends_on };
-my @foo_deps = keys %{ $schema->resultset('Foo')->result_source->deploy_depends_on };
+my @foo_deps
+ = keys %{ $schema->resultset('Foo')->result_source->deploy_depends_on };
isa_ok( $schema->resultset('Bar')->result_source,
'DBIx::Class::ResultSource::View', 'Bar' );
-is( $bar_deps[0], 'baz', 'which is reported to depend on baz...' );
+is( $bar_deps[0], 'baz', 'which is reported to depend on baz...' );
is( $bar_deps[1], 'mixin', 'and on mixin.' );
is( $foo_deps[0], undef, 'Foo has no dependencies...' );
"Baz on the other hand"
);
dies_ok {
- ViewDeps::Result::Baz->result_source_instance->deploy_depends_on(
- { ViewDeps::Result::Mixin->result_source_instance->name => 1 } );
+ ViewDeps::Result::Baz->result_source_instance
+ ->deploy_depends_on("ViewDeps::Result::Mixin");
}
"...and you cannot use deploy_depends_on with that";
-diag("ViewDeps::Foo view definition: ", ViewDeps->source('Foo')->view_definition);
-diag("schema->rs(Bar) view definition: ", $schema->resultset('Bar')->result_source->view_definition);
+diag(
+ "ViewDeps::Foo view definition: ",
+ ViewDeps->source('Foo')->view_definition
+);
+diag( "schema->rs(Bar) view definition: ",
+ $schema->resultset('Bar')->result_source->view_definition );
-my $dir = "t/sql"; # tempdir(CLEANUP => 0);
-$schema->create_ddl_dir([ 'PostgreSQL' ], 0.1, $dir);
+my $dir = "t/sql"; # tempdir(CLEANUP => 0);
+$schema->create_ddl_dir( ['PostgreSQL','SQLite'], 0.1, $dir );
done_testing;
--- /dev/null
+--
+-- Created by SQL::Translator::Producer::PostgreSQL
+-- Created on Fri May 28 08:01:56 2010
+--
+--
+-- Table: just_a_table
+--
+DROP TABLE "just_a_table" CASCADE;
+CREATE TABLE "just_a_table" (
+ "id" serial NOT NULL,
+ "name" character varying(255) NOT NULL,
+ PRIMARY KEY ("id")
+);
+
+--
+-- Table: mixin
+--
+DROP TABLE "mixin" CASCADE;
+CREATE TABLE "mixin" (
+ "id" serial NOT NULL,
+ "words" text NOT NULL,
+ PRIMARY KEY ("id")
+);
+
+--
+-- Table: baz
+--
+DROP TABLE "baz" CASCADE;
+CREATE TABLE "baz" (
+ "id" integer NOT NULL
+);
+CREATE INDEX "baz_idx_b" on "baz" ("b");
+
+--
+-- View: "bar"
+--
+DROP VIEW "bar";
+CREATE VIEW "bar" ( "id", "a", "b" ) AS
+ select * from just_a_table
+;
+
+--
+-- View: "foo"
+--
+DROP VIEW "foo";
+CREATE VIEW "foo" ( "id", "a" ) AS
+ select * from just_a_table
+;
+
+--
+-- Foreign Key Definitions
+--
+
+ALTER TABLE "baz" ADD FOREIGN KEY ("b")
+ REFERENCES "just_a_table" ("id") DEFERRABLE;
+