Skip to content

fix: make mixed CRUD method directives order-independent#867

Open
014-code wants to merge 1 commit into
Tencent:masterfrom
014-code:codex/fix-809-mixed-crud-method-order
Open

fix: make mixed CRUD method directives order-independent#867
014-code wants to merge 1 commit into
Tencent:masterfrom
014-code:codex/fix-809-mixed-crud-method-order

Conversation

@014-code

Copy link
Copy Markdown
Contributor

Summary

Fixes #809.

Mixed CRUD requests containing @post, @put, or @delete could be parsed incorrectly depending on the order of fields in the JSON object.

For example, when a business object appeared before its @delete directive, the object could fall back to GET or use the method assigned to a related array entry.

Root Cause

AbstractParser.batchVerify collected method directives and processed business objects in the same loop.

Therefore, a directive only affected objects appearing after it in iteration order.

Changes

  • Pre-scan all supported method directives before processing business objects
  • Make mixed CRUD method dispatch independent of JSON field order
  • Preserve the priority of an object's explicit @method
  • Keep method directive values limited to String or JSONObject
  • Add documentation for deleting and batch inserting into the same table
  • Add regression tests for method ordering, priority, and invalid array values

Verification

  • mvn -q -f APIJSONORM/pom.xml test
  • Tests run: 3
  • Failures: 0
  • Errors: 0
  • git diff --check passed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[问题咨询] 同一个json请求中,同时新增和删除

1 participant