Skip Menu |

This queue is for tickets about the Tangram CPAN distribution.

Report information
The Basics
Id: 27330
Status: patched
Priority: 0/
Queue: Tangram

Owner: daveh [...]
Requestors: nomad [...]

Bug Information
Severity: (no value)
Broken in: 2.10_01
Fixed in: (no value)

Subject: [PATCH] Tangram::Type::Dump::Perl fails to import self-referentials
Date: Tue, 29 May 2007 17:39:22 +0200 (CEST)
To: bug-Tangram [...]
From: Mark Lawrence <nomad [...]>
Download (untitled) / with headers
text/plain 1.8k
Hi Sam, I've run into a bug with 'perl_dump' types. When 'eval'ing the column retrieved from the storage, Tangram/Type/Dump/ uses something equivalent to the following: my $obj = eval $expr; However HASHes that are self referential are Dumped using more than one statement because we necessarily set the Data::Dumper::Purity flag: The default output of self-referential structures can be "eval"ed, but the nested references to $VARn will be undefined, since a recursive structure cannot be constructed using one Perl statement. You should set the "Purity" flag to 1 to get additional statements that will correctly fill in these references. Since "eval {1;2;}" returns the value of the last statement (instead of the first) we don't get what we expected. The following patch fixes this, while maintaining behaviour for plain HASHes. Cheers, Mark. Fix Tangram::Type::Dump::Perl to handle self-referential objects. --- commit 110879178cc3f2dd754af30e6c3e8f1fd46b83d7 tree 67b8d8071a02a7ced00e79f86acf3975b16bf153 parent 9ac7bac01b37a1b40c8facea1bb5d2699816f4bb author Mark Lawrence <> Tue, 29 May 2007 17:36:47 +0200 committer Mark Lawrence <> Tue, 29 May 2007 17:36:47 +0200 lib/Tangram/Type/Dump/ | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/lib/Tangram/Type/Dump/ b/lib/Tangram/Type/Dump/ index f8bcb8b..b39e3ee 100644 --- a/lib/Tangram/Type/Dump/ +++ b/lib/Tangram/Type/Dump/ @@ -69,7 +69,9 @@ sub reschema { sub get_importer { my ($self, $context) = @_; - return("\$obj->{$self->{name}} = eval shift \@\$row;" + return("undef \$_t::v1;" + ."my \$val = eval shift \@\$row;" + ."\$obj->{$self->{name}} = \$_t::v1 || \$val;" ."Tangram::Type::Dump::unflatten(\$context->{storage}, " ."\$obj->{$self->{name}})"); } -- Mark Lawrence

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to