[CDBI] Re: Inflating/deflating with Storable

Edward J. Sabol sabol at alderaan.gsfc.nasa.gov
Fri Feb 17 23:02:20 GMT 2006


> I want to store an *arbitrary* Perl data structure in a column of type
> BLOB (random variable-length binary data). This is easy to do by
> serializing/deserializing the data with Storable::freeze/thaw. I would
> like to make the data automatically inflate/deflate with Class::DBI.
>
> The problem is that the output of the freeze() function is simply a
> string, and the output of thaw() can have pretty much any type at all.
> Class::DBI::Relationship::HasA doesn't like this state of affairs since
> it expects a specific class.

I haven't done anything like this, but I can think of two solutions:

1. Define your own relationship class that works just like HasA, except it
   doesn't care about the class of the object after inflation. Just copy the
   HasA.pm and change what you need to change, or subclass it in some
   fashion, if possible. This assumes that the problem is really with
   Class::DBI::Relationship::HasA and not Class::DBI itself.

2. Use a container class and inflate to that. The container object would
   always be of the same class, and it would contain the actual object of
   arbitrary class that you serialized into the blob.

Hope this helps,
Ed




More information about the ClassDBI mailing list