Does has_a() really call retrieve() ?
[prev]
[thread]
[next]
[Date index for 2004/06/15]
Doesn't seem to.
I've got retrieve() overridden in my base class, and it never gets hit doing this...
Music::CD->has_a(artist => 'Music::Artist');
print $cd->artist->name;
...where "name" is an essential column. (has_many() *does* hit retrieve, however, in a case just as simple.)
Inflating the object explicitly does cause retrieve to be hit, of course...
Music::CD->has_a(artist => 'Music::Artist', inflate => sub { Music::Artist->retrieve($_[0]) });
...but this seems not to be lazy in its behavior -- the object is inflated immediately upon retrieval -- and laziness in my particular application is crucial. (My particular application being the serialization of "cacheable" representations of CDBI objects for storage on disk.)
I wound up doing this...
sub artist { Music::Artist->retrieve($_[0]->_artist_accessor) }
...which is fine (I only need access, not mutation), but has_a is so much prettier, and I'm always leery of using starts-with-underscore methods.
Anyway, no big deal, but I was wondering: Is this a just docs issue? Or could this be a CDBI implementation oversight? Or maybe niether, and I'm just high.
Any feedback greatly appreciated, and thanks in advance for your time.
Best regards.
Todd Lorenz
|
Does has_a() really call retrieve() ?
trlorenz 00:17 on 15 Jun 2004
|