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
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,15 @@ String toJpql(boolean isCount) {
throw new IllegalArgumentException(String.format("illegal sortBy[%s], entity[%s] doesn't have this field", msg.getSortBy(), info.entityClass.getName()));
}

ret = String.format("%s order by %s.%s %s", ret, entityName, msg.getSortBy(), msg.getSortDirection().toUpperCase());
if ("uuid".equals(msg.getSortBy())) {
ret = String.format("%s order by %s.%s %s", ret, entityName, msg.getSortBy(), msg.getSortDirection().toUpperCase());
} else {
// 追加 uuid 作为 tiebreaker,确保排序稳定
ret = String.format("%s order by %s.%s %s, %s.uuid ASC", ret, entityName, msg.getSortBy(), msg.getSortDirection().toUpperCase(), entityName);
}
} else if (!msg.isCount()) {
// 无排序字段时添加默认排序
ret = String.format("%s order by %s.uuid ASC", ret, entityName);
Comment on lines +736 to +741
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

注释应使用英文,不应包含中文。

根据编码规范,代码中不应有中文,包括注释。请将第 736 行和第 740 行的中文注释改为英文。

建议修复
                         } else {
-                            // 追加 uuid 作为 tiebreaker,确保排序稳定
+                            // Append uuid as tiebreaker to ensure stable sorting
                             ret = String.format("%s order by %s.%s %s, %s.uuid ASC", ret, entityName, msg.getSortBy(), msg.getSortDirection().toUpperCase(), entityName);
                         }
                     } else if (!msg.isCount()) {
-                        // 无排序字段时添加默认排序
+                        // Add default sorting when no sortBy is specified
                         ret = String.format("%s order by %s.uuid ASC", ret, entityName);

As per coding guidelines: "代码里不应当有有中文,包括报错、注释等都应当使用正确的、无拼写错误的英文来写"

🤖 Prompt for AI Agents
In `@search/src/main/java/org/zstack/query/MysqlQueryBuilderImpl3.java` around
lines 736 - 741, Replace the Chinese comments in MysqlQueryBuilderImpl3 near the
code that appends ordering (the block using variables ret, entityName,
msg.getSortBy(), msg.getSortDirection(), and msg.isCount()) with English
comments; specifically change the comment at the branch that adds uuid as a
tiebreaker to something like "append uuid as tiebreaker to ensure stable
ordering" and change the comment at the branch that adds default ordering when
no sort field is provided to something like "add default ordering by uuid when
no sort field is specified."

}

if (msg.getGroupBy() != null) {
Expand Down
10 changes: 9 additions & 1 deletion search/src/main/java/org/zstack/query/QueryFacadeImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,15 @@ public ZQLQueryReturn queryUseZQL(APIQueryMessage msg, Class inventoryClass) {
}

if (msg.getSortBy() != null) {
sb.add(String.format("order by %s %s", msg.getSortBy(), msg.getSortDirection()));
if ("uuid".equals(msg.getSortBy())) {
sb.add(String.format("order by %s %s", msg.getSortBy(), msg.getSortDirection()));
} else {
// 追加 uuid 作为 tiebreaker,确保排序稳定
sb.add(String.format("order by %s %s, uuid asc", msg.getSortBy(), msg.getSortDirection()));
}
} else if (!msg.isCount()) {
// 无排序字段时添加默认排序
sb.add("order by uuid asc");
Comment on lines +489 to +494
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

注释应使用英文,不应包含中文。

根据编码规范,代码中不应有中文,包括注释。请将第 489 行和第 493 行的中文注释改为英文。

建议修复
         } else {
-                // 追加 uuid 作为 tiebreaker,确保排序稳定
+                // Append uuid as tiebreaker to ensure stable sorting
                 sb.add(String.format("order by %s %s, uuid asc", msg.getSortBy(), msg.getSortDirection()));
             }
         } else if (!msg.isCount()) {
-            // 无排序字段时添加默认排序
+            // Add default sorting when no sortBy is specified
             sb.add("order by uuid asc");

As per coding guidelines: "代码里不应当有有中文,包括报错、注释等都应当使用正确的、无拼写错误的英文来写"

📝 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
// 追加 uuid 作为 tiebreaker,确保排序稳定
sb.add(String.format("order by %s %s, uuid asc", msg.getSortBy(), msg.getSortDirection()));
}
} else if (!msg.isCount()) {
// 无排序字段时添加默认排序
sb.add("order by uuid asc");
// Append uuid as tiebreaker to ensure stable sorting
sb.add(String.format("order by %s %s, uuid asc", msg.getSortBy(), msg.getSortDirection()));
}
} else if (!msg.isCount()) {
// Add default sorting when no sortBy is specified
sb.add("order by uuid asc");
🤖 Prompt for AI Agents
In `@search/src/main/java/org/zstack/query/QueryFacadeImpl.java` around lines 489
- 494, Replace the Chinese comments on the block that appends ordering to the
query with English comments: change the comment before the
sb.add(String.format("order by %s %s, uuid asc", msg.getSortBy(),
msg.getSortDirection())) to something like "add uuid as a tiebreaker to ensure
stable ordering" and change the comment before the sb.add("order by uuid asc")
in the !msg.isCount() branch to "apply default ordering when no sort field
provided"; locate these near the code that calls sb.add and references
msg.getSortBy(), msg.getSortDirection(), and msg.isCount() and update only the
comment text to English.

}

if (msg.getLimit() != null) {
Expand Down