Re: [CDBI] Re: construct sucks.

Perrin Harkins <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.class-dbi
Message-ID <[email protected]>
Ryan Tate wrote:
> Here is my proposed change to _init, which I filed on RT by mail:
> 
> sub _init {
>        my $class = shift;
>        my $data  = shift || {};
>        my $key   = $class->_live_object_key($data);
>        my $obj;
>        if ($obj = $Live_Objects{$key}) {
>          $obj->_attribute_store(%$data);
>        }
>        else {
>          $obj = $class->_fresh_init($key => $data);
>        }
>        return $obj;
> }

The potential problem with this change (and I think this was actually 
discussed earlier on the list) is that somewhere else you may have 
already updated one of those keys and not saved it yet, so you'd be 
overwriting that update here.  You could check to see if the keys have 
been changed before writing the new data to the object, although this 
will slow it down.

- Perrin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.