fix: preserve alert receiver fields during partial updates (#6711) - #7038
juicewcode wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new selective MyBatis update binds accessToken as jdbcType=TINYINT despite being a String/VARCHAR, which can cause incorrect updates or runtime SQL type conversion errors.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR addresses #6711 by preventing partial alert receiver updates from overwriting omitted columns with NULL, switching the admin update path to a selective MyBatis update and making enable/matchAll nullable so “not provided” can be preserved.
Changes:
- Use
updateByPrimaryKeySelectivefor alert receiver updates and add the corresponding mapper method + dynamic SQL. - Convert
enableandmatchAllfrom primitivebooleanto nullableBoolean, and update mapping/tests accordingly. - Make alert dispatch filtering null-safe (
Boolean.TRUE.equals(...)) and preservetruedefaults on create in the service layer.
File summaries
| File | Description |
|---|---|
| shenyu-alert/src/main/java/org/apache/shenyu/alert/model/AlertReceiverDTO.java | Make enable/matchAll nullable to support selective updates without implicit false/default writes. |
| shenyu-admin/src/test/java/org/apache/shenyu/admin/transfer/AlertTransferTest.java | Update mapping assertions for nullable Booleans and add null-mapping coverage. |
| shenyu-admin/src/test/java/org/apache/shenyu/admin/service/AlertReceiverServiceTest.java | Verify selective update usage and ensure full-column update isn’t called. |
| shenyu-admin/src/main/resources/mappers/alert-receiver-sqlmap.xml | Add updateByPrimaryKeySelective dynamic SQL for partial updates. |
| shenyu-admin/src/main/java/org/apache/shenyu/admin/transfer/AlertTransfer.java | Update DTO/DO mapping for nullable enable/matchAll. |
| shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/AlertReceiverServiceImpl.java | Default enable/matchAll to true on create and switch update to selective update. |
| shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/AlertDispatchServiceImpl.java | Make dispatch filtering null-safe for nullable Booleans. |
| shenyu-admin/src/main/java/org/apache/shenyu/admin/model/entity/AlertReceiverDO.java | Make persisted enable/matchAll nullable to preserve omitted fields. |
| shenyu-admin/src/main/java/org/apache/shenyu/admin/mapper/AlertReceiverMapper.java | Add updateByPrimaryKeySelective to the mapper interface. |
Review details
- Files reviewed: 9/9 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| <if test="email != null">email = #{email,jdbcType=VARCHAR},</if> | ||
| <if test="hookUrl != null">hook_url = #{hookUrl,jdbcType=VARCHAR},</if> | ||
| <if test="wechatId != null">wechat_id = #{wechatId,jdbcType=VARCHAR},</if> | ||
| <if test="accessToken != null">access_token = #{accessToken,jdbcType=TINYINT},</if> |
Aias00
left a comment
There was a problem hiding this comment.
Approved as PMC (Aias00). Coherent, well-scoped fix with regression tests; green CI, mergeable. Reviewed the diff.
Fixes #6711
Summary
updateByPrimaryKeywithupdateByPrimaryKeySelectivefor alert receiver updates.enableandmatchAllfrom primitivebooleanto nullableBoolean.truewhen creating a new alert receiver.Test
AlertReceiverServiceTestto verify selective updates and prevent calls to the full-column update method.AlertTransferTestfor nullable Boolean mapping.enableandmatchAllvalues.Make sure that:
./mvnw clean install -Dmaven.javadoc.skip=true.