apache / apache/shenyu

[BUG] tag_relation updateByPrimaryKeySelective sets non-existent name column instead of api_id

Closed Beginner friendly
#6,830 2 comments 0 reactions 0 assignees View on GitHub
admin priority: high type: bug
Dominant language
Java
Stars
8.8k
Forks
3.1k
Avg merge
7d 1h
Merged PRs (30d)
85

Description

## Description
`tag_relation updateByPrimaryKeySelective` contains ` name = #{apiId, jdbcType=VARCHAR}, `. The `tag_relation` table has columns `id, api_id, tag_id, date_created, date_updated` — there is **no `name` column**. When `apiId` is non-null, the generated SQL is `UPDATE tag_relation SET name = ? ...` → `Unknown column 'name'` SQL error. Reachable: `TagRelationServiceImpl.update()` calls `tagRelationMapper.updateByPrimaryKeySelective(tagRelationDO)`, and `TagRelationDO.buildTagRelationDO` populates `apiId` from the DTO.

## Location
- `shenyu-admin/src/main/resources/mappers/tag-relation-sqlmap.xml:125`
- `shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/TagRelationServiceImpl.java:54`

## Impact
Updating a tag-relation whose `apiId` is set throws a runtime SQL exception (HTTP 500) rather than performing the update; the tag-relation edit path is broken whenever apiId is supplied.

## Suggested fix
Change line 125 to `api_id = #{apiId, jdbcType=VARCHAR},`.

## Related existing
Distinct from N23 (#6692, `TagServiceImpl.delete` no cascade) and N55 (TagDTO validation). This is a wrong-column SQL defect in `tag-relation-sqlmap`.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at shenyu-admin/src/main/resources/mappers/tag-relation-sqlmap.xml:125 and compare the update mapping with the tag_relation columns listed in the issue. Trace the call from TagRelationServiceImpl.update() to confirm the affected path. Done means a non-null apiId generates an update for api_id and no longer references the nonexistent name column.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
database
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
85/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.