db6eed382f72dd6b63e7a89d08d1db6cf125ce7b
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 17sybase_asa_common.t
1 use strict;
2 use warnings;
3 use lib qw(t/lib);
4 use dbixcsl_common_tests;
5
6 # The default max_cursor_count and max_statement_count settings of 50 are too
7 # low to run this test.
8 #
9 # Setting them to zero is preferred.
10
11 my $dbd_sqlanywhere_dsn      = $ENV{DBICTEST_SYBASE_ASA_DSN} || '';
12 my $dbd_sqlanywhere_user     = $ENV{DBICTEST_SYBASE_ASA_USER} || '';
13 my $dbd_sqlanywhere_password = $ENV{DBICTEST_SYBASE_ASA_PASS} || '';
14
15 my $odbc_dsn      = $ENV{DBICTEST_SYBASE_ASA_ODBC_DSN} || '';
16 my $odbc_user     = $ENV{DBICTEST_SYBASE_ASA_ODBC_USER} || '';
17 my $odbc_password = $ENV{DBICTEST_SYBASE_ASA_ODBC_PASS} || '';
18
19 my $tester = dbixcsl_common_tests->new(
20     vendor      => 'SQLAnywhere',
21     auto_inc_pk => 'INTEGER IDENTITY NOT NULL PRIMARY KEY',
22     connect_info => [ ($dbd_sqlanywhere_dsn ? {
23             dsn         => $dbd_sqlanywhere_dsn,
24             user        => $dbd_sqlanywhere_user,
25             password    => $dbd_sqlanywhere_password,
26         } : ()),
27         ($odbc_dsn ? {
28             dsn         => $odbc_dsn,
29             user        => $odbc_user,
30             password    => $odbc_password,
31         } : ()),
32     ],
33     data_types  => {
34         # http://infocenter.sybase.com/help/topic/com.sybase.help.sqlanywhere.11.0.1/dbreference_en11/rf-datatypes.html
35         #
36         # Numeric types
37         # XXX rewrite low-precision floats to 'real'
38         'bit'         => { data_type => 'bit' },
39         'tinyint'     => { data_type => 'tinyint' },
40         'smallint'    => { data_type => 'smallint' },
41         'int'         => { data_type => 'integer' },
42         'integer'     => { data_type => 'integer' },
43         'bigint'      => { data_type => 'bigint' },
44         'float'       => { data_type => 'float' },
45         'real'        => { data_type => 'float' },
46         'double'      => { data_type => 'double precision' },
47         'double precision' =>
48                          { data_type => 'double precision' },
49
50         'float(2)'    => { data_type => 'float' },
51         'float(24)'   => { data_type => 'float' },
52         'float(25)'   => { data_type => 'double precision' },
53         'float(53)'   => { data_type => 'double precision' },
54
55         # This test only works with the default precision and scale options.
56         #
57         # They are preserved even for the default values, because the defaults
58         # can be changed.
59         'decimal'     => { data_type => 'decimal', size => [30,6] },
60         'dec'         => { data_type => 'decimal', size => [30,6] },
61         'numeric'     => { data_type => 'numeric', size => [30,6] },
62
63         'decimal(3)'   => { data_type => 'decimal', size => [3,0] },
64         'dec(3)'       => { data_type => 'decimal', size => [3,0] },
65         'numeric(3)'   => { data_type => 'numeric', size => [3,0] },
66
67         'decimal(3,3)' => { data_type => 'decimal', size => [3,3] },
68         'dec(3,3)'     => { data_type => 'decimal', size => [3,3] },
69         'numeric(3,3)' => { data_type => 'numeric', size => [3,3] },
70
71         'decimal(18,18)' => { data_type => 'decimal', size => [18,18] },
72         'dec(18,18)'     => { data_type => 'decimal', size => [18,18] },
73         'numeric(18,18)' => { data_type => 'numeric', size => [18,18] },
74
75         # money types
76         'money'        => { data_type => 'money' },
77         'smallmoney'   => { data_type => 'smallmoney' },
78
79         # bit arrays
80         'long varbit'  => { data_type => 'long varbit' },
81         'long bit varying'
82                        => { data_type => 'long varbit' },
83         'varbit'       => { data_type => 'varbit', size => 1 },
84         'varbit(20)'   => { data_type => 'varbit', size => 20 },
85         'bit varying'  => { data_type => 'varbit', size => 1 },
86         'bit varying(20)'
87                        => { data_type => 'varbit', size => 20 },
88
89         # Date and Time Types
90         'date'        => { data_type => 'date' },
91         'datetime'    => { data_type => 'datetime' },
92         'smalldatetime'
93                       => { data_type => 'smalldatetime' },
94         'timestamp'   => { data_type => 'timestamp' },
95         # rewrite 'current timestamp' as 'current_timestamp'
96         'timestamp default current timestamp'
97                       => { data_type => 'timestamp', default_value => \'current_timestamp' },
98         'time'        => { data_type => 'time' },
99
100         # String Types
101         'char'         => { data_type => 'char',      size => 1  },
102         'char(11)'     => { data_type => 'char',      size => 11 },
103         'nchar'        => { data_type => 'nchar',     size => 1  },
104         'nchar(11)'    => { data_type => 'nchar',     size => 11 },
105         'varchar'      => { data_type => 'varchar',   size => 1  },
106         'varchar(20)'  => { data_type => 'varchar',   size => 20 },
107         'char varying(20)'
108                        => { data_type => 'varchar',   size => 20 },
109         'character varying(20)'
110                        => { data_type => 'varchar',   size => 20 },
111         'nvarchar(20)' => { data_type => 'nvarchar',  size => 20 },
112         'xml'          => { data_type => 'xml' },
113         'uniqueidentifierstr'
114                        => { data_type => 'uniqueidentifierstr' },
115
116         # Binary types
117         'binary'       => { data_type => 'binary', size => 1 },
118         'binary(20)'   => { data_type => 'binary', size => 20 },
119         'varbinary'    => { data_type => 'varbinary', size => 1 },
120         'varbinary(20)'=> { data_type => 'varbinary', size => 20 },
121         'uniqueidentifier'
122                        => { data_type => 'uniqueidentifier' },
123
124         # Blob types
125         'long binary'  => { data_type => 'long binary' },
126         'image'        => { data_type => 'image' },
127         'long varchar' => { data_type => 'long varchar' },
128         'text'         => { data_type => 'text' },
129         'long nvarchar'=> { data_type => 'long nvarchar' },
130         'ntext'        => { data_type => 'ntext' },
131     },
132
133 );
134
135 if (not ($dbd_sqlanywhere_dsn || $odbc_dsn)) {
136     $tester->skip_tests('You need to set the DBICTEST_SYBASE_ASA_DSN, _USER and _PASS and/or the DBICTEST_SYBASE_ASA_ODBC_DSN, _USER and _PASS environment variables');
137 }
138 else {
139     $tester->run_tests();
140 }