Commit d668ce92 authored by Andy Yates's avatar Andy Yates
Browse files

Patching issue with there being a difference between NULL and and empty string...

Patching issue with there being a difference between NULL and and empty string WRT description and also plugged a gap in the code when we were trying to query using a display_label which the api allows to be NULL but the DB does not
parent ed534385
......@@ -893,17 +893,17 @@ sub _store_or_fetch_xref {
AND info_type = ?
AND info_text = ?
AND description';
if ($dbEntry->description) {$sql .= ' = ?'}
if (defined $dbEntry->description) {$sql .= ' = ?'}
else {$sql .= ' is NULL'}
$sth = $self->prepare( $sql );
$sth->bind_param(1, $dbEntry->primary_id,SQL_VARCHAR);
$sth->bind_param(2, $dbEntry->display_id,SQL_VARCHAR);
$sth->bind_param(3, $dbEntry->version,SQL_VARCHAR);
$sth->bind_param(2, ($dbEntry->display_id || ''),SQL_VARCHAR);
$sth->bind_param(3, $dbEntry->version ,SQL_VARCHAR);
$sth->bind_param(4, $dbRef,SQL_INTEGER);
$sth->bind_param(5, ($dbEntry->info_type || 'NONE'), SQL_VARCHAR);
$sth->bind_param(6, ($dbEntry->info_text || ''), SQL_VARCHAR);
if ($dbEntry->description) {$sth->bind_param(7, $dbEntry->description,SQL_VARCHAR);}
if (defined $dbEntry->description) {$sth->bind_param(7, $dbEntry->description,SQL_VARCHAR);}
$sth->execute();
($xref_id) = $sth->fetchrow_array();
$sth->finish;
......
......@@ -481,6 +481,22 @@ ok(@{$xrefs} == 23); #test 60
my $db_name = $dbEntryAdaptor->get_db_name_from_external_db_id(4100);
ok($db_name eq 'UniGene');
# Test multiple inserts for empty descriptions
{
$multi->hide('core', 'xref', 'object_xref');
my @basic_args = (-PRIMARY_ID => 'AAAA', -DBNAME => 'Uniprot/SWISSPROT', -RELEASE => 1);
my $entry_no_desc = Bio::EnsEMBL::DBEntry->new(@basic_args, -DESCRIPTION => q{});
my $no_desc_id = $dbEntryAdaptor->store($entry_no_desc, $gene->dbID(), 'Gene');
is_rows(1, $db, 'xref', 'where description = ?', [q{}]);
is_rows(1, $db, 'object_xref');
my $no_desc_id_again = $dbEntryAdaptor->store($entry_no_desc, $gene->dbID(), 'Gene');
is($no_desc_id_again, $no_desc_id, 'Checking the ID is consistent between store() invocations');
is_rows(1, $db, 'xref', 'where description = ?', [q{}]);
is_rows(1, $db, 'object_xref');
is_rows(0, $db, 'object_xref', 'where xref_id =?', [0]);
$multi->restore('core', 'xref', 'object_xref');
}
sub print_dbEntries {
my $dbes = shift;
......
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