support for DBD::Firebird
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 10_11msaccess_common.t
1 use strict;
2 use warnings;
3 use Test::More;
4 use lib qw(t/lib);
5 use dbixcsl_common_tests;
6
7 my $odbc_dsn      = $ENV{DBICTEST_MSACCESS_ODBC_DSN} || '';
8 my $odbc_user     = $ENV{DBICTEST_MSACCESS_ODBC_USER} || '';
9 my $odbc_password = $ENV{DBICTEST_MSACCESS_ODBC_PASS} || '';
10
11 my $ado_dsn       = $ENV{DBICTEST_MSACCESS_ADO_DSN} || '';
12 my $ado_user      = $ENV{DBICTEST_MSACCESS_ADO_USER} || '';
13 my $ado_password  = $ENV{DBICTEST_MSACCESS_ADO_PASS} || '';
14
15 my %ado_extra_types = (
16     'tinyint'     => { data_type => 'tinyint', original => { data_type => 'byte' } },
17     'smallmoney'  => { data_type => 'money', original => { data_type => 'currency' } },
18     'decimal'     => { data_type => 'decimal' },
19     'decimal(3)'  => { data_type => 'decimal', size => [3, 0] },
20     'decimal(3,3)'=> { data_type => 'decimal', size => [3, 3] },
21     'dec(5,5)'    => { data_type => 'decimal', size => [5, 5] },
22     'numeric(2,2)'=> { data_type => 'decimal', size => [2, 2] },
23     'character'   => { data_type => 'char', size => 255 },
24     'character varying(5)'  => { data_type => 'varchar', size => 5 },
25     'nchar(5)'    => { data_type => 'char', size => 5 },
26     'national character(5)' => { data_type => 'char', size => 5 },
27     'nvarchar(5)' => { data_type => 'varchar', size => 5 },
28     'national character varying(5)' => { data_type => 'varchar', size => 5 },
29     'national char varying(5)' => { data_type => 'varchar', size => 5 },
30     'smalldatetime' => { data_type => 'datetime' },
31     'uniqueidentifier' => { data_type => 'uniqueidentifier', original => { data_type => 'guid' } },
32     'text'        => { data_type => 'text', original => { data_type => 'longchar' } },
33     'ntext'       => { data_type => 'text', original => { data_type => 'longchar' } },
34 );
35
36 my $tester = dbixcsl_common_tests->new(
37     vendor      => 'Access',
38     auto_inc_pk => 'AUTOINCREMENT PRIMARY KEY',
39     quote_char  => [qw/[ ]/],
40     connect_info => [ ($odbc_dsn ? {
41             dsn         => $odbc_dsn,
42             user        => $odbc_user,
43             password    => $odbc_password,
44         } : ()),
45         ($ado_dsn ? {
46             dsn         => $ado_dsn,
47             user        => $ado_user,
48             password    => $ado_password,
49         } : ()),
50     ],
51     data_types  => {
52         # http://msdn.microsoft.com/en-us/library/bb208866(v=office.12).aspx
53         #
54         # Numeric types
55         'autoincrement'=>{ data_type => 'integer', is_auto_increment => 1 },
56         'int'         => { data_type => 'integer' },
57         'integer'     => { data_type => 'integer' },
58         'long'        => { data_type => 'integer' },
59         'integer4'    => { data_type => 'integer' },
60         'smallint'    => { data_type => 'smallint' },
61         'short'       => { data_type => 'smallint' },
62         'integer2'    => { data_type => 'smallint' },
63         'integer1'    => { data_type => 'tinyint', original => { data_type => 'byte' } },
64         'byte'        => { data_type => 'tinyint', original => { data_type => 'byte' } },
65         'bit'         => { data_type => 'bit' },
66         'logical'     => { data_type => 'bit' },
67         'logical1'    => { data_type => 'bit' },
68         'yesno'       => { data_type => 'bit' },
69         'money'       => { data_type => 'money', original => { data_type => 'currency' } },
70         'currency'    => { data_type => 'money', original => { data_type => 'currency' } },
71         'real'        => { data_type => 'real' },
72         'single'      => { data_type => 'real' },
73         'ieeesingle'  => { data_type => 'real' },
74         'float4'      => { data_type => 'real' },
75         'float'       => { data_type => 'double precision', original => { data_type => 'double' } },
76         'float'       => { data_type => 'double precision', original => { data_type => 'double' } },
77         'float8'      => { data_type => 'double precision', original => { data_type => 'double' } },
78         'double'      => { data_type => 'double precision', original => { data_type => 'double' } },
79         'ieeedouble'  => { data_type => 'double precision', original => { data_type => 'double' } },
80         'number'      => { data_type => 'double precision', original => { data_type => 'double' } },
81
82 #        # character types
83         'text(25)'    => { data_type => 'varchar', size => 25 },
84         'char'        => { data_type => 'char', size => 255 },
85         'char(5)'     => { data_type => 'char', size => 5 },
86         'string(5)'   => { data_type => 'varchar', size => 5 },
87         'varchar(5)'  => { data_type => 'varchar', size => 5 },
88
89         # binary types
90         'binary(10)'  => { data_type => 'binary', size => 10 },
91         'varbinary(11)' => { data_type => 'varbinary', size => 11 },
92
93         # datetime types
94         'datetime'    => { data_type => 'datetime' },
95         'time'        => { data_type => 'datetime' },
96         'timestamp'   => { data_type => 'datetime' },
97
98         # misc types
99         'guid'        => { data_type => 'uniqueidentifier', original => { data_type => 'guid' } },
100
101         # blob types
102         'longchar'    => { data_type => 'text', original => { data_type => 'longchar' } },
103         'longtext'    => { data_type => 'text', original => { data_type => 'longchar' } },
104         'memo'        => { data_type => 'text', original => { data_type => 'longchar' } },
105         'image'       => { data_type => 'image', original => { data_type => 'longbinary' } },
106         'longbinary'  => { data_type => 'image', original => { data_type => 'longbinary' } },
107
108         ($ado_dsn && (not $odbc_dsn) ? %ado_extra_types : ())
109     },
110 );
111
112 if (not ($odbc_dsn || $ado_dsn)) {
113     $tester->skip_tests('You need to set the DBICTEST_MSACCESS_ODBC_DSN, and optionally _USER and _PASS and/or the DBICTEST_MSACCESS_ADO_DSN, and optionally _USER and _PASS environment variables');
114 }
115 else {
116     $tester->run_tests();
117 }
118
119 # vim:et sts=4 sw=4 tw=0: