better money value comparison in tests
[dbsrgits/DBIx-Class.git] / t / 95sql_maker.t
CommitLineData
e5938571 1use strict;
2use warnings;
3
4use Test::More;
b2b22cd6 5use Test::Exception;
e5938571 6
c61a0748 7use lib qw(t/lib);
8use DBIC::SqlMakerTest;
e5938571 9
b2b22cd6 10plan tests => 4;
e5938571 11
e5938571 12use_ok('DBICTest');
13
14my $schema = DBICTest->init_schema();
15
16my $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)
53my $file = __FILE__;
51a05c99 54$file = "\Q$file\E";
b2b22cd6 55throws_ok (sub {
56 $schema->resultset ('Artist')->search ({}, { order_by => { -asc => 'stuff', -desc => 'staff' } } )->as_query;
57}, qr/$file/, 'Exception correctly croak()ed');