Introduce GOVERNANCE document and empty RESOLUTIONS file.
[dbsrgits/DBIx-Class.git] / t / sqlmaker / literal_with_bind.t
1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
2
3 use strict;
4 use warnings;
5 use Test::More;
6 use Test::Exception;
7
8 use DBICTest;
9
10 my $schema = DBICTest->init_schema(no_populate => 1);
11 my $ars    = $schema->resultset('Artist');
12
13 my $rank = \13;
14 my $ref1 = \['?', [name => 'foo']];
15 my $ref2 = \['?', [name => 'bar']];
16 my $ref3 = \['?', [name => 'baz']];
17
18 # do it twice, make sure the args are untouched
19 for (1,2) {
20   $ars->delete;
21
22   lives_ok {
23     $ars->create({ artistid => 666, name => $ref1, rank => $rank });
24   } 'inserted row using literal sql';
25
26   ok (($ars->search({ name => 'foo' })->first),
27     'row was inserted');
28
29   lives_ok {
30     $ars->search({ name => { '=' => $ref1} })->update({ name => $ref2, rank => $rank });
31   } 'search/updated row using literal sql';
32
33   ok (($ars->search({ name => 'bar' })->first),
34     'row was updated');
35
36   lives_ok {
37     $ars->populate([{ artistid => 777, name => $ref3, rank => $rank  }]);
38   } 'populated row using literal sql';
39
40   ok (($ars->search({ name => 'baz' })->first),
41     'row was populated');
42 }
43
44 is_deeply(
45   $ref1,
46   \['?', [name => 'foo']],
47   'ref1 unchanged',
48 );
49 is_deeply(
50   $ref2,
51   \['?', [name => 'bar']],
52   'ref2 unchanged',
53 );
54 is_deeply(
55   $ref3,
56   \['?', [name => 'baz']],
57   'ref3 unchanged',
58 );
59
60 done_testing;
61
62 # vim:sts=2 sw=2: