correctly decode hstore with @ in data
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 10 Jul 2011 21:45:02 +0000 (23:45 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 10 Jul 2011 21:45:02 +0000 (23:45 +0200)
lib/APKPM/Store.pm
t/Store.t

index fed5741..19aaa6c 100644 (file)
@@ -76,7 +76,10 @@ sub sql : Job : Encode(e_json) : MinProcesses(0) {
        }
        if ( defined $hash_col ) {
                map {
        }
        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
        }
 
                } @$rows
        }
 
index 0f8fa87..54d53ae 100755 (executable)
--- a/t/Store.t
+++ b/t/Store.t
@@ -2,7 +2,7 @@
 use strict;
 use warnings;
 
 use strict;
 use warnings;
 
-use Test::More tests => 9;
+use Test::More tests => 12;
 use Data::Dump qw(dump);
 
 use lib 'lib';
 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 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;
+
+}