Skip to content

Implement PATCH method for partial updates #318

Description

@nanotaboada

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) and id (UUID surrogate key).
  • Only the fields present in the request body are updated; absent fields retain their current values.
  • If the request body includes squadNumber or id, the endpoint returns 400 Bad Request.

Suggested Approach

  1. DTO — Add PlayerPatchDTO in the models package with all patchable fields as nullable (e.g. String, Boolean). Exclude squadNumber and id. Annotate with @JsonInclude(JsonInclude.Include.NON_NULL) so absent fields serialize cleanly.
  2. Service — Add boolean patch(Integer squadNumber, PlayerPatchDTO dto) in PlayersService. Retrieve the existing player, apply only the non-null fields from the DTO, then persist.
  3. Controller — Add @PatchMapping("/players/{squadNumber}") in PlayersController. Check for forbidden fields (squadNumber, id) → 400. Look up player → 404 if missing. Return ResponseEntity<Void> with HttpStatus.NO_CONTENT on success.
  4. Tests — Add unit tests following existing naming conventions.

Acceptance Criteria

  • PATCH /players/{squadNumber} is implemented
  • All fields except squadNumber and id are patchable
  • Fields absent from the request body are left unchanged
  • Returns 204 No Content on success
  • Returns 400 Bad Request if the body contains squadNumber or id
  • Returns 400 Bad Request on field validation failure
  • Returns 404 Not Found when no player has that squad number
  • Tests added following existing naming conventions
  • All existing tests continue to pass
  • CHANGELOG.md updated

References

Activity

  1. added
    enhancementNew feature or request
    javaPull requests that update Java code
    planningEnables automatic issue planning with CodeRabbit
    priority:mediumPlanned enhancement. Queue for upcoming work.
    on Apr 12, 2026
  2. Repository owner deleted a comment from coderabbitai on Apr 12, 2026
  3. removed
    planningEnables automatic issue planning with CodeRabbit
    on Apr 12, 2026
  4. changed the title [-]Implement `PATCH` method for partial player updates[/-] [+]Implement `PATCH` method for partial updates[/+] on Apr 12, 2026
  5. pinned this issue on Apr 19, 2026
  6. the-Sunny-Sharma commented on May 9, 2026

    @the-Sunny-Sharma

    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.

  7. the-Sunny-Sharma commented on May 9, 2026

    @the-Sunny-Sharma

    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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestjavaPull requests that update Java codepriority:mediumPlanned enhancement. Queue for upcoming work.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions