Showing 8 changed files with 94 additions and 1 deletions
BIN
t/access.mdb
Binary file not shown.
+1 -1
t/access.t
... ...
@@ -13,7 +13,7 @@ my $database = "$FindBin::Bin/access.mdb";
13 13
 
14 14
 $dsn = "dbi:ODBC:driver=Microsoft Access Driver (*.mdb);dbq=$database";
15 15
 
16
-plan skip_all => 'Microsoft access(ODBC, *.mdb) private test' unless -f "$FindBin::Bin/run/mysql2.run"
16
+plan skip_all => 'Microsoft access(ODBC, *.mdb) private test' unless -f "$FindBin::Bin/run/access.run"
17 17
   && eval { $dbi = DBIx::Custom->connect(dsn => $dsn); 1 };
18 18
 plan 'no_plan';
19 19
 
+46
t/access2007-accdb.t
... ...
@@ -0,0 +1,46 @@
1
+use Test::More;
2
+use strict;
3
+use warnings;
4
+use utf8;
5
+
6
+use FindBin;
7
+use DBIx::Custom;
8
+
9
+my $dbi;
10
+my $dsn;
11
+my $database = "$FindBin::Bin/access2007.accdb";
12
+
13
+$dsn = "dbi:ODBC:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=$database";
14
+
15
+plan skip_all => 'Microsoft access(ODBC, *.accdb(2007)) private test'
16
+  unless -f "$FindBin::Bin/run/access2007-accdb.run"
17
+      && eval { $dbi = DBIx::Custom->connect(dsn => $dsn); 1 };
18
+plan 'no_plan';
19
+
20
+my $model;
21
+my $result;
22
+my $row;
23
+my $rows;
24
+
25
+eval { $dbi->execute("drop table table1") };
26
+eval { $dbi->execute("drop table table2") };
27
+$dbi->execute("create table table1 (key1 varchar(255), key2 varchar(255))");
28
+$dbi->execute("create table table2 (key1 varchar(255), key3 varchar(255))");
29
+$model = $dbi->create_model(table => 'table1');
30
+$model->insert({key1 => 1, key2 => 2});
31
+$model->insert({key1 => 4, key2 => 5});
32
+$model->insert({key1 => 6, key2 => 7});
33
+$model->update({key2 => 3}, where => {key1 => 1});
34
+$model->delete(where => {key1 => 6});
35
+$rows = $model->select->all;
36
+is_deeply($rows, [{key1 => 1, key2 => 3}, {key1 => 4, key2 => 5}]);
37
+is($model->count, 2);
38
+$dbi->insert({key1 => 1, key3 => 2}, table => 'table2');
39
+$dbi->separator('-');
40
+$row = $model->select(
41
+    table => 'table1',
42
+    column => {table2 => [qw/key3/]},
43
+    join => ['left outer join table2 on table1.key1 = table2.key1']
44
+)->one;
45
+is_deeply($row, {"table2-key3" => 2});
46
+
BIN
t/access2007.accdb
Binary file not shown.
+47
t/access2010-accdb.t
... ...
@@ -0,0 +1,47 @@
1
+use Test::More;
2
+use strict;
3
+use warnings;
4
+use utf8;
5
+
6
+use FindBin;
7
+use DBIx::Custom;
8
+
9
+my $dbi;
10
+my $dsn;
11
+my $database = "$FindBin::Bin/access2010.accdb";
12
+
13
+$dsn = "dbi:ODBC:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=$database";
14
+$dbi = DBIx::Custom->connect(dsn => $dsn);
15
+
16
+plan skip_all => 'Microsoft access(ODBC, *.accdb(2010)) private test'
17
+  unless -f "$FindBin::Bin/run/access2010-accdb.run"
18
+      && eval { $dbi = DBIx::Custom->connect(dsn => $dsn); 1 };
19
+plan 'no_plan';
20
+
21
+my $model;
22
+my $result;
23
+my $row;
24
+my $rows;
25
+
26
+eval { $dbi->execute("drop table table1") };
27
+eval { $dbi->execute("drop table table2") };
28
+$dbi->execute("create table table1 (key1 varchar(255), key2 varchar(255))");
29
+$dbi->execute("create table table2 (key1 varchar(255), key3 varchar(255))");
30
+$model = $dbi->create_model(table => 'table1');
31
+$model->insert({key1 => 1, key2 => 2});
32
+$model->insert({key1 => 4, key2 => 5});
33
+$model->insert({key1 => 6, key2 => 7});
34
+$model->update({key2 => 3}, where => {key1 => 1});
35
+$model->delete(where => {key1 => 6});
36
+$rows = $model->select->all;
37
+is_deeply($rows, [{key1 => 1, key2 => 3}, {key1 => 4, key2 => 5}]);
38
+is($model->count, 2);
39
+$dbi->insert({key1 => 1, key3 => 2}, table => 'table2');
40
+$dbi->separator('-');
41
+$row = $model->select(
42
+    table => 'table1',
43
+    column => {table2 => [qw/key3/]},
44
+    join => ['left outer join table2 on table1.key1 = table2.key1']
45
+)->one;
46
+is_deeply($row, {"table2-key3" => 2});
47
+
BIN
t/access2010.accdb
Binary file not shown.
t/run/access2007-accdb.run
No changes.
t/run/access2010-accdb.run
No changes.