warn "# $rows rows get_username_table $workload\n";
+ $rows = $sth->fetchall_arrayref;
+ my @columns = @{ $sth->{NAME} };
+
+ # decode hash column
+ my $hash_col;
+ foreach ( 0 .. $#columns ) {
+ $hash_col = $_ if $columns[$_] eq 'h';
+ }
+ if ( defined $hash_col ) {
+ map {
+ $_->[$hash_col] = eval '{ ' . $_->[$hash_col] . ' }';
+ } @$rows
+ }
+
return {
- columns => $sth->{NAME},
- rows => $sth->fetchall_arrayref,
+ columns => \@columns,
+ rows => $rows,
+ hash_col => $hash_col,
};
}
use strict;
use warnings;
-use Test::More tests => 7;
+use Test::More tests => 9;
use Data::Dump qw(dump);
use lib 'lib';
ok my $o = APKPM::Store->new, 'new';
-ok my $r = $o->insert('job',{
-_table => 'adsl',
-ip => '127.0.0.1',
-username => 'nobody',
-ATTNRX => "36.5",
-ATTNTX => "17.8",
-MAXRX => 13500,
-MAXTX => 880,
-PWRRX => "0.0",
-PWRTX => "12.6",
-RX => 8500,
-SNRRX => "11.4",
-SNRTX => "16.0",
-TX => 798,
-}), 'ADSL';
-diag dump($r);
-
ok my $r = $o->insert('job',{
_table => 'ping',
ip => '127.0.0.1',
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;
+