Skip to content

Comments

fix(tag): add resourceType to TagPatternVO [ZSTAC-74908]#3372

Open
zstack-robot-2 wants to merge 1 commit into5.5.12from
sync/ye.zou/fix/ZSTAC-74908
Open

fix(tag): add resourceType to TagPatternVO [ZSTAC-74908]#3372
zstack-robot-2 wants to merge 1 commit into5.5.12from
sync/ye.zou/fix/ZSTAC-74908

Conversation

@zstack-robot-2
Copy link
Collaborator

Summary

Add resourceType field to TagPatternVO to scope AI model tags (AI::LLM etc.) away from VM pages.

  • DB upgrade: ADD_COLUMN('TagPatternVO', 'resourceType', 'VARCHAR(128)')
  • TagPatternVO.java: new nullable @Column String resourceType + getter/setter

Paired with premium MR that sets resourceType="ModelVO" when creating AI tag patterns.

Resolves: ZSTAC-74908

sync from gitlab !9207

Resolves: ZSTAC-74908

Change-Id: I48054139babb1e8092ab81e4367743ae3fd8aefb
@coderabbitai
Copy link

coderabbitai bot commented Feb 19, 2026

浏览

在 TagPatternVO 数据库模式和对应的 Java 实体类中添加新字段。SQL 迁移脚本向 TagPatternVO 表添加了 VARCHAR(128) 类型的 resourceType 列,Java 类相应地添加了该字段的持久化定义和访问器方法。

变更

分类 / 文件 摘要
数据库模式
conf/db/upgrade/V5.5.6__schema.sql
通过 ADD_COLUMN 存储过程向 TagPatternVO 表添加 resourceType 列(VARCHAR(128))。
实体模型
header/src/main/java/org/zstack/header/tag/TagPatternVO.java
为 TagPatternVO 类添加 resourceType 字段及其对应的 getter 和 setter 方法。

代码审查工作量估计

🎯 2 (Simple) | ⏱️ ~10 分钟

🐰 数据库的新列悄悄添加,
实体类里字段随之诞生,
resourceType 小小地展开翅膀,
简洁而温和,如春风化雨,
模式与代码,完美相融 ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed PR标题采用正确的[scope]: 格式,且56个字符,符合72字符以内的要求。标题准确描述了主要变更:向TagPatternVO添加resourceType字段。
Description check ✅ Passed PR描述详细说明了变更内容,包括数据库升级、代码添加的新字段及其目的。描述与变更集密切相关,清晰解释了功能目标和关联的问题跟踪。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sync/ye.zou/fix/ZSTAC-74908

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +33 to +34
@Column
private String resourceType;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# 搜索resourceType相关定义和使用
rg "resourceType" --type java -n | head -30

Repository: MatheMatrix/zstack

Length of output: 3602


🏁 Script executed:

# 搜索数据库迁移脚本,查找TagPatternVO相关的schema定义
find . -type f \( -name "*.sql" -o -name "*migration*" -o -name "*Migration*" \) | head -20

Repository: MatheMatrix/zstack

Length of output: 904


🏁 Script executed:

# 查看TagPatternVO完整文件内容
cat -n header/src/main/java/org/zstack/header/tag/TagPatternVO.java

Repository: MatheMatrix/zstack

Length of output: 3175


🏁 Script executed:

# 搜索@Column注解的长度定义模式,了解项目规范
rg '@Column\(length' --type java -A 1 | head -30

Repository: MatheMatrix/zstack

Length of output: 44


🏁 Script executed:

# 搜索tag_pattern表的SQL定义
rg "tag_pattern" --type sql -i -B 2 -A 5

Repository: MatheMatrix/zstack

Length of output: 44


🏁 Script executed:

# 检查项目中是否有@Column(length定义的示例
rg '@Column\(' --type java -A 1 | grep -i "length" | head -20

Repository: MatheMatrix/zstack

Length of output: 44


🏁 Script executed:

# 搜索TagPatternVO的迁移脚本相关定义
rg "TagPatternVO|tag_pattern" --type sql -i

Repository: MatheMatrix/zstack

Length of output: 1083


🏁 Script executed:

# 查看V3.2.0迁移脚本中TagPatternVO的完整建表语句
rg "CREATE TABLE IF NOT EXISTS.*TagPatternVO" --type sql -A 15

Repository: MatheMatrix/zstack

Length of output: 1331


🏁 Script executed:

# 检查项目中其他VO类是否普遍使用@Column(length)或都不使用
rg "@Column" --type java -B 1 -A 1 | grep -E "(length|@Column)" | head -40

Repository: MatheMatrix/zstack

Length of output: 4390


🏁 Script executed:

# 验证resourceType字段在其他VO类中的定义方式
rg "private String resourceType" --type java -B 2 | head -30

Repository: MatheMatrix/zstack

Length of output: 2849


建议在 @Column 注解中明确指定长度以保持一致性。

数据库迁移脚本(V5.5.6__schema.sql)定义 resourceTypeVARCHAR(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.

Suggested change
@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.

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.

2 participants