patch for DBI.pm so store_column is called only once on create() and tests for that
[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
e5938571 16use_ok('DBICTest');
17
18my $schema = DBICTest->init_schema();
19
20my $sql_maker = $schema->storage->sql_maker;
21
22
20ea616f 23{
89479564 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 );
54}