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:
- Start an instance on
v7.12.0+ and make sure the run_key_migration_functions are executed
- Execute the above SQL query to identify duplicate SpLocaleContainer records
- 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.
- Build and/or execute a query that attempts to format or aggreate the chosen table(s)
- 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
Describe the bug
The
run_key_migration_functionsis creating duplicateSpLocaleContainerrecords.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:
specify7/specifyweb/backend/stored_queries/format.py
Lines 94 to 98 in 67ea5b6
The following SQL Query can be ran to identify duplicate SpLocaleContainer records:
To Reproduce
Steps to reproduce the behavior:
v7.12.0+and make sure the run_key_migration_functions are executedCollectionObjectAttachment,DNASequenceAttribute,Determiner,PCRPerson,TaxonAttribute,DNAPrimer,Address,BorrowAgent, etc.Expected behavior
The
run_key_migration_functionsshould not be created duplicate SpLocaleContainer recordsCrash Report
Specify 7 Crash Report - 2026-04-16T18_28_31.346Z.txt
Please fill out the following information manually:
Reported By
Eric P. at Fish and Wildlife Research Institute