From c7b7bed140f98940c5adc696291c57da9576dce0 Mon Sep 17 00:00:00 2001
From: t8y2 <1156263951@qq.com>
Date: Fri, 29 May 2026 00:41:51 +0800
Subject: [PATCH] feat(editor): add extended column properties support for
MySQL, PostgreSQL, and SQL Server
MySQL: AUTO_INCREMENT, ON UPDATE CURRENT_TIMESTAMP
PostgreSQL: GENERATED AS IDENTITY (BY DEFAULT / ALWAYS)
SQL Server: IDENTITY(seed, increment)
---
.../structure/TableStructureEditor.vue | 136 ++++++++++--
apps/desktop/src/i18n/locales/en.ts | 7 +
apps/desktop/src/i18n/locales/es.ts | 7 +
apps/desktop/src/i18n/locales/zh-CN.ts | 7 +
.../src/lib/tableStructureEditorSql.ts | 13 ++
.../src/lib/tableStructureEditorState.ts | 34 ++-
crates/dbx-core/src/table_structure_sql.rs | 193 ++++++++++++++++++
.../tableStructureEditorState.test.ts | 28 ++-
8 files changed, 410 insertions(+), 15 deletions(-)
diff --git a/apps/desktop/src/components/structure/TableStructureEditor.vue b/apps/desktop/src/components/structure/TableStructureEditor.vue
index a94f1964f0..54d42d5b6e 100644
--- a/apps/desktop/src/components/structure/TableStructureEditor.vue
+++ b/apps/desktop/src/components/structure/TableStructureEditor.vue
@@ -147,17 +147,28 @@ const indexTypeOptions = computed(() =>
structureCapabilities.value.indexType ? (indexTypesByDb[databaseType.value ?? ""] ?? []) : [],
);
-const colLabels = computed(() => [
- "#",
- t("structureEditor.columnName"),
- t("structureEditor.dataType"),
- t("structureEditor.length"),
- t("structureEditor.nullable"),
- t("structureEditor.primaryKey"),
- t("structureEditor.defaultValue"),
- t("structureEditor.comment"),
- t("structureEditor.actions"),
-]);
+const showExtendedProperties = computed(() => {
+ const dt = databaseType.value;
+ return dt === "mysql" || dt === "postgres" || dt === "sqlserver";
+});
+
+const colLabels = computed(() => {
+ const labels = [
+ "#",
+ t("structureEditor.columnName"),
+ t("structureEditor.dataType"),
+ t("structureEditor.length"),
+ t("structureEditor.nullable"),
+ t("structureEditor.primaryKey"),
+ t("structureEditor.defaultValue"),
+ t("structureEditor.comment"),
+ ];
+ if (showExtendedProperties.value) {
+ labels.push(t("structureEditor.extendedProperties"));
+ }
+ labels.push(t("structureEditor.actions"));
+ return labels;
+});
const indexColLabels = computed(() => [
t("structureEditor.indexName"),
t("structureEditor.indexColumns"),
@@ -252,7 +263,7 @@ async function loadStructure(silent = false) {
api.listForeignKeys(props.connectionId, props.database, targetSchema.value, props.tableName).catch(() => []),
api.listTriggers(props.connectionId, props.database, targetSchema.value, props.tableName).catch(() => []),
]);
- columns.value = createColumnDrafts(nextColumns);
+ columns.value = createColumnDrafts(nextColumns, databaseType.value);
indexes.value = createIndexDrafts(nextIndexes);
foreignKeys.value = nextForeignKeys;
triggers.value = nextTriggers;
@@ -284,6 +295,7 @@ async function addColumn() {
defaultValue: "",
comment: "",
isPrimaryKey: false,
+ extra: {},
markedForDrop: false,
});
await nextTick();
@@ -693,6 +705,106 @@ watch(
+
+
+
+
+
+
+
+
+
+
+
+ {
+ if (column.extra.identity) {
+ column.extra.identity.seed = v ? Number(v) : undefined;
+ }
+ }
+ "
+ />
+ {
+ if (column.extra.identity) {
+ column.extra.identity.increment = v ? Number(v) : undefined;
+ }
+ }
+ "
+ />
+
+
+
+
+
+
+ {
+ if (!column.extra.identity) column.extra.identity = {};
+ column.extra.identity.seed = v ? Number(v) : undefined;
+ }
+ "
+ />
+ {
+ if (!column.extra.identity) column.extra.identity = {};
+ column.extra.identity.increment = v ? Number(v) : undefined;
+ }
+ "
+ />
+
+
+
+ |
|