I noticed that when I try to set a boolean value to 0 it successfully
sets the value to false, but then fails to save the changes to the DB
when I call $object->save. This doesn't happen when you set the value
to 'f' or 'n' or any other value that has a 'defined' value.
The attached simple patch fixes the problem. I have attached a second
alternate patch which fixes the exact same problem in a slightly
different way, which I think is a bit cleaner (there seemed to be some
duplication of effort in there).
Cheers,
Cees
--- Rose-DB-Object-0.726.orig/lib/Rose/DB/Object/MakeMethods/Generic.pm 2006-05-18 10:01:39.000000000 -0400
+++ Rose-DB-Object-0.726/lib/Rose/DB/Object/MakeMethods/Generic.pm 2006-05-24 13:46:20.000000000 -0400
@@ -495,6 +495,7 @@
}
}
+ $self->{$formatted_key,$driver} = undef;
return $self->{$key} = 0;
}
@@ -563,6 +564,7 @@
}
}
+ $self->{$formatted_key,$driver} = undef;
return $self->{$key} = 0;
}
--- Rose-DB-Object-0.726.orig/lib/Rose/DB/Object/MakeMethods/Generic.pm 2006-05-18 10:01:39.000000000 -0400
+++ Rose-DB-Object-0.726/lib/Rose/DB/Object/MakeMethods/Generic.pm 2006-05-24 13:24:07.000000000 -0400
@@ -466,8 +466,6 @@
if(@_)
{
- if($_[0])
- {
if($self->{STATE_LOADING()})
{
$self->{$key} = undef;
@@ -495,9 +493,6 @@
}
}
- return $self->{$key} = 0;
- }
-
# Pull default through if necessary
unless(defined $self->{$key} || defined $self->{$formatted_key,$driver})
{
@@ -534,8 +529,6 @@
my $db = $self->db or die "Missing Rose::DB object attribute";
my $driver = $db->driver || 'unknown';
- if($_[0])
- {
if($self->{STATE_LOADING()})
{
$self->{$key} = undef;
@@ -563,9 +556,6 @@
}
}
- return $self->{$key} = 0;
- }
-
if($self->{STATE_SAVING()})
{
$self->{$formatted_key,$driver} = $db->format_boolean($self->{$key})