added Microsoft Access 2010 ...
|
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( |
|
cleanup
|
41 |
table => 'table1', |
42 |
column => {table2 => [qw/key3/]}, |
|
43 |
join => ['left outer join table2 on table1.key1 = table2.key1'] |
|
added Microsoft Access 2010 ...
|
44 |
)->one; |
45 |
is_deeply($row, {"table2-key3" => 2}); |
|
46 |