diff --git a/modules/Bio/EnsEMBL/DBSQL/DBEntryAdaptor.pm b/modules/Bio/EnsEMBL/DBSQL/DBEntryAdaptor.pm index 29942c95f527c835297540eab15329469ab66bdd..d19ed7c5349caa76e14e45795673adc194bd447e 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 5e7968a6c9254a77f5ca7cd2bdcd1bbfca918c93..174a230094979ca89bfc39362dd95d3beacc227d 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'); diff --git a/modules/t/gene.t b/modules/t/gene.t index 80ca5b64f4cdb265ab927086f32f596c1980ab53..65e330555b5b3c1007df952c6007f74d767ae426 100644 --- a/modules/t/gene.t +++ b/modules/t/gene.t @@ -589,10 +589,13 @@ ok(scalar(@genes) == 4); debug("Wildcard test:" . $genes[0]->stable_id); ok($genes[0]->stable_id() eq 'ENSG00000101367'); -@genes = @{$ga->fetch_all_by_external_name('M_%')}; -debug("Wildcard test:" . $genes[0]->stable_id()); -debug(scalar @genes . " genes found"); -ok(scalar @genes == 2); +SKIP: { + skip 'Wildcard behaviour different for SQLite', 1 if $db->dbc->driver() eq 'SQLite'; + @genes = @{$ga->fetch_all_by_external_name('M_%')}; + debug("Wildcard test:" . $genes[0]->stable_id()); + debug(scalar @genes . " genes found"); + ok(scalar @genes == 2); +} # Test performance protection (very vague queries return no hits) debug("Testing vague query protection"); diff --git a/sql/patch_94_95_c.sql b/sql/patch_94_95_c.sql new file mode 100644 index 0000000000000000000000000000000000000000..79c4cdc5e654152f4cab73745ebc86013b861a03 --- /dev/null +++ b/sql/patch_94_95_c.sql @@ -0,0 +1,29 @@ +-- Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute +-- Copyright [2016-2018] EMBL-European Bioinformatics Institute +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. + +# patch_94_95_c.sql +# +# Title: Remove analysis_id from unique key constraint +# +# Description: +# Not all object_xref have an analysis, remove analysis_id from unique key constraint + +ALTER TABLE object_xref + DROP INDEX xref_idx, + ADD UNIQUE KEY xref_idx (xref_id, ensembl_object_type, ensembl_id); + +# Patch identifier +INSERT INTO meta (species_id, meta_key, meta_value) + VALUES (NULL, 'patch', 'patch_94_95_c.sql|ox_key_update'); diff --git a/sql/table.sql b/sql/table.sql index 63b56773ca238afa050ab593edbcbf9106eff3b0..51eaab949796bf349b725fb43972011da336ed6e 100755 --- a/sql/table.sql +++ b/sql/table.sql @@ -319,6 +319,9 @@ INSERT INTO meta (species_id, meta_key, meta_value) INSERT INTO meta (species_id, meta_key, meta_value) VALUES (NULL, 'patch', 'patch_94_95_b.sql|vertebrate_division_rename'); +INSERT INTO meta (species_id, meta_key, meta_value) + VALUES (NULL, 'patch', 'patch_94_95_c.sql|ox_key_update'); + /** @table meta_coord @@ -2325,7 +2328,7 @@ CREATE TABLE object_xref ( PRIMARY KEY (object_xref_id), - UNIQUE KEY xref_idx (xref_id, ensembl_object_type, ensembl_id, analysis_id), + UNIQUE KEY xref_idx (xref_id, ensembl_object_type, ensembl_id), KEY ensembl_idx (ensembl_object_type, ensembl_id), KEY analysis_idx (analysis_id)