[Dbix-class] Storable freeze/thaw on a column?
Jess Robinson
castaway at desert-island.demon.co.uk
Mon Nov 27 18:32:10 GMT 2006
Except it won't for much longer, as we're making the values to/from
inflate/deflate insist on being blessed() objects.
Though I'm pretty sure one of them did already, so do freeze/thaw return
objects, or something?
Jess
On Sun, 26 Nov 2006, Mike Friedman wrote:
> On 11/26/06, Ash Berlin <ash at cpan.org> wrote:
>
>> InflateColumn is for going to/from an object for a given column. I.e.
>> turn datetime column into a DateTime object on read, and from DateTime
>> object to datetime column (str value) on write.
>
>
>
> Ah, OK. That makes sense.
>
> However for blobs I was under the impression that it would Just Work.
>> i.e. you'd get a scalar value with your data in.
>
>
>
> Unfortunately, I wasn't able to get it to Just Work; passing a reference to
> a blob column mutator just causes the stringification to be stored in the
> column. But after looking at the docs for InflateColumn, I was able to get
> this to work:
>
> use Storable qw(freeze thaw);
>
> __PACKAGE__->inflate_column(
> myblobcol => {
> inflate => sub { thaw( shift ) },
> deflate => sub { freeze( shift ) }
> }
> );
>
>
> Most excellent!
>
> Thanks,
>
>
> Mike
>
>
More information about the Dbix-class
mailing list