3 use dbixcsl_common_tests;
7 my $dsn = $ENV{DBICTEST_ORA_DSN} || '';
8 my $user = $ENV{DBICTEST_ORA_USER} || '';
9 my $password = $ENV{DBICTEST_ORA_PASS} || '';
11 my $tester = dbixcsl_common_tests->new(
13 auto_inc_pk => 'INTEGER NOT NULL PRIMARY KEY',
15 my ($table, $col) = @_;
17 qq{ CREATE SEQUENCE ${table}_${col}_seq START WITH 1 INCREMENT BY 1},
19 CREATE OR REPLACE TRIGGER ${table}_${col}_trigger
20 BEFORE INSERT ON ${table}
23 SELECT ${table}_${col}_seq.nextval INTO :NEW.${col} FROM dual;
28 auto_inc_drop_cb => sub {
29 my ($table, $col) = @_;
30 return qq{ DROP SEQUENCE ${table}_${col}_seq };
34 password => $password,
38 CREATE TABLE oracle_loader_test1 (
39 id INTEGER PRIMARY KEY,
40 a_varchar VARCHAR2(100) DEFAULT 'foo',
41 an_int INTEGER DEFAULT 42,
42 a_double DOUBLE PRECISION DEFAULT 10.555,
43 a_date DATE DEFAULT sysdate
47 drop => [ qw/ oracle_loader_test1 / ],
50 my ($schema, $monikers, $classes) = @_;
52 my $rsrc = $schema->resultset($monikers->{oracle_loader_test1})
55 is $rsrc->column_info('a_varchar')->{default_value},
57 'constant character default';
59 is $rsrc->column_info('an_int')->{default_value},
61 'constant integer default';
63 is $rsrc->column_info('a_double')->{default_value},
65 'constant numeric default';
67 my $function_default =
68 $rsrc->column_info('a_date')->{default_value};
70 ok ((ref $function_default eq 'SCALAR'),
71 'default_value for function default is a scalar ref')
72 or diag "default_value is: ", $function_default
75 eval { is $$function_default,
77 'default_value for function default is correct' };
82 if( !$dsn || !$user ) {
83 $tester->skip_tests('You need to set the DBICTEST_ORA_DSN, _USER, and _PASS environment variables');