Skip to content

Load Specify 7 specific tables into datamodel #2835

Closed as not planned
Closed as not planned
@melton-jason

Description

@melton-jason

Add a block for

  • spdataset

For more context, this is regarding adding a deletion blocker to SpecifyUser. This operation is not currently supported with how I extended deletion blockers, but I will add a way to support adding reverse relationships so this can be added.

Spatasets will more complicated than any other table(s) to work with on the backend. Many of Specify's internal helper functions rely on the datamodel being loaded when Specify starts up (this happens in load_datamodel.py). The issue is that to get the list of tables and fields in the database, Specify 7 reads the specify_datamodel.xml in the Specify 6 config directory (as seen below), and as far as I know the spdataset table is not included within that file.

def load_datamodel() -> Datamodel:
datamodeldef = ElementTree.parse(os.path.join(settings.SPECIFY_CONFIG_DIR, 'specify_datamodel.xml'))
datamodel = Datamodel()
datamodel.tables = [make_table(tabledef) for tabledef in datamodeldef.findall('table')]
add_collectingevents_to_locality(datamodel)
flag_dependent_fields(datamodel)
flag_system_tables(datamodel)
return datamodel

We could manually use SQL to get the correct information, but that will only be a short-term solution (which may be fine for now). Preferably, we would want to engineer a way to load/register these Specify 7 specific tables in the internal specify datamodel. (If such a way already exists and I am overlooking it, then feel free to point it out. I have checked all attributes on specify.models and spdataset does not exist)

From #2806 (comment)

It would be nice to have a proper solution to adding these tables into the Specify datamodel, this would be beneficial both for backend use (as described above) and for frontend use.
Currently in Specify 7, users are not allowed to query on these tables that are not loaded into the datamodel, which may become an issue if tables are added solely in Specify 7.

Metadata

Metadata

Assignees

No one assigned

    Labels

    1 - RequestA request made by a member of the communityres:duplicateDuplicate of an existing issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions