From: Dobrica Pavlinusic Date: Sun, 10 Jul 2011 21:45:02 +0000 (+0200) Subject: correctly decode hstore with @ in data X-Git-Url: http://git.rot13.org/?p=APKPM.git;a=commitdiff_plain;h=981e886549c990c4ea7a024d3759138de377f73e correctly decode hstore with @ in data --- diff --git a/lib/APKPM/Store.pm b/lib/APKPM/Store.pm index fed5741..19aaa6c 100644 --- a/lib/APKPM/Store.pm +++ b/lib/APKPM/Store.pm @@ -76,7 +76,10 @@ sub sql : Job : Encode(e_json) : MinProcesses(0) { } if ( defined $hash_col ) { map { - $_->[$hash_col] = eval '{ ' . $_->[$hash_col] . ' }'; + my $hash = $_->[$hash_col]; + $hash =~ s/\@/\\\@/g; + $_->[$hash_col] = eval "{ $hash }"; + $_->[$hash_col] = "ERROR: $@ for $hash" if $@; } @$rows } diff --git a/t/Store.t b/t/Store.t index 0f8fa87..54d53ae 100755 --- a/t/Store.t +++ b/t/Store.t @@ -2,7 +2,7 @@ use strict; use warnings; -use Test::More tests => 9; +use Test::More tests => 12; use Data::Dump qw(dump); use lib 'lib'; @@ -26,8 +26,13 @@ ok my $r = $o->sql('job', "select xx from fake"), 'sql with error'; ok exists $r->{error}, 'error'; diag dump($r); -ok my $r = $o->sql('job', "select * from cpe_Davolink limit 1"), 'cpe_Davolink'; -ok( $r->{hash_col}, 'hash_col' ); -isa_ok $r->{rows}->[0]->[ $r->{hash_col} ], 'HASH', 'hstore column'; -diag dump $r; +foreach my $cpe_table ( qw(cpe_Davolink cpe_EasyGateway) ) { + + diag $cpe_table; + ok my $r = $o->sql('job', "select * from $cpe_table limit 1"), $cpe_table; + ok( $r->{hash_col}, 'hash_col' ); + isa_ok $r->{rows}->[0]->[ $r->{hash_col} ], 'HASH', 'hstore column'; + diag "$cpe_table ",dump $r; + +}