From: Michael G Schwern Date: Wed, 16 Jan 2008 08:17:30 +0000 (-0800) Subject: freeze/thaw/dclone as functions can't be made to reliably work. I'll X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7244b45f10a538d98bdc576b8bac9e3cc8647a7f;p=dbsrgits%2FDBIx-Class-Historic.git freeze/thaw/dclone as functions can't be made to reliably work. I'll have to change the calling code in my app. --- diff --git a/lib/DBIx/Class/Serialize/Storable.pm b/lib/DBIx/Class/Serialize/Storable.pm index 5795293..d904c0b 100644 --- a/lib/DBIx/Class/Serialize/Storable.pm +++ b/lib/DBIx/Class/Serialize/Storable.pm @@ -11,13 +11,13 @@ sub STORABLE_freeze { delete $to_serialize->{related_resultsets}; delete $to_serialize->{_inflated_column}; - return('', $to_serialize); + return (Storable::freeze($to_serialize)); } sub STORABLE_thaw { - my ($self, $cloning, $junk, $obj) = @_; + my ($self, $cloning, $serialized) = @_; - %$self = %{ $obj }; + %$self = %{ Storable::thaw($serialized) }; $self->result_source($self->result_source_instance) if $self->can('result_source_instance'); } diff --git a/t/84serialize.t b/t/84serialize.t index 51c7e56..0819d8c 100644 --- a/t/84serialize.t +++ b/t/84serialize.t @@ -9,8 +9,11 @@ use Storable qw(dclone freeze thaw); my $schema = DBICTest->init_schema(); my %stores = ( - dclone => sub { return dclone($_[0]) }, - "freeze/thaw" => sub { return thaw(freeze($_[0])) }, + dclone_method => sub { return $schema->dclone($_[0]) }, + "freeze/thaw_method" => sub { + my $ice = $schema->freeze($_[0]); + return $schema->thaw($ice); + }, ); plan tests => (7 * keys %stores); @@ -34,6 +37,6 @@ for my $name (keys %stores) { qq[serialize with related_resultset "$key"]); } - ok eval { $copy->discard_changes; 1 }; + ok eval { $copy->discard_changes; 1 } or diag $@; is($copy->id, $artist->id, "IDs still match "); }