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。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(grid): preserve null text during editing
zhangsanf8baedc6e62b
diff --git a/apps/desktop/src/lib/__tests__/dataGrid/dataGridCellCoercion.spec.ts b/apps/desktop/src/lib/__tests__/dataGrid/dataGridCellCoercion.spec.tsindex 85485aa86f..088ebf1bdb 100644--- a/apps/desktop/src/lib/__tests__/dataGrid/dataGridCellCoercion.spec.ts+++ b/apps/desktop/src/lib/__tests__/dataGrid/dataGridCellCoercion.spec.ts@@ -34,6 +34,26 @@ describe("dataGridCellDisplayText", () => {});describe("coerceDataGridCellValue", () => {+ it.each(["null", "NULL", "Null", "nUlL"])("preserves literal %s input as text", (value) => {+ expect(+ coerceDataGridCellValue({+ value,+ oldValue: null,+ databaseType: "mysql",+ columnInfo: { data_type: "varchar(255)" },+ }),+ ).toBe(value);++ expect(+ coerceDataGridCellValue({+ value,+ oldValue: "previous",+ databaseType: "postgres",+ columnInfo: { data_type: "text" },+ }),+ ).toBe(value);+ });+it("preserves an explicitly generated empty string for a null cell", () => {const options = {value: "",diff --git a/apps/desktop/src/lib/dataGrid/dataGridCellCoercion.ts b/apps/desktop/src/lib/dataGrid/dataGridCellCoercion.tsindex d60d95b71c..b9c9468871 100644--- a/apps/desktop/src/lib/dataGrid/dataGridCellCoercion.ts+++ b/apps/desktop/src/lib/dataGrid/dataGridCellCoercion.ts@@ -11,7 +11,6 @@ export interface CoerceDataGridCellValueOptions {export function coerceDataGridCellValue(options: CoerceDataGridCellValueOptions): GridCellValue {const { value, oldValue } = options;- if (value.toUpperCase() === "NULL") return null;if (value === "" && oldValue === null && !options.preserveEmptyString) return null;const postgresArrayValue = coercePostgresArrayValue(options);if (postgresArrayValue !== undefined) return postgresArrayValue;diff --git a/packages/app-tests/dataGridEditor.test.ts b/packages/app-tests/dataGridEditor.test.tsindex aab888fa69..12c462c979 100644--- a/packages/app-tests/dataGridEditor.test.ts+++ b/packages/app-tests/dataGridEditor.test.ts@@ -618,6 +618,23 @@ test("undo and redo restore pending cell edits before save", () => {assert.deepEqual(editor.rowDataWithChanges(result.value.rows[0], 0), [1, "Ada Lovelace"]);});+test("typing NULL preserves the literal string value", async () => {+ setActivePinia(createPinia());+ installBrowserTestGlobals();++ const result = computed(() => ({+ columns: ["id", "name"],+ rows: [[1, "Ada"] as CellValue[]],+ }));+ const editor = createPeopleGridEditor(result);++ editor.applyCellValue(0, 1, "NULL");++ assert.equal(editor.dirtyRows.value.get(0)?.get(1), "NULL");+ assert.deepEqual(editor.rowDataWithChanges(result.value.rows[0], 0), [1, "NULL"]);+ assert.deepEqual(await editor.previewChanges(), [`UPDATE "people" SET "name" = 'NULL' WHERE "id" = 1;`]);+});+test("setting a cell to NULL records pending SQL and supports undo and redo", async () => {setActivePinia(createPinia());installBrowserTestGlobals();