Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions conf/db/upgrade/V5.5.6__schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,6 @@ SET g.`allocateStatus` = 'Unallocatable'
WHERE p.`virtStatus` IN ('VFIO_MDEV_VIRTUALIZED', 'SRIOV_VIRTUALIZED')
AND p.`vmInstanceUuid` IS NULL
AND g.`allocateStatus` != 'Unallocatable';

-- ZSTAC-74908: Add resourceType to TagPatternVO to scope AI model tags away from VM pages
CALL ADD_COLUMN('TagPatternVO', 'resourceType', 'VARCHAR(128)', 1, NULL);
11 changes: 11 additions & 0 deletions header/src/main/java/org/zstack/header/tag/TagPatternVO.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public class TagPatternVO extends ResourceVO implements OwnedByAccount {
@Transient
private String accountUuid;

@Column
private String resourceType;
Comment on lines +33 to +34
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.


@Column
private Timestamp createDate;

Expand Down Expand Up @@ -106,4 +109,12 @@ public TagPatternType getType() {
public void setType(TagPatternType type) {
this.type = type;
}

public String getResourceType() {
return resourceType;
}

public void setResourceType(String resourceType) {
this.resourceType = resourceType;
}
}