* Added test cases to test if arrayref bind values in insert/update are passed throu...
[dbsrgits/DBIx-Class-Historic.git] / t / 95sql_maker.t
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
24 my ($sql, @bind) = $sql_maker->insert(
25           'lottery',
26           {
27             'day' => '2008-11-16',
28             'numbers' => [13, 21, 34, 55, 89]
29           }
30 );
31
32 is_same_sql_bind(
33   $sql, \@bind,
34   q/INSERT INTO lottery (day, numbers) VALUES (?, ?)/,
35     [ ['day' => '2008-11-16'], ['numbers' => [13, 21, 34, 55, 89]] ],
36   'sql_maker passes arrayrefs in insert'
37 );
38
39
40 ($sql, @bind) = $sql_maker->update(
41           'lottery',
42           {
43             'day' => '2008-11-16',
44             'numbers' => [13, 21, 34, 55, 89]
45           }
46 );
47
48 is_same_sql_bind(
49   $sql, \@bind,
50   q/UPDATE lottery SET day = ?, numbers = ?/,
51     [ ['day' => '2008-11-16'], ['numbers' => [13, 21, 34, 55, 89]] ],
52   'sql_maker passes arrayrefs in update'
53 );