Adding the "existing" side of a self relationship breaks the relationship
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 970
- Forks
- 486
- Avg merge
- 3d 33m
- Merged PRs (30d)
- 170
Description
Parent Issue
No response
Problem Statement
When a user adds a relationship field to match an existing self-related field in the same content type, the relationship record in the database is broken, and a duplicate relationship is created. This problem generates inconsistent results in the data, showing duplicate records and sometimes linking related content to the wrong relationship field.
Steps to Reproduce
- Create a content type
- Add a relationship field to itself
- Add another relationship field, but this time, choose "Existing" and select the field created in 2
If you go to the database and query the relationship table, you will notice that 2 relationships were created instead of 1. Relating a self-relationship's "existing" side should work the same way it does for non-self-related fields. The relationship record in the database must be updated instead of creating a second one
Acceptance Criteria
Adding the "existing" side of a self-relationship should not create duplicates in the relationship table. The field parent_relation_name in the existing relationship should be updated instead of creating a new relationship record.
Important note: As part of the fix, we have to make sure that pushing a content type (using PP or dotCLI) with a self-related field is working as expected, especially after adding an "existing" side of the relationship (which would require an additional push to update)
dotCMS Version
25.03.04
Proposed Objective
Please Select
Proposed Priority
Please Select
External Links... Slack Conversations, Support Tickets, Figma Designs, etc.
No response
Assumptions & Initiation Needs
No response
Quality Assurance Notes & Workarounds
No response
Sub-Tasks & Estimates
No response
Parent: #31604
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Begin by reproducing the self-related content type flow and inspecting the relationship table after selecting the existing field. Trace the content-type push paths for PP and dotCLI, including the additional push required after adding the existing side. Done means the existing relationship is updated through both flows without duplicate records or incorrect field links.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100