IQSS / IQSS/dataverse

Template deletion not possible if at least one dataset uses it

Open
#11,008 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Type: Bug
Dominant language
Java
Stars
1.1k
Forks
564
Avg merge
2d 2h
Merged PRs (30d)
29

Description

It is not possible to delete a template when it is used by one or more datasets.

The delete button is present and clickable:

Capture d’écran du 2024-11-08 16-00-26

After a deletion request, nothing is deleted from the interface, but an error appears in the server logs:

Local Exception Stack: 
Exception [EclipseLink-4002] (Eclipse Persistence Services - 4.0.1.payara-p1.v202304041433): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: update or delete on table "template" violates foreign key constraint "fx_dataset_template_id" on table "dataset"
  Detail: Key (id)=(222) is still referenced from table "dataset".
Error Code: 0
Call: DELETE FROM TEMPLATE WHERE (ID = ?)
	bind => [1 parameter bound]
Query: DeleteObjectQuery(edu.harvard.iq.dataverse.Template@de)

Proposed solution:

when deleting a template, set the template_id of the dataset and datasetfield to null.
The SQL constraint will be respected and the deletion can be performed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the template deletion path and the PostgreSQL foreign-key error described in the issue. Trace how dataset and datasetfield references to the template are handled, then verify that deletion clears those references and removes the template without violating the constraint.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, postgresql
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.