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/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 |