[Dbix-class] how to tell if related has been loaded?

Mark Hedges hedges at formdata.biz
Tue May 3 07:23:25 GMT 2011


Hi all,

In my result class I added a row object method that returns
a legacy object with the base data populated.

That legacy object has a method to get at some related table
data with direct SQL.  Not every use of the object requires
that data to be loaded.

Suppose in one case the row object came from a result set
with a gigantic prefetch that cached all the related data.

In the row object method, how do I tell whether the related
objects have been populated already, without calling the
DBIC relationship accessor, which would execute an extra
query if not loaded?  If I can tell from the row object
whether or not the related entities are already there, I can
go ahead and populate the legacy object's related data
cache.

Mark



More information about the DBIx-Class mailing list