Bring out the big-paranoia-harness - make describe_env infallible
[dbsrgits/DBIx-Class.git] / t / sqlmaker / literal_with_bind.t
CommitLineData
c0329273 1BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
2
f6faeab8 3use strict;
4use warnings;
5use Test::More;
6use Test::Exception;
c0329273 7
f6faeab8 8use DBICTest;
9
10my $schema = DBICTest->init_schema(no_populate => 1);
11my $ars = $schema->resultset('Artist');
12
13my $rank = \13;
14my $ref1 = \['?', [name => 'foo']];
15my $ref2 = \['?', [name => 'bar']];
16my $ref3 = \['?', [name => 'baz']];
17
18# do it twice, make sure the args are untouched
19for (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
44is_deeply(
45 $ref1,
46 \['?', [name => 'foo']],
47 'ref1 unchanged',
48);
49is_deeply(
50 $ref2,
51 \['?', [name => 'bar']],
52 'ref2 unchanged',
53);
54is_deeply(
55 $ref3,
56 \['?', [name => 'baz']],
57 'ref3 unchanged',
58);
59
60done_testing;
61
62# vim:sts=2 sw=2: