[CDBI] Updating a record - slight change proposal

Hartmaier Alexander Alexander.Hartmaier at t-systems.at
Wed Sep 7 14:41:10 BST 2005


Hi!

I already sent a patch to Tony including a test at the time he released
0.999.
The wrote that he will look at it to include in 1.00 but after the
controversies on the list Tony never replied about it.

-Alex


> -----Ursprüngliche Nachricht-----
> Von: classdbi-bounces at lists.digitalcraftsmen.net [mailto:classdbi-
> bounces at lists.digitalcraftsmen.net] Im Auftrag von William Ross
> Gesendet: Mittwoch, 7. September 2005 11:34
> An: Kate Yoak
> Cc: classdbi at lists.digitalcraftsmen.net
> Betreff: Re: [CDBI] Updating a record - slight change proposal
> 
> 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 at lists.digitalcraftsmen.net
> http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5544 bytes
Desc: not available
Url : http://lists.digitalcraftsmen.net/mailman/private/classdbi/attachments/20050907/e000f19d/smime.bin


More information about the ClassDBI mailing list