File Coverage

File:t/09-sql-update.t
Coverage:100.0%

linestmtbrancondsubpodtimecode
1
1
1
1
31
4
11
use lib 'lib';
2
1
1
1
13
3
7
use strict;
3
1
1
1
11
16
10
use warnings;
4
5
1
1
1
15
3
19
use Test::More tests => 6;
6
1
12
BEGIN { use_ok('SQL::Update'); }
7
8
1
22
sub _Q { "'$_[0]'" }
9
10
1
10
my $update = SQL::Update->new;
11
1
7
$update->update( 'models' )
12       ->set( 'abc' => '"howdy"' );
13
14
1
11
is $update->generate, <<_EOC_;
15update models
16set abc = "howdy";
17_EOC_
18
19
1
3
is "$update", <<_EOC_;
20update models
21set abc = "howdy";
22_EOC_
23
24
1
13
$update->where("table_name", '=', _Q('blah'))->set(foo => 'bar');
25
26
1
8
is $update->generate, <<_EOC_;
27update models
28set abc = "howdy", foo = bar
29where table_name = 'blah';
30_EOC_
31
32
1
14
$update->where("Foo", '>', 'bar');
33
1
4
is "$update", <<'_EOC_';
34update models
35set abc = "howdy", foo = bar
36where table_name = 'blah' and Foo > bar;
37_EOC_
38
39
1
20
$update->reset( qw<abc> )
40       ->set( 'foo' => 3 )->where(name => '"John"');
41
1
6
is $update->generate, <<_EOC_;
42update abc
43set foo = 3
44where name = "John";
45_EOC_
46