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