Skip to content

Run key migrations creating duplicate splocalecontainer records #7988

@melton-jason

Description

@melton-jason

Describe the bug
The run_key_migration_functions is creating duplicate SpLocaleContainer records.

This can result in problems in Queries where a table is supposed to be formatted or aggregated and the formatter is not defined in the DataObjFormatters (Record Formatters) file.
Specify tries to fetch the format defined on the SpLocaleContainer record, which will raise a MultipleObjectsReturned error if more than one SpLocaleContainer exists with the same name in the same discipline:

formatter_name = Splocalecontainer.objects.get(
name=specify_model.name.lower(),
schematype=0,
discipline=self.collection.discipline
).format

The following SQL Query can be ran to identify duplicate SpLocaleContainer records:

SELECT * FROM splocalecontainer spc1 JOIN splocalecontainer spc2 ON spc1.DisciplineID=spc2.DisciplineID AND spc1.SchemaType=spc2.SchemaType AND spc1.Name=spc2.Name AND spc2.SpLocaleContainerID > spc1.SpLocaleContainerID WHERE spc1.SchemaType=0 \G

To Reproduce
Steps to reproduce the behavior:

  1. Start an instance on v7.12.0+ and make sure the run_key_migration_functions are executed
  2. Execute the above SQL query to identify duplicate SpLocaleContainer records
  3. Choose a table that has a duplicate SpLocaleContainer record that is not defined in the Record Formatters app resource
  • Some duplicates I observed locally were: CollectionObjectAttachment, DNASequenceAttribute, Determiner, PCRPerson, TaxonAttribute, DNAPrimer, Address, BorrowAgent, etc.
  1. Build and/or execute a query that attempts to format or aggreate the chosen table(s)
  2. See error when executing query

Expected behavior
The run_key_migration_functions should not be created duplicate SpLocaleContainer records

Crash Report

Specify 7 Crash Report - 2026-04-16T18_28_31.346Z.txt

Please fill out the following information manually:

  • OS: macOS M3 Pro Tahoe 16.3.1
  • Browser: Google Chrome 146.0.7680.178 (Official Build) (arm64)
  • Specify 7 Version: v7.12.0.3

Reported By
Eric P. at Fish and Wildlife Research Institute

Metadata

Metadata

Assignees

No one assigned

    Labels

    1 - BugIncorrect behavior of the productregressionThis is behavior that once worked that has broken. Must be resolved before the next release.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions