Qikuyueser.com

PUT vs PATCH for Partial Updates

Added 2026-10

PUT vs PATCH for Partial Updates — Chinese original prompt

这个更新接口 [接口名] 用同一种请求体处理整体替换和字段修改,客户端漏传字段时会被当成置空。请区分两种语义,明确哪些字段可空、哪些字段缺省表示不修改、哪些必须整体提交。输出:接口语义说明、请求体字段表(必填、可空、缺省含义)、客户端调用建议、以及历史数据的兼容处理。
Site original

Chinese original

Open in ChatGPT

Example

Sample input

更新接口用同一个请求体处理整体替换和字段修改,客户端漏传就变置空,帮我区分两种语义。

The output should include

  • 两种语义分开说明并给字段表
  • 标出可空与缺省不修改的字段
  • 历史数据的兼容处理给做法

Replace these placeholders 1

Swap the bracketed parts for your own details before sending.

  • [接口名]
How to use

「缺省」和「显式置空」必须能区分,否则这个坑永远修不干净。

Try tweaking it

  • Have it restate requirements and constraints before writing code.
  • Ask for the smallest change plus a rollback path, not a full-file rewrite.

What you should get

  • A minimal, runnable change with copy-ready code
  • Impact list: which files and call sites must follow

Common mistakes

  • Asking it to touch ten files at once, then losing track of what broke what.
  • Pasting only the error, with no code or version, and getting an unfixable answer.

How to check the output

  • The change runs, can be rolled back, and touches nothing unrelated.
  • Edge cases (empty, oversized, concurrent) are covered or explained.

Where it works

  • Good for: having it restate requirements and constraints, then propose the smallest runnable change.
  • Watch out: include versions and a minimal reproduction with the error, or the fix may look plausible but not fit.

More in this topic