rewrite "CURRENT_TIMESTAMP" to "current_timestamp" for SQLite
[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 },
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 #
53 # everything is alised to NUMBER
54 #
55 'decimal' => { data_type => 'integer' },
56 'dec' => { data_type => 'integer' },
57 'numeric' => { data_type => 'integer' },
58
59 'decimal(3)' => { data_type => 'numeric', size => [3,0] },
60 'dec(3)' => { data_type => 'numeric', size => [3,0] },
61 'numeric(3)' => { data_type => 'numeric', size => [3,0] },
62
63 'decimal(3,3)' => { data_type => 'numeric', size => [3,3] },
64 'dec(3,3)' => { data_type => 'numeric', size => [3,3] },
65 'numeric(3,3)' => { data_type => 'numeric', size => [3,3] },
66
67 'integer' => { data_type => 'integer' },
68 'int' => { data_type => 'integer' },
69 'smallint' => { data_type => 'integer' },
70
71 'binary_float' => { data_type => 'binary_float' },
72 'binary_double' => { data_type => 'binary_double' },
73
74 # Blob Types
75 'raw(50)' => { data_type => 'raw', size => 50 },
76 'clob' => { data_type => 'clob' },
77 'nclob' => { data_type => 'nclob' },
78 'blob' => { data_type => 'blob' },
79 'bfile' => { data_type => 'bfile' },
80 # these must be tested one at a time, can't have 2 longs in one table
81 # XXX add overrides to type tester to handle this
82# 'long' => { data_type => 'long' },
83 'long raw' => { data_type => 'long raw' },
84
85 # Datetime Types
3785bc2e 86 'date' => { data_type => 'datetime', original => { data_type => 'date' } },
760fd65c 87 'date default sysdate'
3785bc2e 88 => { data_type => 'datetime', default_value => \'current_timestamp',
89 original => { data_type => 'date', default_value => \'sysdate' } },
760fd65c 90 'timestamp' => { data_type => 'timestamp' },
91 'timestamp default current_timestamp'
92 => { data_type => 'timestamp', default_value => \'current_timestamp' },
93 'timestamp(3)' => { data_type => 'timestamp', size => 3 },
94 'timestamp with time zone'
95 => { data_type => 'timestamp with time zone' },
96 'timestamp(3) with time zone'
97 => { data_type => 'timestamp with time zone', size => 3 },
98 'timestamp with local time zone'
99 => { data_type => 'timestamp with local time zone' },
100 'timestamp(3) with local time zone'
101 => { data_type => 'timestamp with local time zone', size => 3 },
102 'interval year to month'
103 => { data_type => 'interval year to month' },
104 'interval year(3) to month'
105 => { data_type => 'interval year to month', size => 3 },
106 'interval day to second'
107 => { data_type => 'interval day to second' },
108 'interval day(3) to second'
109 => { data_type => 'interval day to second', size => [3,6] },
110 'interval day to second(3)'
111 => { data_type => 'interval day to second', size => [2,3] },
112 'interval day(3) to second(3)'
113 => { data_type => 'interval day to second', size => [3,3] },
114
115 # Other Types
116 'rowid' => { data_type => 'rowid' },
117 'urowid' => { data_type => 'urowid' },
118 'urowid(3333)' => { data_type => 'urowid', size => 3333 },
119 },
e7262300 120);
121
122if( !$dsn || !$user ) {
123 $tester->skip_tests('You need to set the DBICTEST_ORA_DSN, _USER, and _PASS environment variables');
124}
125else {
126 $tester->run_tests();
127}
760fd65c 128# vim:et sw=4 sts=4 tw=0: