fix(admin): tag_relation updateByPrimaryKeySelective sets non-existent name column - #6907
Open
yangjj-iso wants to merge 4 commits into
Open
Conversation
…t name column
The apiId branch emitted `name = #{apiId}`, but tag_relation only has
id, api_id, tag_id, date_created and date_updated. Updating a tag
relation with an apiId therefore failed with a SQL grammar error
instead of performing the update. The sibling updateByPrimaryKey
already uses api_id.
Add a TagRelationMapperTest case for updateByPrimaryKeySelective, which
was the only mapper method left uncovered by that test class.
Fixes apache#6830
Co-authored-by: Cursor <cursoragent@cursor.com>
Aias00
approved these changes
Aug 14, 2026
Aias00
left a comment
Contributor
There was a problem hiding this comment.
Review: #6907 — fix(admin): tag_relation updateByPrimaryKeySelective sets non-existent name column
Verdict: ✅ Approve
Textbook copy-paste bug fix for #6830.
What's correct
- The column genuinely doesn't exist. I verified the
tag_relationDDL (db/init/oracle/schema.sql): columns areid, api_id, tag_id, date_created, date_updated. There is noname. SoUPDATE tag_relation SET name = ?always threw aBadSqlGrammarwhenever a request carried anapiId— exactly the reported failure onPUT /tag-relation/id/{id}. - Fix targets the right column.
name→api_idmatches the siblingupdateByPrimaryKeyin the same mapper, which already usesapi_id. That sibling statement is the strongest evidence this was a copy-paste defect, not intent. - Regression test pins the defect.
testUpdateByPrimaryKeySelectivewas the only uncovered mapper method (which is why the bug slipped through). It inserts a row, updatesapiId, asserts persistence, then deletes the row to avoid perturbing the count-based sibling tests. The PR description shows it failing withBadSqlGrammarwhen the mapper change is reverted — proper proof that the test is meaningful.
Non-blocking suggestions
- This same
name = #{apiId}typo pattern could exist in other*sqlmap.xmlfiles (the PR notes it's a copy-paste class of bug). A quick repo-wide grep forname = #{...Idagainst tables without anamecolumn would be a cheap follow-up to catch siblings — but that's out of scope for this PR. buildTagRelationDOalways populatesapiIdfrom the DTO, so the<if test="apiId != null">branch fires on essentially every update. Not a problem with this fix, just noting the branch is effectively always-on.
Verdict
Approving. One-line, verifiably-correct, test-backed. Merge as-is.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6830
Problem
tag-relation-sqlmap.xmlline 125 emitsname = #{apiId, jdbcType=VARCHAR}in theapiIdbranch ofupdateByPrimaryKeySelective, buttag_relationonly has the columnsid,api_id,tag_id,date_createdanddate_updated. There is nonamecolumn.This is reachable from the REST layer:
PUT /tag-relation/id/{id}→TagRelationController.updateTagRelation→TagRelationServiceImpl.update→TagRelationDO.buildTagRelationDO, which always populatesapiIdfrom the DTO. Whenever the request body carries anapiId, the<if>branch fires and the statement becomesUPDATE tag_relation SET name = ? ..., which fails with a SQL grammar error instead of performing the update.The sibling
updateByPrimaryKeyin the same mapper (line 137) already usesapi_id, which confirms this is a copy-paste defect rather than intent.Change
tag-relation-sqlmap.xml:name→api_idinupdateByPrimaryKeySelective.TagRelationMapperTest: addtestUpdateByPrimaryKeySelective. This was the onlyTagRelationMappermethod the test class did not cover, which is why the defect went unnoticed. The test inserts a row, updatesapiId, asserts the new value is persisted, and deletes the row so it does not perturb the sibling tests that assert on row counts.Verification
Run against JDK 17 (matching the CI matrix):
With the fix applied:
With the mapper change reverted and only the new test in place, to confirm the test actually pins the defect:
Make sure that:
./mvnw -pl shenyu-admin -am -DskipTests installfollowed by./mvnw -pl shenyu-admin test -Dtest=TagRelationMapperTestwith Checkstyle enabled, rather than a full-reactorclean install. The change touches a single MyBatis statement inshenyu-admin, so no other module is affected.