added the default attrs to solve the failing test recently commited
[dbsrgits/DBIx-Class.git] / t / 95sql_maker.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use Test::Exception;
6
7 use lib qw(t/lib);
8 use DBIC::SqlMakerTest;
9
10 plan tests => 4;
11
12 use_ok('DBICTest');
13
14 my $schema = DBICTest->init_schema();
15
16 my $sql_maker = $schema->storage->sql_maker;
17
18
19 {
20   my ($sql, @bind) = $sql_maker->insert(
21             'lottery',
22             {
23               'day' => '2008-11-16',
24               'numbers' => [13, 21, 34, 55, 89]
25             }
26   );
27
28   is_same_sql_bind(
29     $sql, \@bind,
30     q/INSERT INTO lottery (day, numbers) VALUES (?, ?)/,
31       [ ['day' => '2008-11-16'], ['numbers' => [13, 21, 34, 55, 89]] ],
32     'sql_maker passes arrayrefs in insert'
33   );
34
35
36   ($sql, @bind) = $sql_maker->update(
37             'lottery',
38             {
39               'day' => '2008-11-16',
40               'numbers' => [13, 21, 34, 55, 89]
41             }
42   );
43
44   is_same_sql_bind(
45     $sql, \@bind,
46     q/UPDATE lottery SET day = ?, numbers = ?/,
47       [ ['day' => '2008-11-16'], ['numbers' => [13, 21, 34, 55, 89]] ],
48     'sql_maker passes arrayrefs in update'
49   );
50 }
51
52 # Make sure the carp/croak override in SQLA works (via SQLAHacks)
53 my $file = __FILE__;
54 $file = "\Q$file\E";
55 throws_ok (sub {
56   $schema->resultset ('Artist')->search ({}, { order_by => { -asc => 'stuff', -desc => 'staff' } } )->as_query;
57 }, qr/$file/, 'Exception correctly croak()ed');