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。

feat(grid): add current datetime generation with milliseconds

高桥凉介03db4cad8c15
diff --git a/apps/desktop/src/components/grid/DataGrid.vue b/apps/desktop/src/components/grid/DataGrid.vue
index a5f2c6e833..f38eb23853 100644
--- a/apps/desktop/src/components/grid/DataGrid.vue
+++ b/apps/desktop/src/components/grid/DataGrid.vue
@@ -9990,6 +9990,11 @@ function generateSelectionMenuItems(disabled: boolean): ContextMenuItem[] {
action: () => applyGeneratedSelectionValue("datetime"),
disabled,
},
+ {
+ label: t("grid.generateCurrentDatetimeMilliseconds"),
+ action: () => applyGeneratedSelectionValue("datetime-ms"),
+ disabled,
+ },
{
label: t("grid.generateCurrentDate"),
action: () => applyGeneratedSelectionValue("date"),
@@ -15571,6 +15576,7 @@ useUpdateBlocker(() => (hasPendingChanges.value || hasPendingDataEditorDraft.val
<DropdownMenuItem @click="applyGeneratedDetailValue('empty')">{{ t("grid.generateEmptyString") }}</DropdownMenuItem>
<DropdownMenuItem @click="applyGeneratedDetailValue('null')">{{ t("grid.generateNull") }}</DropdownMenuItem>
<DropdownMenuItem @click="applyGeneratedDetailValue('datetime')">{{ t("grid.generateCurrentDatetime") }}</DropdownMenuItem>
+ <DropdownMenuItem @click="applyGeneratedDetailValue('datetime-ms')">{{ t("grid.generateCurrentDatetimeMilliseconds") }}</DropdownMenuItem>
<DropdownMenuItem @click="applyGeneratedDetailValue('date')">{{ t("grid.generateCurrentDate") }}</DropdownMenuItem>
<DropdownMenuItem @click="applyGeneratedDetailValue('uuid')">{{ t("grid.generateUuidV4") }}</DropdownMenuItem>
<DropdownMenuItem @click="applyGeneratedDetailValue('uuid-v7')">{{ t("grid.generateUuidV7") }}</DropdownMenuItem>
diff --git a/apps/desktop/src/i18n/locales/az.ts b/apps/desktop/src/i18n/locales/az.ts
index 53b980d1ab..5658cfe3b2 100644
--- a/apps/desktop/src/i18n/locales/az.ts
+++ b/apps/desktop/src/i18n/locales/az.ts
@@ -2322,6 +2322,7 @@ export default withEnglishFallback({
generateEmptyString: "Boş mətn",
generateNull: "NULL",
generateCurrentDatetime: "Cari tarix və vaxt",
+ generateCurrentDatetimeMilliseconds: "Cari tarix və vaxt (millisaniyə)",
generateCurrentDate: "Cari tarix",
generateUuidV4: "UUID v4",
generateUuidV7: "UUID v7",
diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts
index 4547bc7fc4..f472772d43 100644
--- a/apps/desktop/src/i18n/locales/en.ts
+++ b/apps/desktop/src/i18n/locales/en.ts
@@ -2769,6 +2769,7 @@ export default {
generateEmptyString: "Empty String",
generateNull: "NULL",
generateCurrentDatetime: "Current Datetime",
+ generateCurrentDatetimeMilliseconds: "Current Datetime (Milliseconds)",
generateCurrentDate: "Current Date",
generateUuidV4: "UUID v4",
generateUuidV7: "UUID v7",
diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.ts
index 21cdd805ca..b1e2695b0e 100644
--- a/apps/desktop/src/i18n/locales/es.ts
+++ b/apps/desktop/src/i18n/locales/es.ts
@@ -2589,6 +2589,7 @@ export default withEnglishFallback({
generateEmptyString: "Cadena vacía",
generateNull: "NULL",
generateCurrentDatetime: "Fecha y hora actuales",
+ generateCurrentDatetimeMilliseconds: "Fecha y hora actuales (milisegundos)",
generateCurrentDate: "Fecha actual",
generateUuidV4: "UUID v4",
generateUuidV7: "UUID v7",
diff --git a/apps/desktop/src/i18n/locales/id.ts b/apps/desktop/src/i18n/locales/id.ts
index b1a1e60a0a..e1eae53149 100644
--- a/apps/desktop/src/i18n/locales/id.ts
+++ b/apps/desktop/src/i18n/locales/id.ts
@@ -2603,6 +2603,7 @@ export default withEnglishFallback({
generateEmptyString: "String Kosong",
generateNull: "NULL",
generateCurrentDatetime: "Datetime Saat Ini",
+ generateCurrentDatetimeMilliseconds: "Datetime Saat Ini (Milidetik)",
generateCurrentDate: "Tanggal Saat Ini",
generateUuidV4: "UUID v4",
generateUuidV7: "UUID v7",
diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.ts
index 91ce906831..bfafcb623b 100644
--- a/apps/desktop/src/i18n/locales/it.ts
+++ b/apps/desktop/src/i18n/locales/it.ts
@@ -2483,6 +2483,7 @@ export default withEnglishFallback({
generateEmptyString: "Stringa vuota",
generateNull: "NULL",
generateCurrentDatetime: "Data e ora correnti",
+ generateCurrentDatetimeMilliseconds: "Data e ora correnti (millisecondi)",
generateCurrentDate: "Data corrente",
generateUuidV4: "UUID v4",
generateUuidV7: "UUID v7",
diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.ts
index 6375ca2810..b2d5f084a0 100644
--- a/apps/desktop/src/i18n/locales/ja.ts
+++ b/apps/desktop/src/i18n/locales/ja.ts
@@ -2489,6 +2489,7 @@ export default withEnglishFallback({
generateEmptyString: "空文字列",
generateNull: "NULL",
generateCurrentDatetime: "現在の日時",
+ generateCurrentDatetimeMilliseconds: "現在の日時(ミリ秒)",
generateCurrentDate: "現在の日付",
generateUuidV4: "UUID v4",
generateUuidV7: "UUID v7",
diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.ts
index 2c13304b1f..e18ac3953d 100644
--- a/apps/desktop/src/i18n/locales/ko.ts
+++ b/apps/desktop/src/i18n/locales/ko.ts
@@ -2539,6 +2539,7 @@ export default withEnglishFallback({
generateEmptyString: "빈 문자열",
generateNull: "NULL",
generateCurrentDatetime: "현재 날짜/시간",
+ generateCurrentDatetimeMilliseconds: "현재 날짜/시간(밀리초)",
generateCurrentDate: "현재 날짜",
generateUuidV4: "UUID v4",
generateUuidV7: "UUID v7",
diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.ts
index 19638dda4b..5d4fedff1f 100644
--- a/apps/desktop/src/i18n/locales/pt-BR.ts
+++ b/apps/desktop/src/i18n/locales/pt-BR.ts
@@ -2484,6 +2484,7 @@ export default withEnglishFallback({
generateEmptyString: "String vazia",
generateNull: "NULL",
generateCurrentDatetime: "Data e hora atuais",
+ generateCurrentDatetimeMilliseconds: "Data e hora atuais (milissegundos)",
generateCurrentDate: "Data atual",
generateUuidV4: "UUID v4",
generateUuidV7: "UUID v7",
diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.ts
index 657df91227..9fd7865161 100644
--- a/apps/desktop/src/i18n/locales/ru.ts
+++ b/apps/desktop/src/i18n/locales/ru.ts
@@ -2663,6 +2663,7 @@ export default withEnglishFallback({
generateEmptyString: "Пустая строка",
generateNull: "NULL",
generateCurrentDatetime: "Текущие дата и время",
+ generateCurrentDatetimeMilliseconds: "Текущие дата и время (мс)",
generateCurrentDate: "Текущая дата",
generateUuidV4: "UUID v4",
generateUuidV7: "UUID v7",
diff --git a/apps/desktop/src/i18n/locales/tr.ts b/apps/desktop/src/i18n/locales/tr.ts
index 2ad7f3d5c1..394e714f98 100644
--- a/apps/desktop/src/i18n/locales/tr.ts
+++ b/apps/desktop/src/i18n/locales/tr.ts
@@ -2315,6 +2315,7 @@ export default withEnglishFallback({
generateEmptyString: "Boş Dize",
generateNull: "NULL",
generateCurrentDatetime: "Geçerli Tarih-Saat",
+ generateCurrentDatetimeMilliseconds: "Geçerli Tarih-Saat (Milisaniye)",
generateCurrentDate: "Geçerli Tarih",
generateUuidV4: "UUID v4",
generateUuidV7: "UUID v7",
diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts
index 1770294e8c..37e350f0fe 100644
--- a/apps/desktop/src/i18n/locales/zh-CN.ts
+++ b/apps/desktop/src/i18n/locales/zh-CN.ts
@@ -2704,6 +2704,7 @@ export default withEnglishFallback({
generateEmptyString: "空字符串",
generateNull: "NULL",
generateCurrentDatetime: "当前日期时间",
+ generateCurrentDatetimeMilliseconds: "当前日期时间(毫秒)",
generateCurrentDate: "当前日期",
generateUuidV4: "UUID v4",
generateUuidV7: "UUID v7",
diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.ts
index 4d79fd4b42..5e01c37eb1 100644
--- a/apps/desktop/src/i18n/locales/zh-TW.ts
+++ b/apps/desktop/src/i18n/locales/zh-TW.ts
@@ -2485,6 +2485,7 @@ export default withEnglishFallback({
generateEmptyString: "空字串",
generateNull: "NULL",
generateCurrentDatetime: "目前日期時間",
+ generateCurrentDatetimeMilliseconds: "目前日期時間(毫秒)",
generateCurrentDate: "目前日期",
generateUuidV4: "UUID v4",
generateUuidV7: "UUID v7",
diff --git a/apps/desktop/src/lib/__tests__/dataGrid/cellValueGeneration.spec.ts b/apps/desktop/src/lib/__tests__/dataGrid/cellValueGeneration.spec.ts
index 7891898a70..a58c426a15 100644
--- a/apps/desktop/src/lib/__tests__/dataGrid/cellValueGeneration.spec.ts
+++ b/apps/desktop/src/lib/__tests__/dataGrid/cellValueGeneration.spec.ts
@@ -17,6 +17,12 @@ describe("generateCellValues", () => {
expect(generateCellValues("date", 2, { now })).toEqual(["2026-07-16", "2026-07-16"]);
});
+ it("appends three-digit milliseconds when requested", () => {
+ const now = new Date(2026, 6, 16, 9, 8, 7, 123);
+ expect(generateCellValues("datetime-ms", 2, { now })).toEqual(["2026-07-16 09:08:07.123", "2026-07-16 09:08:07.123"]);
+ expect(generateCellValues("datetime-ms", 1, { now: new Date(2026, 6, 16, 9, 8, 7) })).toEqual(["2026-07-16 09:08:07.000"]);
+ });
+
it("generates one UUID per cell", () => {
let index = 0;
expect(generateCellValues("uuid", 3, { uuidFactory: () => `uuid-${++index}` })).toEqual(["uuid-1", "uuid-2", "uuid-3"]);
diff --git a/apps/desktop/src/lib/dataGrid/cellValueGeneration.ts b/apps/desktop/src/lib/dataGrid/cellValueGeneration.ts
index b833979f95..b2c4b2c700 100644
--- a/apps/desktop/src/lib/dataGrid/cellValueGeneration.ts
+++ b/apps/desktop/src/lib/dataGrid/cellValueGeneration.ts
@@ -1,6 +1,6 @@
import { uuid } from "@/lib/common/utils";
-export type CellValueGenerationKind = "empty" | "null" | "datetime" | "date" | "uuid" | "uuid-v7" | "increment" | "snowflake";
+export type CellValueGenerationKind = "empty" | "null" | "datetime" | "datetime-ms" | "date" | "uuid" | "uuid-v7" | "increment" | "snowflake";
export interface SnowflakeIdGenerator {
next(nowMs?: number): string;
@@ -57,6 +57,7 @@ export function generateCellValues(
if (kind === "null") return null;
if (kind === "empty") return "";
if (kind === "datetime") return localDateTimeText(now);
+ if (kind === "datetime-ms") return localDateTimeMillisecondText(now);
if (kind === "date") return localDateText(now);
if (kind === "uuid") return uuidFactory();
if (kind === "uuid-v7") {
@@ -78,6 +79,14 @@ function localDateTimeText(date: Date): string {
return `${date.getFullYear()}-${padDatePart(date.getMonth() + 1)}-${padDatePart(date.getDate())} ${padDatePart(date.getHours())}:${padDatePart(date.getMinutes())}:${padDatePart(date.getSeconds())}`;
}
+/**
+ * 带毫秒的本地日期时间文本(issue #11602),例如 2026-07-16 09:08:07.123。
+ * 毫秒固定补足 3 位,避免 7 毫秒被写成 .7 而与存量数据的 3 位格式不一致。
+ */
+function localDateTimeMillisecondText(date: Date): string {
+ return `${localDateTimeText(date)}.${String(date.getMilliseconds()).padStart(3, "0")}`;
+}
+
function localDateText(date: Date): string {
return `${date.getFullYear()}-${padDatePart(date.getMonth() + 1)}-${padDatePart(date.getDate())}`;
}