Commit | Line | Data |
e7262300 |
1 | use strict; |
2 | use lib qw(t/lib); |
3 | use dbixcsl_common_tests; |
6b0e47fc |
4 | use Test::More; |
5 | use Test::Exception; |
e7262300 |
6 | |
7 | my $dsn = $ENV{DBICTEST_ORA_DSN} || ''; |
8 | my $user = $ENV{DBICTEST_ORA_USER} || ''; |
9 | my $password = $ENV{DBICTEST_ORA_PASS} || ''; |
10 | |
11 | my $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 | }, |
e7262300 |
32 | dsn => $dsn, |
33 | user => $user, |
34 | password => $password, |
760fd65c |
35 | data_types => { |
36 | # From: |
37 | # http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements001.htm#i54330 |
38 | # |
39 | # These tests require at least Oracle 9.2, because of the VARCHAR to |
40 | # VARCHAR2 casting. |
41 | # |
42 | # Character Types |
43 | 'char' => { data_type => 'char', size => 1 }, |
44 | 'char(11)' => { data_type => 'char', size => 11 }, |
45 | 'nchar' => { data_type => 'nchar', size => 1 }, |
46 | 'nchar(11)' => { data_type => 'nchar', size => 11 }, |
47 | 'varchar(20)' => { data_type => 'varchar2', size => 20 }, |
48 | 'varchar2(20)' => { data_type => 'varchar2', size => 20 }, |
49 | 'nvarchar2(20)'=> { data_type => 'nvarchar2', size => 20 }, |
50 | |
51 | # Numeric Types |
52 | # |
1c22571b |
53 | # integer/decimal/numeric is alised to NUMBER |
760fd65c |
54 | # |
4ea15dfe |
55 | 'integer' => { data_type => 'integer', original => { data_type => 'number', size => [38,0] } }, |
56 | 'int' => { data_type => 'integer', original => { data_type => 'number', size => [38,0] } }, |
57 | 'smallint' => { data_type => 'integer', original => { data_type => 'number', size => [38,0] } }, |
760fd65c |
58 | |
4ea15dfe |
59 | 'decimal' => { data_type => 'integer', original => { data_type => 'number', size => [38,0] } }, |
60 | 'dec' => { data_type => 'integer', original => { data_type => 'number', size => [38,0] } }, |
61 | 'numeric' => { data_type => 'integer', original => { data_type => 'number', size => [38,0] } }, |
760fd65c |
62 | |
4ea15dfe |
63 | 'decimal(3)' => { data_type => 'numeric', size => [3,0], original => { data_type => 'number' } }, |
64 | 'dec(3)' => { data_type => 'numeric', size => [3,0], original => { data_type => 'number' } }, |
65 | 'numeric(3)' => { data_type => 'numeric', size => [3,0], original => { data_type => 'number' } }, |
760fd65c |
66 | |
4ea15dfe |
67 | 'decimal(3,3)' => { data_type => 'numeric', size => [3,3], original => { data_type => 'number' } }, |
68 | 'dec(3,3)' => { data_type => 'numeric', size => [3,3], original => { data_type => 'number' } }, |
69 | 'numeric(3,3)' => { data_type => 'numeric', size => [3,3], original => { data_type => 'number' } }, |
760fd65c |
70 | |
1c22571b |
71 | 'binary_float' => { data_type => 'real', original => { data_type => 'binary_float' } }, |
72 | 'binary_double' => { data_type => 'double precision', original => { data_type => 'binary_double' } }, |
73 | |
74 | # these are not mentioned in the summary chart, must be aliased |
75 | real => { data_type => 'real', original => { data_type => 'float', size => 63 } }, |
76 | 'float(63)' => { data_type => 'real', original => { data_type => 'float', size => 63 } }, |
77 | 'float(64)' => { data_type => 'double precision', original => { data_type => 'float', size => 64 } }, |
78 | 'float(126)' => { data_type => 'double precision', original => { data_type => 'float', size => 126 } }, |
79 | float => { data_type => 'double precision', original => { data_type => 'float', size => 126 } }, |
760fd65c |
80 | |
81 | # Blob Types |
82 | 'raw(50)' => { data_type => 'raw', size => 50 }, |
83 | 'clob' => { data_type => 'clob' }, |
84 | 'nclob' => { data_type => 'nclob' }, |
85 | 'blob' => { data_type => 'blob' }, |
86 | 'bfile' => { data_type => 'bfile' }, |
3b29d0ac |
87 | 'long' => { data_type => 'long' }, |
760fd65c |
88 | 'long raw' => { data_type => 'long raw' }, |
89 | |
90 | # Datetime Types |
3785bc2e |
91 | 'date' => { data_type => 'datetime', original => { data_type => 'date' } }, |
760fd65c |
92 | 'date default sysdate' |
3785bc2e |
93 | => { data_type => 'datetime', default_value => \'current_timestamp', |
94 | original => { data_type => 'date', default_value => \'sysdate' } }, |
760fd65c |
95 | 'timestamp' => { data_type => 'timestamp' }, |
96 | 'timestamp default current_timestamp' |
97 | => { data_type => 'timestamp', default_value => \'current_timestamp' }, |
98 | 'timestamp(3)' => { data_type => 'timestamp', size => 3 }, |
99 | 'timestamp with time zone' |
100 | => { data_type => 'timestamp with time zone' }, |
101 | 'timestamp(3) with time zone' |
102 | => { data_type => 'timestamp with time zone', size => 3 }, |
103 | 'timestamp with local time zone' |
104 | => { data_type => 'timestamp with local time zone' }, |
105 | 'timestamp(3) with local time zone' |
106 | => { data_type => 'timestamp with local time zone', size => 3 }, |
107 | 'interval year to month' |
108 | => { data_type => 'interval year to month' }, |
109 | 'interval year(3) to month' |
110 | => { data_type => 'interval year to month', size => 3 }, |
111 | 'interval day to second' |
112 | => { data_type => 'interval day to second' }, |
113 | 'interval day(3) to second' |
114 | => { data_type => 'interval day to second', size => [3,6] }, |
115 | 'interval day to second(3)' |
116 | => { data_type => 'interval day to second', size => [2,3] }, |
117 | 'interval day(3) to second(3)' |
118 | => { data_type => 'interval day to second', size => [3,3] }, |
119 | |
120 | # Other Types |
121 | 'rowid' => { data_type => 'rowid' }, |
122 | 'urowid' => { data_type => 'urowid' }, |
123 | 'urowid(3333)' => { data_type => 'urowid', size => 3333 }, |
124 | }, |
e7262300 |
125 | ); |
126 | |
127 | if( !$dsn || !$user ) { |
128 | $tester->skip_tests('You need to set the DBICTEST_ORA_DSN, _USER, and _PASS environment variables'); |
129 | } |
130 | else { |
131 | $tester->run_tests(); |
132 | } |
760fd65c |
133 | # vim:et sw=4 sts=4 tw=0: |