Closed LordFlashmeow closed 3 years ago
@LordFlashmeow I pushed a change, do you have means to test it? I also put a test in spec_combination.rb
but not sure if it catches what you experienced.
specify '.matching_protonyms 6' do
species.update(original_genus: genus, original_subgenus: genus, original_species: species)
species2.update(original_genus: genus, original_species: species, original_subspecies: species2)
tr = TaxonNameRelationship.create(subject_taxon_name: species2, object_taxon_name: species, type: 'TaxonNameRelationship::Iczn::Invalidating::Synonym')
expect(Combination.matching_protonyms(nil, genus: genus.id, species: species.id).to_a).to contain_exactly()
end
@LordFlashmeow Sorry was wrong test. Replicated it. It is fixed now.
Describe the bug
A clear and concise description of what the bug is.
Combination.protonyms_matching_original_relationships
fails to find original relationships when the species (object_taxon_name
) has otherTaxonNameRelationships
besides theOriginalCombination
ones.As you can see below, the query does not take into account other relationships the protonym may have.
https://github.com/SpeciesFileGroup/taxonworks/blob/26246656ef8fbcc611a085c72a4fcbd6a47c5081/app/models/combination.rb#L222
The SQL query looks like this—notice the
HAVING COUNT
line: