From: Amiri Barksdale at Home Date: Wed, 2 Jun 2010 01:57:52 +0000 (-0700) Subject: Formats and POD X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3c9baea8904d3c68732aef37cb9d4962674fa420;p=dbsrgits%2FDBIx-Class-ResultSource-MultipleTableInheritance.git Formats and POD --- diff --git a/lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm b/lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm index a5cb4cf..d492490 100644 --- a/lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm +++ b/lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm @@ -146,14 +146,14 @@ method attach_additional_sources () { # have to use source name lookups rather than result class here # because we don't actually have a result class on the raw sources $table->add_relationship('parent', $parent->raw_source_name, \%pk_join); - $self->depends_on->{$parent->source_name} = 1; + $self->deploy_depends_on->{$parent->source_name} = 1; } foreach my $add (@{$self->additional_parents||[]}) { $table->add_relationship( 'parent_'.$add->name, $add->source_name, \%pk_join ); - $self->depends_on->{$add->source_name} = 1; + $self->deploy_depends_on->{$add->source_name} = 1; } # add every column that's actually a concrete part of us diff --git a/t/01load.t b/t/01load.t index 664c2c5..81c04a8 100644 --- a/t/01load.t +++ b/t/01load.t @@ -2,6 +2,7 @@ use strict; use warnings; use lib 't/lib'; use Test::More qw(no_plan); +use Carp::Always; BEGIN { use_ok 'MTITest'; } diff --git a/t/02view_def.t b/t/02view_def.t index 1facf59..c1838ed 100644 --- a/t/02view_def.t +++ b/t/02view_def.t @@ -12,7 +12,7 @@ dies_ok { MTITest->source('Foo')->view_definition } "Can't generate view def without connected schema"; my $schema = MTITest->connect('dbi:SQLite::memory:'); - +#diag("MTITest view definition: ", $schema->resultset('Bar')->result_source->view_definition); my $dir = "t/sql"; # tempdir(CLEANUP => 0); $schema->create_ddl_dir([ 'PostgreSQL' ], 0.1, $dir); diff --git a/t/sql/MTITest-0.1-PostgreSQL.sql b/t/sql/MTITest-0.1-PostgreSQL.sql index f5c0fa5..cd2386e 100644 --- a/t/sql/MTITest-0.1-PostgreSQL.sql +++ b/t/sql/MTITest-0.1-PostgreSQL.sql @@ -1,6 +1,6 @@ -- -- Created by SQL::Translator::Producer::PostgreSQL --- Created on Sat Apr 17 08:25:41 2010 +-- Created on Tue Jun 1 18:40:12 2010 -- -- -- Table: just_a_table @@ -45,119 +45,119 @@ CREATE TABLE "_foo" ( CREATE INDEX "_foo_idx_a" on "_foo" ("a"); -- --- View: "foo" +-- View: "bar" -- -DROP VIEW "foo"; -CREATE VIEW "foo" ( "id", "a" ) AS - SELECT _foo.id, a FROM _foo; +DROP VIEW "bar"; +CREATE VIEW "bar" ( "id", "a", "words", "b" ) AS + SELECT _bar.id, b, words, a FROM _bar _bar JOIN mixin mixin ON mixin.id = _bar.id JOIN foo foo ON foo.id = _bar.id; -CREATE OR REPLACE FUNCTION foo_insert - (_a INTEGER) +CREATE OR REPLACE FUNCTION bar_insert + (_b INTEGER, _words TEXT, _a INTEGER) RETURNS VOID AS $function$ BEGIN - INSERT INTO _foo ( a) VALUES ( _a ); + INSERT INTO foo ( a) VALUES ( _a ); + INSERT INTO _bar ( b, id) VALUES ( _b, currval('_foo_id_seq') ); + INSERT INTO mixin ( id, words) VALUES ( currval('_foo_id_seq'), _words ); END; $function$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION foo_update - (_id INTEGER, _a INTEGER) +CREATE OR REPLACE FUNCTION bar_update + (_id INTEGER, _b INTEGER, _words TEXT, _a INTEGER) RETURNS VOID AS $function$ BEGIN - UPDATE _foo SET a = _a WHERE ( id = _id ); + UPDATE _bar SET b = _b WHERE ( id = _id ); + UPDATE mixin SET words = _words WHERE ( id = _id ); + UPDATE foo SET a = _a WHERE ( id = _id ); END; $function$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION foo_delete +CREATE OR REPLACE FUNCTION bar_delete (_id INTEGER) RETURNS VOID AS $function$ BEGIN - DELETE FROM _foo WHERE ( id = _id ); + DELETE FROM _bar WHERE ( id = _id ); + DELETE FROM mixin WHERE ( id = _id ); + DELETE FROM foo WHERE ( id = _id ); END; $function$ LANGUAGE plpgsql; -CREATE RULE _foo_insert_rule AS - ON INSERT TO foo +CREATE RULE _bar_insert_rule AS + ON INSERT TO bar DO INSTEAD ( - SELECT foo_insert(NEW.a) + SELECT bar_insert(NEW.b, NEW.words, NEW.a) ); -CREATE RULE _foo_update_rule AS - ON UPDATE TO foo +CREATE RULE _bar_update_rule AS + ON UPDATE TO bar DO INSTEAD ( - SELECT foo_update(OLD.id, NEW.a) + SELECT bar_update(OLD.id, NEW.b, NEW.words, NEW.a) ); -CREATE RULE _foo_delete_rule AS - ON DELETE TO foo +CREATE RULE _bar_delete_rule AS + ON DELETE TO bar DO INSTEAD ( - SELECT foo_delete(OLD.id) + SELECT bar_delete(OLD.id) ); ; -- --- View: "bar" +-- View: "foo" -- -DROP VIEW "bar"; -CREATE VIEW "bar" ( "id", "a", "words", "b" ) AS - SELECT _bar.id, b, words, a FROM _bar _bar JOIN mixin mixin ON mixin.id = _bar.id JOIN foo foo ON foo.id = _bar.id; +DROP VIEW "foo"; +CREATE VIEW "foo" ( "id", "a" ) AS + SELECT _foo.id, a FROM _foo; -CREATE OR REPLACE FUNCTION bar_insert - (_b INTEGER, _words TEXT, _a INTEGER) +CREATE OR REPLACE FUNCTION foo_insert + (_a INTEGER) RETURNS VOID AS $function$ BEGIN - INSERT INTO foo ( a) VALUES ( _a ); - INSERT INTO _bar ( b, id) VALUES ( _b, currval('_foo_id_seq') ); - INSERT INTO mixin ( id, words) VALUES ( currval('_foo_id_seq'), _words ); + INSERT INTO _foo ( a) VALUES ( _a ); END; $function$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION bar_update - (_id INTEGER, _b INTEGER, _words TEXT, _a INTEGER) +CREATE OR REPLACE FUNCTION foo_update + (_id INTEGER, _a INTEGER) RETURNS VOID AS $function$ BEGIN - UPDATE _bar SET b = _b WHERE ( id = _id ); - UPDATE mixin SET words = _words WHERE ( id = _id ); - UPDATE foo SET a = _a WHERE ( id = _id ); + UPDATE _foo SET a = _a WHERE ( id = _id ); END; $function$ LANGUAGE plpgsql; -CREATE OR REPLACE FUNCTION bar_delete +CREATE OR REPLACE FUNCTION foo_delete (_id INTEGER) RETURNS VOID AS $function$ BEGIN - DELETE FROM _bar WHERE ( id = _id ); - DELETE FROM mixin WHERE ( id = _id ); - DELETE FROM foo WHERE ( id = _id ); + DELETE FROM _foo WHERE ( id = _id ); END; $function$ LANGUAGE plpgsql; -CREATE RULE _bar_insert_rule AS - ON INSERT TO bar +CREATE RULE _foo_insert_rule AS + ON INSERT TO foo DO INSTEAD ( - SELECT bar_insert(NEW.b, NEW.words, NEW.a) + SELECT foo_insert(NEW.a) ); -CREATE RULE _bar_update_rule AS - ON UPDATE TO bar +CREATE RULE _foo_update_rule AS + ON UPDATE TO foo DO INSTEAD ( - SELECT bar_update(OLD.id, NEW.b, NEW.words, NEW.a) + SELECT foo_update(OLD.id, NEW.a) ); -CREATE RULE _bar_delete_rule AS - ON DELETE TO bar +CREATE RULE _foo_delete_rule AS + ON DELETE TO foo DO INSTEAD ( - SELECT bar_delete(OLD.id) + SELECT foo_delete(OLD.id) ); ;