Commit | Line | Data |
f6faeab8 |
1 | use strict; |
2 | use warnings; |
3 | use Test::More; |
4 | use Test::Exception; |
5 | use lib qw(t/lib); |
6 | use DBICTest; |
7 | |
8 | my $schema = DBICTest->init_schema(no_populate => 1); |
9 | my $ars = $schema->resultset('Artist'); |
10 | |
11 | my $rank = \13; |
12 | my $ref1 = \['?', [name => 'foo']]; |
13 | my $ref2 = \['?', [name => 'bar']]; |
14 | my $ref3 = \['?', [name => 'baz']]; |
15 | |
16 | # do it twice, make sure the args are untouched |
17 | for (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 | |
42 | is_deeply( |
43 | $ref1, |
44 | \['?', [name => 'foo']], |
45 | 'ref1 unchanged', |
46 | ); |
47 | is_deeply( |
48 | $ref2, |
49 | \['?', [name => 'bar']], |
50 | 'ref2 unchanged', |
51 | ); |
52 | is_deeply( |
53 | $ref3, |
54 | \['?', [name => 'baz']], |
55 | 'ref3 unchanged', |
56 | ); |
57 | |
58 | done_testing; |
59 | |
60 | # vim:sts=2 sw=2: |