Pg: preserve_case mode
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 14ora_common.t
CommitLineData
e7262300 1use strict;
2use lib qw(t/lib);
3use dbixcsl_common_tests;
6b0e47fc 4use Test::More;
5use Test::Exception;
e7262300 6
7my $dsn = $ENV{DBICTEST_ORA_DSN} || '';
8my $user = $ENV{DBICTEST_ORA_USER} || '';
9my $password = $ENV{DBICTEST_ORA_PASS} || '';
10
11my $tester = dbixcsl_common_tests->new(
12 vendor => 'Oracle',
c1ac681d 13 auto_inc_pk => 'INTEGER NOT NULL PRIMARY KEY',
14 auto_inc_cb => sub {
15 my ($table, $col) = @_;
16 return (
17 qq{ CREATE SEQUENCE ${table}_${col}_seq START WITH 1 INCREMENT BY 1},
18 qq{
19 CREATE OR REPLACE TRIGGER ${table}_${col}_trigger
20 BEFORE INSERT ON ${table}
21 FOR EACH ROW
22 BEGIN
23 SELECT ${table}_${col}_seq.nextval INTO :NEW.${col} FROM dual;
24 END;
25 }
26 );
27 },
28 auto_inc_drop_cb => sub {
29 my ($table, $col) = @_;
30 return qq{ DROP SEQUENCE ${table}_${col}_seq };
31 },
c930f78b 32 quote_char => '"',
e7262300 33 dsn => $dsn,
34 user => $user,
35 password => $password,
760fd65c 36 data_types => {
37 # From:
38 # http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements001.htm#i54330
39 #
40 # These tests require at least Oracle 9.2, because of the VARCHAR to
41 # VARCHAR2 casting.
42 #
43 # Character Types
44 'char' => { data_type => 'char', size => 1 },
45 'char(11)' => { data_type => 'char', size => 11 },
46 'nchar' => { data_type => 'nchar', size => 1 },
47 'nchar(11)' => { data_type => 'nchar', size => 11 },
48 'varchar(20)' => { data_type => 'varchar2', size => 20 },
49 'varchar2(20)' => { data_type => 'varchar2', size => 20 },
50 'nvarchar2(20)'=> { data_type => 'nvarchar2', size => 20 },
51
52 # Numeric Types
53 #
1c22571b 54 # integer/decimal/numeric is alised to NUMBER
760fd65c 55 #
4ea15dfe 56 'integer' => { data_type => 'integer', original => { data_type => 'number', size => [38,0] } },
57 'int' => { data_type => 'integer', original => { data_type => 'number', size => [38,0] } },
58 'smallint' => { data_type => 'integer', original => { data_type => 'number', size => [38,0] } },
760fd65c 59
4ea15dfe 60 'decimal' => { data_type => 'integer', original => { data_type => 'number', size => [38,0] } },
61 'dec' => { data_type => 'integer', original => { data_type => 'number', size => [38,0] } },
62 'numeric' => { data_type => 'integer', original => { data_type => 'number', size => [38,0] } },
760fd65c 63
4ea15dfe 64 'decimal(3)' => { data_type => 'numeric', size => [3,0], original => { data_type => 'number' } },
65 'dec(3)' => { data_type => 'numeric', size => [3,0], original => { data_type => 'number' } },
66 'numeric(3)' => { data_type => 'numeric', size => [3,0], original => { data_type => 'number' } },
760fd65c 67
4ea15dfe 68 'decimal(3,3)' => { data_type => 'numeric', size => [3,3], original => { data_type => 'number' } },
69 'dec(3,3)' => { data_type => 'numeric', size => [3,3], original => { data_type => 'number' } },
70 'numeric(3,3)' => { data_type => 'numeric', size => [3,3], original => { data_type => 'number' } },
760fd65c 71
1c22571b 72 'binary_float' => { data_type => 'real', original => { data_type => 'binary_float' } },
73 'binary_double' => { data_type => 'double precision', original => { data_type => 'binary_double' } },
74
75 # these are not mentioned in the summary chart, must be aliased
76 real => { data_type => 'real', original => { data_type => 'float', size => 63 } },
77 'float(63)' => { data_type => 'real', original => { data_type => 'float', size => 63 } },
78 'float(64)' => { data_type => 'double precision', original => { data_type => 'float', size => 64 } },
79 'float(126)' => { data_type => 'double precision', original => { data_type => 'float', size => 126 } },
80 float => { data_type => 'double precision', original => { data_type => 'float', size => 126 } },
760fd65c 81
82 # Blob Types
83 'raw(50)' => { data_type => 'raw', size => 50 },
84 'clob' => { data_type => 'clob' },
85 'nclob' => { data_type => 'nclob' },
86 'blob' => { data_type => 'blob' },
87 'bfile' => { data_type => 'bfile' },
3b29d0ac 88 'long' => { data_type => 'long' },
760fd65c 89 'long raw' => { data_type => 'long raw' },
90
91 # Datetime Types
3785bc2e 92 'date' => { data_type => 'datetime', original => { data_type => 'date' } },
760fd65c 93 'date default sysdate'
3785bc2e 94 => { data_type => 'datetime', default_value => \'current_timestamp',
95 original => { data_type => 'date', default_value => \'sysdate' } },
760fd65c 96 'timestamp' => { data_type => 'timestamp' },
97 'timestamp default current_timestamp'
98 => { data_type => 'timestamp', default_value => \'current_timestamp' },
99 'timestamp(3)' => { data_type => 'timestamp', size => 3 },
100 'timestamp with time zone'
101 => { data_type => 'timestamp with time zone' },
102 'timestamp(3) with time zone'
103 => { data_type => 'timestamp with time zone', size => 3 },
104 'timestamp with local time zone'
105 => { data_type => 'timestamp with local time zone' },
106 'timestamp(3) with local time zone'
107 => { data_type => 'timestamp with local time zone', size => 3 },
108 'interval year to month'
109 => { data_type => 'interval year to month' },
110 'interval year(3) to month'
111 => { data_type => 'interval year to month', size => 3 },
112 'interval day to second'
113 => { data_type => 'interval day to second' },
114 'interval day(3) to second'
115 => { data_type => 'interval day to second', size => [3,6] },
116 'interval day to second(3)'
117 => { data_type => 'interval day to second', size => [2,3] },
118 'interval day(3) to second(3)'
119 => { data_type => 'interval day to second', size => [3,3] },
120
121 # Other Types
122 'rowid' => { data_type => 'rowid' },
123 'urowid' => { data_type => 'urowid' },
124 'urowid(3333)' => { data_type => 'urowid', size => 3333 },
125 },
e7262300 126);
127
128if( !$dsn || !$user ) {
129 $tester->skip_tests('You need to set the DBICTEST_ORA_DSN, _USER, and _PASS environment variables');
130}
131else {
132 $tester->run_tests();
133}
760fd65c 134# vim:et sw=4 sts=4 tw=0: