Skip to content
Open
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
10 changes: 9 additions & 1 deletion sql/templates/queryapplylist.html
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,15 @@ <h4 class="modal-title text-danger">工单日志</h4>
$("#db_name").empty();
$("#db_name_multiple").empty();
for (var i = 0; i < result.length; i++) {
var name = "<option value=\"" + result[i] + "\">" + result[i] + "</option>";
// Redis 返回带展示文本的资源对象(例如
// {value: "0", text: "db0[100]"}),申请时必须提交
// value,否则审批通过后权限库名会变成 [object Object]。
var item = result[i];
var value = (typeof item === "object" && item !== null)
? item.value : item;
var text = (typeof item === "object" && item !== null)
? item.text : item;
Comment on lines +393 to +396

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve array-valued database entries

When the selected instance uses Memcached, /api/v1/sqlquery/resources/ returns each node as a one-element array because MemcachedEngine.get_all_databases() appends [db_name] in sql/engines/memcached.py:69-70. Arrays also satisfy this new object check, so both item.value and item.text become undefined; the permission form consequently displays and submits undefined rather than Node - 0, and approved users cannot connect to the requested node. Restrict this branch to objects that actually provide the Redis value/text fields, or retain the prior handling for arrays.

Useful? React with 👍 / 👎.

var name = "<option value=\"" + value + "\">" + text + "</option>";
$("#db_name").append(name);
$("#db_name_multiple").append(name);
}
Expand Down
Loading