Commit | Line | Data |
e5938571 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
b2b22cd6 |
5 | use Test::Exception; |
e5938571 |
6 | |
c61a0748 |
7 | use lib qw(t/lib); |
8 | use DBIC::SqlMakerTest; |
e5938571 |
9 | |
b2b22cd6 |
10 | plan tests => 4; |
e5938571 |
11 | |
e5938571 |
12 | use_ok('DBICTest'); |
13 | |
14 | my $schema = DBICTest->init_schema(); |
15 | |
16 | my $sql_maker = $schema->storage->sql_maker; |
17 | |
18 | |
20ea616f |
19 | { |
89479564 |
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 | } |
b2b22cd6 |
51 | |
52 | # Make sure the carp/croak override in SQLA works (via SQLAHacks) |
53 | my $file = __FILE__; |
54 | throws_ok (sub { |
55 | $schema->resultset ('Artist')->search ({}, { order_by => { -asc => 'stuff', -desc => 'staff' } } )->as_query; |
56 | }, qr/$file/, 'Exception correctly croak()ed'); |