Commit 5dc9ba1c authored by Dan Staines's avatar Dan Staines
Browse files

altered execute_into_hash to retain elements where value is 0 (as opposed to undef)

parent b6a81065
...@@ -446,7 +446,7 @@ sub execute_into_hash { ...@@ -446,7 +446,7 @@ sub execute_into_hash {
my $key = $row->[0]; my $key = $row->[0];
my $value = $hash->{$key}; my $value = $hash->{$key};
my $new_value = $callback->($row, $value); my $new_value = $callback->($row, $value);
if($new_value) { if(defined $new_value) {
$hash->{ $key } = $new_value; $hash->{ $key } = $new_value;
} }
return; return;
......
...@@ -108,6 +108,17 @@ is($meta_count_hash->{$meta_key}, 1, 'Checking hash comes back correctly'); ...@@ -108,6 +108,17 @@ is($meta_count_hash->{$meta_key}, 1, 'Checking hash comes back correctly');
is_deeply($explicit_hash, $expected_hash, 'Checking HASH building allows for callbacks with same data structure with undef returns'); is_deeply($explicit_hash, $expected_hash, 'Checking HASH building allows for callbacks with same data structure with undef returns');
} }
my $zero_count_hash = $helper->execute_into_hash(
-SQL => 'select 1,0'
);
is($zero_count_hash->{1}, 0, 'Checking hash contains key for zero value');
my $null_count_hash = $helper->execute_into_hash(
-SQL => 'select 1,NULL'
);
ok(!exists $null_count_hash->{1}, 'Checking hash doesnt contain key for NULL value');
#TRANSACTION() CHECKS #TRANSACTION() CHECKS
my $meta_table_count = $helper->execute_single_result(-SQL => 'select count(*) from meta'); my $meta_table_count = $helper->execute_single_result(-SQL => 'select count(*) from meta');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment