From 0799dabab7cad62992b681bb7418002eb5e1bb5c Mon Sep 17 00:00:00 2001 From: Magali Ruffier <mr6@ebi.ac.uk> Date: Wed, 17 Oct 2018 17:21:53 +0100 Subject: [PATCH] ENSCORESW-2903: remove default 0 analysis_id, should be NULL --- modules/Bio/EnsEMBL/DBSQL/DBEntryAdaptor.pm | 2 -- modules/t/dbEntries.t | 8 +++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/modules/Bio/EnsEMBL/DBSQL/DBEntryAdaptor.pm b/modules/Bio/EnsEMBL/DBSQL/DBEntryAdaptor.pm index 29942c95f5..d19ed7c534 100644 --- a/modules/Bio/EnsEMBL/DBSQL/DBEntryAdaptor.pm +++ b/modules/Bio/EnsEMBL/DBSQL/DBEntryAdaptor.pm @@ -790,8 +790,6 @@ sub _store_object_xref_mapping { my $analysis_id; if ( $dbEntry->analysis() ) { $analysis_id = $self->db()->get_AnalysisAdaptor->store( $dbEntry->analysis() ); - } else { - $analysis_id = 0; ## This used to be undef, but uniqueness in mysql requires a value } my $insert_ignore = $self->insert_ignore_clause(); diff --git a/modules/t/dbEntries.t b/modules/t/dbEntries.t index 5e7968a6c9..174a230094 100644 --- a/modules/t/dbEntries.t +++ b/modules/t/dbEntries.t @@ -554,12 +554,18 @@ $multi->restore(); 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(2, $db, 'object_xref'); is_rows(0, $db, 'object_xref', 'where xref_id =?', [0]); $multi->restore('core', 'xref', 'object_xref'); } +# Test storing with no analysis + +my $dbentry = Bio::EnsEMBL::DBEntry->new(-PRIMARY_ID => 'my_id', -DBNAME => 'EntrezGene', -RELEASE => 1); +$xref_id = $dbEntryAdaptor->store($dbentry, $gene->dbID(), 'Gene'); +is_rows("1", $db, "object_xref", "where xref_id = $xref_id and analysis_id is null"); + # Test for external DB ids { is($dbEntryAdaptor->get_external_db_id('RFAM', 1), 4200, 'RFAM ID as expected'); -- GitLab