Baby Moose All Tuckered out

It if put the 'D' in CRUD day here at the Moose-pen.

So yeaterday I fininsed off Retreive/Select after I pulled a few hairs out trying to debug and issues that was not there I thouhg today I wiyld finish of my CRUD subs by doing the _delete sub today.

At least this is the most simple of all four functions as there is not need to iterate over fields or contrainers so the code is just;


sub _delete {
my $self = shift;
my ($container) = @_;
my @fields = ();
my $delete_clause = join(" ",Database::Accessor::Driver::DBI::SQL::DELETE
,Database::Accessor::Driver::DBI::SQL::FROM
,$self->view()->name());
$self->da_warn("_delete","Delete clause='$delete_clause'")
if $self->da_warning()>=5;
return $delete_clause;
}

Like the other four sub I am keeping things very simple for but then again for deletes are very simple in SQL snaydiwnow and for once I did not make any typos or
other bugs so I had a little time to fix up the 10_crud_basic.t test case a little.

So in that vain I added this onto that test case


ok(scalar(@{$user->result()->set}) == 1,"One row returned");
ok($user->result()->set->[0]->[0] eq 'Uchanged','username changed');
ok($user->result()->set->[0]->[1] eq 'Achanged','address changed');
eval{
$user->delete($utils->connect());
};
if ($@) {
fail("delete function error=$@");
}
else {
pass("delete function");
}
ok($user->result()->effected == 1,"One row Deleted");
eval{
$user->retrieve($utils->connect());
};
if ($@) {
fail("retrieve function error=$@");
}
else {
pass("retrieve function");
}
ok(scalar(@{$user->result()->set}) == 0,"Nothing in DB");

So I do that check after the select for 'One Row' and then I check to see that my result set had the correct values
that reflected the eariler change with the update. I then do the delete and check for 1 returned and then
I do another select and check to see if no records where returned.

Now when I run it I get;


ok 1 - Create function
ok 2 - One row effected
ok 3 - Update function
ok 4 - Two rows effected
ok 5 - retrieve function
ok 6 - One row returned
ok 7 - username changed
ok 8 - address changed
ok 9 - delete function
ok 10 - One row Deleted
ok 11 - retrieve function
ok 12 - Nothing in DB

so progress at last. The baby moose is getting really tiered now as things start moving along,

DSC07262a.jpg

Leave a comment

About byterock

user-pic Long time Perl guy, a few CPAN mods allot of work on DBD::Oracle and a few YAPC presentations