Re: [CDBI] Updating a record - slight change proposal
[prev]
[thread]
[next]
[Date index for 2005/09/07]
On 7 Sep 2005, at 02:53, Kate Yoak wrote:
> <snip> for my $col (keys %$vals) {
> #### ADDING the unless statement here:
> #$self->{__Changed}{$col}++ ;
> $self->{__Changed}{$col}++ unless $self->_attr($col) eq $vals-
> >{$col};
> }
> $self->_attribute_store($vals);
> }
>
> In other words, don't mark something as changed if it hasn't really
> changed.
>
> What did I break?
The existing or new value will often be an object, which will often
but not always stringify to the value that would be stored in the
database, so testing with 'eq' isn't always going to work. You'd
really have to use the same deflation mechanism as cdbi does when
updating. I would imagine that Tony considered this before taking the
easy route, but since he's not here you'd have to ask him directly.
I'm afraid you'll probably have to grep for primary keys when using
set(). You could either do it beforehand or by adding a
normalize_column_values() method in subclass:
sub normalize_column_values {
my ($self, $column_values) = @_;
delete $column_values->{$_} for $self->primary_columns;
}
I do think you've found a bug, though. The real fix is probably to
prevent _attribute_delete() from emptying primary key columns, which
imho aren't really attributes in that sense anyway.
best,
will
_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi
|
|
Re: [CDBI] Updating a record - slight change proposal
William Ross 09:33 on 07 Sep 2005
|