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