Update Firebird ODBC driver download URL
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 10_11msaccess_common.t
CommitLineData
3b17d988 1use strict;
2use warnings;
3use Test::More;
4fb2971c 4use DBIx::Class::Optional::Dependencies;
3568bda9 5use DBIx::Class::Schema::Loader::DBI::ODBC::ACCESS ();
3b17d988 6use lib qw(t/lib);
7use dbixcsl_common_tests;
8
4fb2971c 9my %dsns;
10for (qw(MSACCESS_ODBC MSACCESS_ADO)) {
11 next unless $ENV{"DBICTEST_${_}_DSN"};
3b17d988 12
4fb2971c 13 my $dep_group = lc "rdbms_$_";
14 if (!DBIx::Class::Optional::Dependencies->req_ok_for($dep_group)) {
15 diag 'You need to install ' . DBIx::Class::Optional::Dependencies->req_missing_for($dep_group)
16 . " to test with $_";
17 next;
18 }
19
20 $dsns{$_}{dsn} = $ENV{"DBICTEST_${_}_DSN"};
21 $dsns{$_}{user} = $ENV{"DBICTEST_${_}_USER"};
22 $dsns{$_}{password} = $ENV{"DBICTEST_${_}_PASS"};
23};
24
25plan skip_all => 'You need to set the DBICTEST_MSACCESS_ODBC_DSN, _USER and _PASS and/or the DBICTEST_MSACCESS_ADO_DSN, _USER and _PASS environment variables'
26 unless %dsns;
3b17d988 27
28my %ado_extra_types = (
29 'tinyint' => { data_type => 'tinyint', original => { data_type => 'byte' } },
30 'smallmoney' => { data_type => 'money', original => { data_type => 'currency' } },
31 'decimal' => { data_type => 'decimal' },
32 'decimal(3)' => { data_type => 'decimal', size => [3, 0] },
33 'decimal(3,3)'=> { data_type => 'decimal', size => [3, 3] },
34 'dec(5,5)' => { data_type => 'decimal', size => [5, 5] },
35 'numeric(2,2)'=> { data_type => 'decimal', size => [2, 2] },
36 'character' => { data_type => 'char', size => 255 },
37 'character varying(5)' => { data_type => 'varchar', size => 5 },
38 'nchar(5)' => { data_type => 'char', size => 5 },
39 'national character(5)' => { data_type => 'char', size => 5 },
40 'nvarchar(5)' => { data_type => 'varchar', size => 5 },
41 'national character varying(5)' => { data_type => 'varchar', size => 5 },
42 'national char varying(5)' => { data_type => 'varchar', size => 5 },
43 'smalldatetime' => { data_type => 'datetime' },
44 'uniqueidentifier' => { data_type => 'uniqueidentifier', original => { data_type => 'guid' } },
45 'text' => { data_type => 'text', original => { data_type => 'longchar' } },
46 'ntext' => { data_type => 'text', original => { data_type => 'longchar' } },
47);
48
49my $tester = dbixcsl_common_tests->new(
50 vendor => 'Access',
51 auto_inc_pk => 'AUTOINCREMENT PRIMARY KEY',
52 quote_char => [qw/[ ]/],
7336f5dc 53 connect_info => [ map { $dsns{$_} } sort keys %dsns ],
3b17d988 54 data_types => {
55 # http://msdn.microsoft.com/en-us/library/bb208866(v=office.12).aspx
56 #
57 # Numeric types
58 'autoincrement'=>{ data_type => 'integer', is_auto_increment => 1 },
59 'int' => { data_type => 'integer' },
60 'integer' => { data_type => 'integer' },
61 'long' => { data_type => 'integer' },
62 'integer4' => { data_type => 'integer' },
63 'smallint' => { data_type => 'smallint' },
64 'short' => { data_type => 'smallint' },
65 'integer2' => { data_type => 'smallint' },
66 'integer1' => { data_type => 'tinyint', original => { data_type => 'byte' } },
67 'byte' => { data_type => 'tinyint', original => { data_type => 'byte' } },
68 'bit' => { data_type => 'bit' },
69 'logical' => { data_type => 'bit' },
70 'logical1' => { data_type => 'bit' },
71 'yesno' => { data_type => 'bit' },
72 'money' => { data_type => 'money', original => { data_type => 'currency' } },
73 'currency' => { data_type => 'money', original => { data_type => 'currency' } },
74 'real' => { data_type => 'real' },
75 'single' => { data_type => 'real' },
76 'ieeesingle' => { data_type => 'real' },
77 'float4' => { data_type => 'real' },
78 'float' => { data_type => 'double precision', original => { data_type => 'double' } },
79 'float' => { data_type => 'double precision', original => { data_type => 'double' } },
80 'float8' => { data_type => 'double precision', original => { data_type => 'double' } },
81 'double' => { data_type => 'double precision', original => { data_type => 'double' } },
82 'ieeedouble' => { data_type => 'double precision', original => { data_type => 'double' } },
83 'number' => { data_type => 'double precision', original => { data_type => 'double' } },
84
85# # character types
86 'text(25)' => { data_type => 'varchar', size => 25 },
87 'char' => { data_type => 'char', size => 255 },
88 'char(5)' => { data_type => 'char', size => 5 },
89 'string(5)' => { data_type => 'varchar', size => 5 },
90 'varchar(5)' => { data_type => 'varchar', size => 5 },
91
92 # binary types
93 'binary(10)' => { data_type => 'binary', size => 10 },
94 'varbinary(11)' => { data_type => 'varbinary', size => 11 },
95
96 # datetime types
97 'datetime' => { data_type => 'datetime' },
98 'time' => { data_type => 'datetime' },
99 'timestamp' => { data_type => 'datetime' },
100
101 # misc types
102 'guid' => { data_type => 'uniqueidentifier', original => { data_type => 'guid' } },
103
104 # blob types
105 'longchar' => { data_type => 'text', original => { data_type => 'longchar' } },
106 'longtext' => { data_type => 'text', original => { data_type => 'longchar' } },
107 'memo' => { data_type => 'text', original => { data_type => 'longchar' } },
108 'image' => { data_type => 'image', original => { data_type => 'longbinary' } },
109 'longbinary' => { data_type => 'image', original => { data_type => 'longbinary' } },
110
3568bda9 111 %ado_extra_types,
112 },
113 data_types_ddl_cb => sub {
114 my $ddl = shift;
115 {
116 package DBIXCSL_Test::DummySchema;
117 use base 'DBIx::Class::Schema';
118 }
4fb2971c 119 my @connect_info = @{$dsns{MSACCESS_ODBC} || $dsns{MSACCESS_ADO}};
3568bda9 120
121 my $schema = DBIXCSL_Test::DummySchema->connect(@connect_info);
122
123 my $loader = DBIx::Class::Schema::Loader::DBI::ODBC::ACCESS->new(
124 schema => $schema,
125 naming => 'current',
126 );
127
128 my $conn = $loader->_ado_connection;
129
9ef345a5 130 require Win32::OLE;
3568bda9 131 my $comm = Win32::OLE->new('ADODB.Command');
132
133 $comm->{ActiveConnection} = $conn;
134 $comm->{CommandText} = $ddl;
135 $comm->Execute;
3b17d988 136 },
137);
138
4fb2971c 139$tester->run_tests();
3b17d988 140
141# vim:et sts=4 sw=4 tw=0: