X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F10_05ora_common.t;h=2cb7480e135bc0b3988fecf9a5d5c4fd2f2b4980;hb=c939b4acb9a74ccfac75d58510bc241fcaf39b02;hp=566a5de6e4669830f083be7008a3c8b30aa0d370;hpb=1af21646d6a7fa3947796c3204697879efc3c618;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/t/10_05ora_common.t b/t/10_05ora_common.t index 566a5de..2cb7480 100644 --- a/t/10_05ora_common.t +++ b/t/10_05ora_common.t @@ -2,6 +2,7 @@ use strict; use warnings; use Test::More; use Test::Exception; +use DBIx::Class::Optional::Dependencies; use DBIx::Class::Schema::Loader 'make_schema_at'; use DBIx::Class::Schema::Loader::Utils qw/slurp_file split_name/; use Try::Tiny; @@ -25,7 +26,7 @@ my $auto_inc_cb = sub { my ($table, $col) = @_; return ( qq{ CREATE SEQUENCE ${table}_${col}_seq START WITH 1 INCREMENT BY 1}, - qq{ + qq{ CREATE OR REPLACE TRIGGER ${table}_${col}_trigger BEFORE INSERT ON ${table} FOR EACH ROW @@ -45,9 +46,12 @@ my $tester = dbixcsl_common_tests->new( vendor => 'Oracle', auto_inc_pk => 'INTEGER NOT NULL PRIMARY KEY', auto_inc_cb => $auto_inc_cb, - auto_inc_drop_cb => $auto_inc_drop_cb, + auto_inc_drop_cb => $auto_inc_drop_cb, preserve_case_mode_is_exclusive => 1, quote_char => '"', + default_is_deferrable => 0, + default_on_delete_clause => 'NO ACTION', + default_on_update_clause => 'NO ACTION', dsn => $dsn, user => $user, password => $password, @@ -155,7 +159,7 @@ my $tester = dbixcsl_common_tests->new( }, extra => { create => [ - q{ + q{ CREATE TABLE oracle_loader_test1 ( id NUMBER(11), value VARCHAR2(100) @@ -163,9 +167,23 @@ my $tester = dbixcsl_common_tests->new( }, q{ COMMENT ON TABLE oracle_loader_test1 IS 'oracle_loader_test1 table comment' }, q{ COMMENT ON COLUMN oracle_loader_test1.value IS 'oracle_loader_test1.value column comment' }, + # 4 through 8 are used for the multi-schema tests + q{ + create table oracle_loader_test9 ( + id int primary key + ) + }, + q{ + create table oracle_loader_test10 ( + id int primary key, + nine_id int, + foreign key (nine_id) references oracle_loader_test9(id) + on delete set null deferrable + ) + }, ], - drop => [qw/oracle_loader_test1/], - count => 3 + 30 * 2, + drop => [qw/oracle_loader_test1 oracle_loader_test9 oracle_loader_test10/], + count => 7 + 31 * 2, run => sub { my ($monikers, $classes); ($schema, $monikers, $classes) = @_; @@ -192,8 +210,21 @@ my $tester = dbixcsl_common_tests->new( like $code, qr/^=head2 value\n\n(.+:.+\n)+\noracle_loader_test1\.value column comment\n\n/m, 'column comment and attrs'; + # test on delete/update fk clause introspection + ok ((my $rel_info = $schema->source('OracleLoaderTest10')->relationship_info('nine')), + 'got rel info'); + + is $rel_info->{attrs}{on_delete}, 'SET NULL', + 'ON DELETE clause introspected correctly'; + + is $rel_info->{attrs}{on_update}, 'NO ACTION', + 'ON UPDATE clause set to NO ACTION by default'; + + is $rel_info->{attrs}{is_deferrable}, 1, + 'DEFERRABLE clause introspected correctly'; + SKIP: { - skip 'Set the DBICTEST_ORA_EXTRAUSER_DSN, _USER and _PASS environment variables to run the cross-schema relationship tests', 6 * 2 + skip 'Set the DBICTEST_ORA_EXTRAUSER_DSN, _USER and _PASS environment variables to run the cross-schema relationship tests', 31 * 2 unless $ENV{DBICTEST_ORA_EXTRAUSER_DSN}; $extra_schema = $schema->clone; @@ -214,7 +245,7 @@ my $tester = dbixcsl_common_tests->new( ) EOF - $dbh1->do($_) for $auto_inc_cb->('oracle_loader_test4', 'id'); + $dbh1->do($_) for $auto_inc_cb->(lc "${schema1}.oracle_loader_test4", 'id'); $dbh1->do("GRANT ALL ON oracle_loader_test4 TO $schema2"); $dbh1->do("GRANT ALL ON oracle_loader_test4_id_seq TO $schema2"); @@ -323,6 +354,9 @@ EOF is try { $rsrc->column_info('id')->{is_auto_increment} }, 1, 'column in schema1'; + is try { $rsrc->column_info('id')->{sequence} }, lc "${schema1}.oracle_loader_test4_id_seq", + 'sequence in schema1'; + is try { $rsrc->column_info('value')->{data_type} }, 'varchar2', 'column in schema1'; @@ -442,6 +476,9 @@ EOF if( !$dsn || !$user ) { $tester->skip_tests('You need to set the DBICTEST_ORA_DSN, _USER, and _PASS environment variables'); } +elsif (!DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_oracle')) { + $tester->skip_tests('You need to install ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_oracle')); +} else { $tester->run_tests(); }