Repository navigation
Implement PATCH method for partial updates #318
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or requestjavaPull requests that update Java codePull requests that update Java codepriority:mediumPlanned enhancement. Queue for upcoming work.Planned enhancement. Queue for upcoming work.
Description
Problem
The API supports PUT for player updates, which requires sending the complete player payload even when only one or two fields need to change. A PATCH endpoint would allow callers to update specific fields without providing the entire resource.
Proposed Solution
Add PATCH /players/{squadNumber} for partial updates (following the existing PUT and DELETE URL convention in this repo).
- All fields are patchable except
squadNumber(natural key, present in the URL path) andid(UUID surrogate key). - Only the fields present in the request body are updated; absent fields retain their current values.
- If the request body includes
squadNumberorid, the endpoint returns400 Bad Request.
Suggested Approach
- DTO — Add
PlayerPatchDTOin the models package with all patchable fields as nullable (e.g.String,Boolean). ExcludesquadNumberandid. Annotate with@JsonInclude(JsonInclude.Include.NON_NULL)so absent fields serialize cleanly. - Service — Add
boolean patch(Integer squadNumber, PlayerPatchDTO dto)inPlayersService. Retrieve the existing player, apply only the non-null fields from the DTO, then persist. - Controller — Add
@PatchMapping("/players/{squadNumber}")inPlayersController. Check for forbidden fields (squadNumber,id) →400. Look up player →404if missing. ReturnResponseEntity<Void>withHttpStatus.NO_CONTENTon success. - Tests — Add unit tests following existing naming conventions.
Acceptance Criteria
-
PATCH /players/{squadNumber}is implemented - All fields except
squadNumberandidare patchable - Fields absent from the request body are left unchanged
- Returns
204 No Contenton success - Returns
400 Bad Requestif the body containssquadNumberorid - Returns
400 Bad Requeston field validation failure - Returns
404 Not Foundwhen no player has that squad number - Tests added following existing naming conventions
- All existing tests continue to pass
-
CHANGELOG.mdupdated
References
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestjavaPull requests that update Java codePull requests that update Java codepriority:mediumPlanned enhancement. Queue for upcoming work.Planned enhancement. Queue for upcoming work.
Activity
[-]Implement `PATCH` method for partial player updates[/-][+]Implement `PATCH` method for partial updates[/+]the-Sunny-Sharma commentedon May 9, 2026
Hi @nanotaboada, I'd like to work on this. I'll implement PATCH /players/{squadNumber} following the suggested approach — PlayerPatchDTO, service patch() method, controller mapping, and unit tests. Will submit a PR shortly.
the-Sunny-Sharma commentedon May 9, 2026
Hi @nanotaboada, I've submitted PR #329 implementing the PATCH /players/{squadNumber} endpoint as described. All 41 existing tests pass. Please let me know if you'd like any changes. Happy to iterate!
chore: resolve merge conflict in CHANGELOG.md with master