Some cleanups and code dedup of Top and FetchFirst limit dialects
[dbsrgits/DBIx-Class.git] / t / 69update.t
CommitLineData
70350518 1use strict;
8273e845 2use warnings;
70350518 3
4use Test::More;
5use lib qw(t/lib);
6use DBICTest;
7
a47e1233 8my $schema = DBICTest->init_schema();
0567538f 9
f9db5527 10my $art = $schema->resultset("Artist")->find(1);
0567538f 11
12isa_ok $art => 'DBICTest::Artist';
13
14my $name = 'Caterwauler McCrae';
15
16ok($art->name($name) eq $name, 'update');
17
56166f36 18{
0567538f 19 my @changed_keys = $art->is_changed;
20 is( scalar (@changed_keys), 0, 'field changed but same value' );
56166f36 21}
0567538f 22
23$art->discard_changes;
24
5a9e0e60 25ok($art->update({ artistid => 100 }), 'update allows pk mutation');
26
27is($art->artistid, 100, 'pk mutation applied');
6c299e8b 28
29my $art_100 = $schema->resultset("Artist")->find(100);
30$art_100->artistid(101);
31ok($art_100->update(), 'update allows pk mutation via column accessor');
56166f36 32
33done_testing;