fix(tag): add resourceType to TagPatternVO [ZSTAC-74908]#3372
fix(tag): add resourceType to TagPatternVO [ZSTAC-74908]#3372zstack-robot-2 wants to merge 1 commit into5.5.12from
Conversation
Resolves: ZSTAC-74908 Change-Id: I48054139babb1e8092ab81e4367743ae3fd8aefb
浏览在 TagPatternVO 数据库模式和对应的 Java 实体类中添加新字段。SQL 迁移脚本向 TagPatternVO 表添加了 VARCHAR(128) 类型的 resourceType 列,Java 类相应地添加了该字段的持久化定义和访问器方法。 变更
代码审查工作量估计🎯 2 (Simple) | ⏱️ ~10 分钟 诗
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@header/src/main/java/org/zstack/header/tag/TagPatternVO.java`:
- Around line 33-34: The `@Column` on the resourceType field in TagPatternVO does
not specify a length and should match the DB schema (VARCHAR(128)); update the
annotation on the private String resourceType field in class TagPatternVO to
include length = 128 (i.e., `@Column`(length = 128)); also scan similar fields in
SshKeyPairRefVO, LocalStorageResourceRefVO, ResourceConfigVO and align their
`@Column` length attributes to 128 for consistency with V5.5.6__schema.sql.
| @Column | ||
| private String resourceType; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# 搜索resourceType相关定义和使用
rg "resourceType" --type java -n | head -30Repository: MatheMatrix/zstack
Length of output: 3602
🏁 Script executed:
# 搜索数据库迁移脚本,查找TagPatternVO相关的schema定义
find . -type f \( -name "*.sql" -o -name "*migration*" -o -name "*Migration*" \) | head -20Repository: MatheMatrix/zstack
Length of output: 904
🏁 Script executed:
# 查看TagPatternVO完整文件内容
cat -n header/src/main/java/org/zstack/header/tag/TagPatternVO.javaRepository: MatheMatrix/zstack
Length of output: 3175
🏁 Script executed:
# 搜索@Column注解的长度定义模式,了解项目规范
rg '@Column\(length' --type java -A 1 | head -30Repository: MatheMatrix/zstack
Length of output: 44
🏁 Script executed:
# 搜索tag_pattern表的SQL定义
rg "tag_pattern" --type sql -i -B 2 -A 5Repository: MatheMatrix/zstack
Length of output: 44
🏁 Script executed:
# 检查项目中是否有@Column(length定义的示例
rg '@Column\(' --type java -A 1 | grep -i "length" | head -20Repository: MatheMatrix/zstack
Length of output: 44
🏁 Script executed:
# 搜索TagPatternVO的迁移脚本相关定义
rg "TagPatternVO|tag_pattern" --type sql -iRepository: MatheMatrix/zstack
Length of output: 1083
🏁 Script executed:
# 查看V3.2.0迁移脚本中TagPatternVO的完整建表语句
rg "CREATE TABLE IF NOT EXISTS.*TagPatternVO" --type sql -A 15Repository: MatheMatrix/zstack
Length of output: 1331
🏁 Script executed:
# 检查项目中其他VO类是否普遍使用@Column(length)或都不使用
rg "@Column" --type java -B 1 -A 1 | grep -E "(length|@Column)" | head -40Repository: MatheMatrix/zstack
Length of output: 4390
🏁 Script executed:
# 验证resourceType字段在其他VO类中的定义方式
rg "private String resourceType" --type java -B 2 | head -30Repository: MatheMatrix/zstack
Length of output: 2849
建议在 @Column 注解中明确指定长度以保持一致性。
数据库迁移脚本(V5.5.6__schema.sql)定义 resourceType 为 VARCHAR(128),但 Java 实体未显式指定长度属性。虽然项目中其他 resourceType 字段(如 SshKeyPairRefVO、LocalStorageResourceRefVO、ResourceConfigVO)也采用了相同做法,这可能导致 Java 实体定义与数据库 schema 不同步。建议添加 length = 128 以保持对齐,并考虑对项目中相同模式的其他字段进行统一处理。
建议修正
- `@Column`
- private String resourceType;
+ `@Column`(length = 128)
+ private String resourceType;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| @Column | |
| private String resourceType; | |
| `@Column`(length = 128) | |
| private String resourceType; |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@header/src/main/java/org/zstack/header/tag/TagPatternVO.java` around lines 33
- 34, The `@Column` on the resourceType field in TagPatternVO does not specify a
length and should match the DB schema (VARCHAR(128)); update the annotation on
the private String resourceType field in class TagPatternVO to include length =
128 (i.e., `@Column`(length = 128)); also scan similar fields in SshKeyPairRefVO,
LocalStorageResourceRefVO, ResourceConfigVO and align their `@Column` length
attributes to 128 for consistency with V5.5.6__schema.sql.
Summary
Add
resourceTypefield to TagPatternVO to scope AI model tags (AI::LLM etc.) away from VM pages.ADD_COLUMN('TagPatternVO', 'resourceType', 'VARCHAR(128)')@Column String resourceType+ getter/setterPaired with premium MR that sets
resourceType="ModelVO"when creating AI tag patterns.Resolves: ZSTAC-74908
sync from gitlab !9207