Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ensembl-gh-mirror
ensembl-hive
Commits
0e9b901d
Commit
0e9b901d
authored
Mar 17, 2014
by
Leo Gordon
Browse files
bugfix: make sure undefined values are mentioned as IS NULL in the filter (thanks, Matthieu!)
parent
20a13d2c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
5 deletions
+16
-5
modules/Bio/EnsEMBL/Hive/DBSQL/BaseAdaptor.pm
modules/Bio/EnsEMBL/Hive/DBSQL/BaseAdaptor.pm
+16
-5
No files found.
modules/Bio/EnsEMBL/Hive/DBSQL/BaseAdaptor.pm
View file @
0e9b901d
...
...
@@ -421,15 +421,26 @@ sub check_object_present_in_db { # return autoinc_id/undef if the table has a
my
$column_set
=
$self
->
column_set
();
my
$autoinc_id
=
$self
->
autoinc_id
();
# we look for identical contents, so must skip the autoinc_id columns when fetching:
my
$non_autoinc_columns
=
[
grep
{
$_
ne
$autoinc_id
}
keys
%$column_set
];
my
$non_autoinc_values
=
$self
->
slicer
(
$object
,
$non_autoinc_columns
);
my
$sql
=
'
SELECT
'
.
(
$autoinc_id
or
1
)
.
"
FROM
$table_name
WHERE
"
.
# we look for identical contents, so must skip the autoinc_id columns when fetching:
join
('
AND
',
map
{
my
$v
=
$non_autoinc_values
->
[
$_
];
"
$non_autoinc_columns
->[
$_
]
"
.
(
defined
(
$v
)
?
"
='
$v
'
"
:
'
IS NULL
')
}
(
0
..
@$non_autoinc_columns
-
1
)
);
my
@constraints
=
();
my
@values
=
();
foreach
my
$idx
(
0
..
scalar
(
@$non_autoinc_columns
)
-
1
)
{
my
$column
=
$non_autoinc_columns
->
[
$idx
];
my
$value
=
$non_autoinc_values
->
[
$idx
];
if
(
defined
(
$value
)
)
{
push
@constraints
,
"
$column
= ?
";
push
@values
,
$value
;
}
else
{
push
@constraints
,
"
$column
IS NULL
";
}
}
my
$sth
=
$self
->
prepare
(
$sql
);
$sth
->
execute
();
my
$sql
=
'
SELECT
'
.
(
$autoinc_id
or
1
)
.
"
FROM
$table_name
WHERE
"
.
join
('
AND
',
@constraints
);
my
$sth
=
$self
->
prepare
(
$sql
);
$sth
->
execute
(
@values
);
my
(
$return_value
)
=
$sth
->
fetchrow_array
();
$sth
->
finish
;
...
...
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