Taxa pointing to the same name objects, or having the same name_cache value #182

Open
jonkerz opened this Issue Dec 7, 2016 · 0 comments

Comments

Projects
None yet
1 participant
Member

jonkerz commented Dec 7, 2016

I'm not sure what to do here, but this will be linked from two upcoming database scripts.


Two or more taxa can have the same Taxon#name_cache because:

  • The taxa are homonyms (valid reason).
  • More than one taxa are linked to the same Name object (we may want to not allow this).
  • The taxon's Taxon#name_cache has not been updated (it should be).

Background

  • All taxa have a Taxon#name_id, which points to a Name object.
  • All Name objects have a Name#name, which is the plain-text version of the full name.
  • All taxa also have a Taxon#name_cache, which is a cached copy the plain-text version.

Why this matters

Code that looks up taxa by Taxon#name_cache picks the first name it finds. In most cases it's not possible to tell that this has happened, so in this sense it doesn't matter. In many other situations it simply works anyways, because the code picks the taxon with the lowest ID, which usually happens to be the correct taxon.

Example: if you add Camponotus atra as a synonyms to a species, the code will pick http://antcat.org/catalog/432028 and not http://antcat.org/catalog/432029, because the former has a lower ID.

Where this is an issue:

  • Species#become_subspecies_of (convert to subspecies button)
  • Subspecies#elevate_to_species (elevate to species button)
  • TaxonDecorator::Headline#headline_type_name (displays the type name in the catalog)
  • SynonymsController#create (for the synonyms section in the 'edit taxon' form)
  • NameFieldsController and NamePopupsController.

The problem with reusing Name objects is that this means that changes to the name of one of the taxa changes it for all other at the same time.

@jonkerz jonkerz added a commit to jonkerz/antcat that referenced this issue Dec 8, 2016

@jonkerz jonkerz New database scripts x 2: 'Taxa with the same name (object|cache valu…
…e)'. See #182.
0e41437
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment