9 my @art = DBICTest::Artist->search({ }, { order_by => 'name DESC'});
11 cmp_ok(@art, '==', 3, "Three artists returned");
15 is($art->name, 'We Are Goth', "Correct order too");
17 $art->name('We Are In Rehab');
19 is($art->name, 'We Are In Rehab', "Accessor update ok");
21 is($art->get_column("name"), 'We Are In Rehab', 'And via get_column');
23 ok($art->update, 'Update run');
25 @art = DBICTest::Artist->search({ name => 'We Are In Rehab' });
27 cmp_ok(@art, '==', 1, "Changed artist returned by search");
29 cmp_ok($art[0]->artistid, '==', 3,'Correct artist too');
33 @art = DBICTest::Artist->search({ });
35 cmp_ok(@art, '==', 2, 'And then there were two');
37 ok(!$art->in_database, "It knows it's dead");
39 eval { $art->delete; };
41 ok($@, "Can't delete twice: $@");
43 is($art->name, 'We Are In Rehab', 'But the object is still live');
47 ok($art->in_database, "Re-created");
49 @art = DBICTest::Artist->search({ });
51 cmp_ok(@art, '==', 3, 'And now there are three again');
53 my $new = DBICTest::Artist->create({ artistid => 4 });
55 cmp_ok($new->artistid, '==', 4, 'Create produced record ok');
57 @art = DBICTest::Artist->search({ });
59 cmp_ok(@art, '==', 4, "Oh my god! There's four of them!");
61 $new->set_column('name' => 'Man With A Fork');
63 is($new->name, 'Man With A Fork', 'set_column ok');
65 $new->discard_changes;
67 ok(!defined $new->name, 'Discard ok');
69 $new->name('Man With A Spoon');
73 $new_again = DBICTest::Artist->retrieve(4);
75 is($new_again->name, 'Man With A Spoon', 'Retrieved correctly');