Fix ordering of 'use lib' and 'use' in tests
[dbsrgits/DBIx-Class.git] / t / 95sql_maker.t
CommitLineData
e5938571 1use strict;
2use warnings;
3
4use Test::More;
e5938571 5
c61a0748 6use lib qw(t/lib);
7use DBIC::SqlMakerTest;
e5938571 8
9BEGIN {
10 eval "use DBD::SQLite";
11 plan $@
12 ? ( skip_all => 'needs DBD::SQLite for testing' )
13 : ( tests => 3 );
14}
15
16use lib qw(t/lib);
17
18use_ok('DBICTest');
19
20my $schema = DBICTest->init_schema();
21
22my $sql_maker = $schema->storage->sql_maker;
23
24
89479564 25SKIP: {
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}