Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
ensembl-gh-mirror
ensembl
Commits
5dc9ba1c
Commit
5dc9ba1c
authored
Apr 26, 2012
by
Dan Staines
Browse files
altered execute_into_hash to retain elements where value is 0 (as opposed to undef)
parent
b6a81065
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
1 deletion
+12
-1
modules/Bio/EnsEMBL/Utils/SqlHelper.pm
modules/Bio/EnsEMBL/Utils/SqlHelper.pm
+1
-1
modules/t/sqlHelper.t
modules/t/sqlHelper.t
+11
-0
No files found.
modules/Bio/EnsEMBL/Utils/SqlHelper.pm
View file @
5dc9ba1c
...
...
@@ -446,7 +446,7 @@ sub execute_into_hash {
my
$key
=
$row
->
[
0
];
my
$value
=
$hash
->
{
$key
};
my
$new_value
=
$callback
->
(
$row
,
$value
);
if
(
$new_value
)
{
if
(
defined
$new_value
)
{
$hash
->
{
$key
}
=
$new_value
;
}
return
;
...
...
modules/t/sqlHelper.t
View file @
5dc9ba1c
...
...
@@ -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
');
}
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
my
$meta_table_count
=
$helper
->
execute_single_result
(
-
SQL
=>
'
select count(*) from meta
');
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment