Re: [CDBI] Re: construct sucks.

"Ryan Tate" <lists-UNebACArQA1Wk0Htik3J/[email protected]>
Newsgroups gmane.comp.lang.perl.modules.class-dbi
Message-ID <[email protected]>
Here is the relevant code from CDBI 3.0.15, latest:

sub construct {
	my ($proto, $data) = @_;
	my $class = ref $proto || $proto;
	my $self = $class->_init($data);
	$self->call_trigger('select');
	return $self;
}

sub _init {
	my $class = shift;
	my $data  = shift || {};
	my $key   = $class->_live_object_key($data);
	return $Live_Objects{$key} || $class->_fresh_init($key => $data);
}

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;
}
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.