Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix(grid): display JSONB values as JSON string in edit mode and detail panel (#152)

t8y2fdf65ac5e304
diff --git a/src/components/grid/DataGrid.vue b/src/components/grid/DataGrid.vue
index 8fe7ab5602..e9a0805d01 100644
--- a/src/components/grid/DataGrid.vue
+++ b/src/components/grid/DataGrid.vue
@@ -428,7 +428,7 @@ const activeCellDetail = computed(() => {
if (!item || !column) return null;
const value = item.data[cell.col] ?? null;
const rawValue = formatCell(value);
- const valueText = value === null ? "" : String(value);
+ const valueText = value === null ? "" : typeof value === "object" ? JSON.stringify(value) : String(value);
const trimmed = valueText.trim();
const maybeJson = typeof value === "string" && (trimmed.startsWith("{") || trimmed.startsWith("["));
let formattedJson = "";
@@ -578,7 +578,7 @@ function startEdit(rowId: number, colIdx: number) {
isCancelling = false;
editingCell.value = { rowId, col: colIdx };
const val = item?.data[colIdx] ?? null;
- editValue.value = val === null ? "" : String(val);
+ editValue.value = val === null ? "" : typeof val === "object" ? JSON.stringify(val) : String(val);
nextTick(() => {
const input = document.querySelector(".cell-edit-input") as HTMLInputElement;
input?.focus();
diff --git a/src/lib/gridSelection.ts b/src/lib/gridSelection.ts
index 7fc57b42e6..07d77ac64b 100644
--- a/src/lib/gridSelection.ts
+++ b/src/lib/gridSelection.ts
@@ -51,6 +51,7 @@ export function extractSelection(
function displayValue(value: GridCellValue): string {
if (value === null) return "NULL";
if (typeof value === "boolean") return value ? "true" : "false";
+ if (typeof value === "object") return JSON.stringify(value);
return String(value);
}