Re: Using TEMP columns when the object is already in memory
[prev]
[thread]
[next]
[Date index for 2004/05/12]
--=-EIHlMUBKl1jmX9In18Qt
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
On Wed, 2004-05-12 at 10:17, Mark Hughes wrote:
> If you already have a copy of an artist in memory then the cds value for
> this artist will be undefined as Class::DBI will use the existing object .
>
> I'm getting around this by calling remove_from_object_index() on the
> object already in memory before calling the _search method.
Interesting. This query is sort of a cheat, since it involves making a
special constructor that fetches information the normal constructor
doesn't know about. However, it is a documented cheat.
I think we could fix this with a little change to _init(). Want to give
this patch a try? There is some danger introduced here in that it would
allow you to overwrite unsaved data in an instance in memory. Maybe it
should check for that too.
- Perrin
--=-EIHlMUBKl1jmX9In18Qt
Content-Disposition: attachment; filename=DBI.pm.patch
Content-Type: text/x-patch; name=DBI.pm.patch; charset=
Content-Transfer-Encoding: 7bit
--- /usr/lib/perl5/site_perl/5.8.3/Class/DBI.pm 2004-04-30 03:22:12.000000000 -0400
+++ /home/perrin/DBI.pm 2004-05-12 13:00:31.000000000 -0400
@@ -523,7 +523,7 @@
sort @primary_columns;
}
- unless (defined($obj = $Live_Objects{$obj_key})) {
+ if (!defined($obj = $Live_Objects{$obj_key})) {
# not in the object_index, or we don't have all keys yet
$obj = bless {}, $class;
@@ -537,7 +537,10 @@
$class->purge_dead_from_object_index
if ++$Init_Count % $class->purge_object_index_every == 0;
}
- }
+ } else {
+ # fill in any extra data we were passed
+ $obj->_attribute_store(%$data);
+ }
return $obj;
}
--=-EIHlMUBKl1jmX9In18Qt--
|
|
Re: Using TEMP columns when the object is already in memory
Perrin Harkins 17:04 on 12 May 2004
|