whops
[dbsrgits/DBIx-Class.git] / t / 95sql_maker.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5
6 use lib qw(t/lib);
7 use DBIC::SqlMakerTest;
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_ok('DBICTest');
17
18 my $schema = DBICTest->init_schema();
19
20 my $sql_maker = $schema->storage->sql_maker;
21
22
23 SKIP: {
24   skip "SQL::Abstract < 1.49 does not pass through arrayrefs", 2
25     if $SQL::Abstract::VERSION < 1.49;
26
27   my ($sql, @bind) = $sql_maker->insert(
28             'lottery',
29             {
30               'day' => '2008-11-16',
31               'numbers' => [13, 21, 34, 55, 89]
32             }
33   );
34
35   is_same_sql_bind(
36     $sql, \@bind,
37     q/INSERT INTO lottery (day, numbers) VALUES (?, ?)/,
38       [ ['day' => '2008-11-16'], ['numbers' => [13, 21, 34, 55, 89]] ],
39     'sql_maker passes arrayrefs in insert'
40   );
41
42
43   ($sql, @bind) = $sql_maker->update(
44             'lottery',
45             {
46               'day' => '2008-11-16',
47               'numbers' => [13, 21, 34, 55, 89]
48             }
49   );
50
51   is_same_sql_bind(
52     $sql, \@bind,
53     q/UPDATE lottery SET day = ?, numbers = ?/,
54       [ ['day' => '2008-11-16'], ['numbers' => [13, 21, 34, 55, 89]] ],
55     'sql_maker passes arrayrefs in update'
56   );
57 }