From 981e886549c990c4ea7a024d3759138de377f73e Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sun, 10 Jul 2011 23:45:02 +0200 Subject: [PATCH] correctly decode hstore with @ in data --- lib/APKPM/Store.pm | 5 ++++- t/Store.t | 15 ++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) 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; + +} -- 2.20.1