Commit | Line | Data |
e5938571 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
e5938571 |
5 | |
c61a0748 |
6 | use lib qw(t/lib); |
7 | use DBIC::SqlMakerTest; |
e5938571 |
8 | |
9 | BEGIN { |
10 | eval "use DBD::SQLite"; |
11 | plan $@ |
12 | ? ( skip_all => 'needs DBD::SQLite for testing' ) |
13 | : ( tests => 3 ); |
14 | } |
15 | |
16 | use lib qw(t/lib); |
17 | |
18 | use_ok('DBICTest'); |
19 | |
20 | my $schema = DBICTest->init_schema(); |
21 | |
22 | my $sql_maker = $schema->storage->sql_maker; |
23 | |
24 | |
89479564 |
25 | SKIP: { |
89869c75 |
26 | skip "SQL::Abstract < 1.49 does not pass through arrayrefs", 2 |
27 | if $SQL::Abstract::VERSION < 1.49; |
89479564 |
28 | |
29 | my ($sql, @bind) = $sql_maker->insert( |
30 | 'lottery', |
31 | { |
32 | 'day' => '2008-11-16', |
33 | 'numbers' => [13, 21, 34, 55, 89] |
34 | } |
35 | ); |
36 | |
37 | is_same_sql_bind( |
38 | $sql, \@bind, |
39 | q/INSERT INTO lottery (day, numbers) VALUES (?, ?)/, |
40 | [ ['day' => '2008-11-16'], ['numbers' => [13, 21, 34, 55, 89]] ], |
41 | 'sql_maker passes arrayrefs in insert' |
42 | ); |
43 | |
44 | |
45 | ($sql, @bind) = $sql_maker->update( |
46 | 'lottery', |
47 | { |
48 | 'day' => '2008-11-16', |
49 | 'numbers' => [13, 21, 34, 55, 89] |
50 | } |
51 | ); |
52 | |
53 | is_same_sql_bind( |
54 | $sql, \@bind, |
55 | q/UPDATE lottery SET day = ?, numbers = ?/, |
56 | [ ['day' => '2008-11-16'], ['numbers' => [13, 21, 34, 55, 89]] ], |
57 | 'sql_maker passes arrayrefs in update' |
58 | ); |
59 | } |