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
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,
'int' => { data_type => 'integer', original => { data_type => 'number', size => [38,0] } },
'smallint' => { data_type => 'integer', original => { data_type => 'number', size => [38,0] } },
+ # very long DEFAULT throws an ORA-24345
+ "number(15) DEFAULT to_number(decode(substrb(userenv('CLIENT_INFO'),1,1),' ',null,substrb(userenv('CLIENT_INFO'),1,10)))" => {
+ data_type => 'numeric', size => [15,0], original => { data_type => 'number' },
+ default_value => \"to_number(decode(substrb(userenv('CLIENT_INFO'),1,1),' ',null,substrb(userenv('CLIENT_INFO'),1,10)))"
+ },
+
'decimal' => { data_type => 'integer', original => { data_type => 'number', size => [38,0] } },
'dec' => { data_type => 'integer', original => { data_type => 'number', size => [38,0] } },
'numeric' => { data_type => 'integer', original => { data_type => 'number', size => [38,0] } },
},
extra => {
create => [
- q{
+ q{
CREATE TABLE oracle_loader_test1 (
id NUMBER(11),
value VARCHAR2(100)
},
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 + 30 * 2,
run => sub {
my ($monikers, $classes);
($schema, $monikers, $classes) = @_;
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
unless $ENV{DBICTEST_ORA_EXTRAUSER_DSN};
my $schema2_moniker = join '', map ucfirst lc, split_name to_identifier $schema2;
my %monikers;
- $monikers{'1.4'} = $schema1_moniker . 'OracleLoaderTest4';
$monikers{'1.5'} = $schema1_moniker . 'OracleLoaderTest5';
$monikers{'2.5'} = $schema2_moniker . 'OracleLoaderTest5';
- $monikers{'2.6'} = $schema2_moniker . 'OracleLoaderTest6';
- $monikers{'2.7'} = $schema2_moniker . 'OracleLoaderTest7';
- $monikers{'1.8'} = $schema1_moniker . 'OracleLoaderTest8';
foreach my $db_schema ([$schema1, $schema2], '%') {
lives_and {
{
naming => 'current',
db_schema => $db_schema,
- moniker_parts => [qw/schema name/],
dump_directory => EXTRA_DUMP_DIR,
quiet => 1,
},
} 'connected test schema';
lives_and {
- ok $rsrc = $test_schema->source($monikers{'1.4'});
+ ok $rsrc = $test_schema->source('OracleLoaderTest4');
} 'got source for table in schema1';
is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
'column in schema1';
lives_and {
- ok $rs = $test_schema->resultset($monikers{'1.4'});
+ ok $rs = $test_schema->resultset('OracleLoaderTest4');
} 'got resultset for table in schema1';
lives_and {
'correct unique constraint in schema1');
lives_and {
- ok $rsrc = $test_schema->source($monikers{'2.6'});
+ ok $rsrc = $test_schema->source('OracleLoaderTest6');
} 'got source for table in schema2';
is try { $rsrc->column_info('id')->{is_auto_increment} }, 1,
'column in schema2 introspected correctly';
lives_and {
- ok $rs = $test_schema->resultset($monikers{'2.6'});
+ ok $rs = $test_schema->resultset('OracleLoaderTest6');
} 'got resultset for table in schema2';
lives_and {
'relationship in schema2';
lives_and {
- ok $rsrc = $test_schema->source($monikers{'2.7'});
+ ok $rsrc = $test_schema->source('OracleLoaderTest7');
} 'got source for table in schema2';
%uniqs = try { $rsrc->unique_constraints };
'correct unique constraint in schema2');
lives_and {
- ok $test_schema->source($monikers{'2.6'})
+ ok $test_schema->source('OracleLoaderTest6')
->has_relationship('oracle_loader_test4');
} 'cross-schema relationship in multi-db_schema';
lives_and {
- ok $test_schema->source($monikers{'1.4'})
+ ok $test_schema->source('OracleLoaderTest4')
->has_relationship('oracle_loader_test6s');
} 'cross-schema relationship in multi-db_schema';
lives_and {
- ok $test_schema->source($monikers{'1.8'})
+ ok $test_schema->source('OracleLoaderTest8')
->has_relationship('oracle_loader_test7');
} 'cross-schema relationship in multi-db_schema';
lives_and {
- ok $test_schema->source($monikers{'2.7'})
+ ok $test_schema->source('OracleLoaderTest7')
->has_relationship('oracle_loader_test8s');
} 'cross-schema relationship in multi-db_schema';
}