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(structure): open editor from field and index nodes

t8y292ef1ac3cf75
diff --git a/apps/desktop/src/components/layout/ContentArea.vue b/apps/desktop/src/components/layout/ContentArea.vue
index 4e82e0ceac..12a0ddc39a 100644
--- a/apps/desktop/src/components/layout/ContentArea.vue
+++ b/apps/desktop/src/components/layout/ContentArea.vue
@@ -1412,6 +1412,7 @@ defineExpose({ focusSearch, refreshData, handleModRTarget, requestQueryEditorExe
:table-name="activeTab.structureTableName || ''"
:initial-tab="activeTab.structureInitialTab"
:initial-tab-request-id="activeTab.structureInitialTabRequestId"
+ :initial-target="activeTab.structureInitialTarget"
:draft="activeTab.structureDraft"
@update:draft="(draft) => (activeTab.structureDraft = draft)"
@saved="(commentChanged) => emit('structureEditorSaved', commentChanged)"
diff --git a/apps/desktop/src/components/sidebar/TreeItem.vue b/apps/desktop/src/components/sidebar/TreeItem.vue
index 1a3d1fbc5d..ecda4a8444 100644
--- a/apps/desktop/src/components/sidebar/TreeItem.vue
+++ b/apps/desktop/src/components/sidebar/TreeItem.vue
@@ -3790,8 +3790,22 @@ function openTableImport() {
function openStructureEditor() {
const node = props.node;
- if (node.type !== "table" || !node.connectionId || !node.database) return;
- queryStore.openTableStructure(node.connectionId, node.database, node.schema, node.label);
+ if (!node.connectionId || !node.database) return;
+ if (node.type === "table") {
+ queryStore.openTableStructure(node.connectionId, node.database, node.schema, node.label);
+ return;
+ }
+ if (node.type === "column" && node.tableName) {
+ const columnName = tableChildDropObjectName(node).trim();
+ if (!columnName) return;
+ queryStore.openTableStructure(node.connectionId, node.database, node.schema, node.tableName, "columns", { kind: "column", name: columnName });
+ return;
+ }
+ if (node.type === "index" && node.tableName) {
+ const indexName = tableChildDropObjectName(node).trim();
+ if (!indexName) return;
+ queryStore.openTableStructure(node.connectionId, node.database, node.schema, node.tableName, "indexes", { kind: "index", name: indexName });
+ }
}
function openFieldLineage() {
@@ -3835,7 +3849,8 @@ const canOpenTableImport = computed(() => {
return props.node.type === "table" && !isSqlServerLinkedNode(props.node) && !!props.node.database && supportsTableImport(currentDatabaseType());
});
const canOpenStructureEditor = computed(() => {
- return props.node.type === "table" && !isSqlServerLinkedNode(props.node) && !!props.node.database && supportsTableStructureEditing(currentTableStructureDatabaseType());
+ const editableNode = props.node.type === "table" || ((props.node.type === "column" || props.node.type === "index") && !!props.node.tableName);
+ return editableNode && !isSqlServerLinkedNode(props.node) && !!props.node.connectionId && !!props.node.database && supportsTableStructureEditing(currentTableStructureDatabaseType());
});
const canOpenFieldLineage = computed(() => {
return props.node.type === "column" && !!props.node.database && !!props.node.tableName && supportsFieldLineage(currentDatabaseType());
@@ -4756,9 +4771,16 @@ function treeItemMenuItems(): ContextMenuItem[] {
// 7. Column
if (node.type === "column") {
items.push({ label: t("contextMenu.copyName"), action: copyName, icon: Copy, shortcut: shortcutCopyName.value });
+ const columnActions: ContextMenuItem[] = [];
+ if (canOpenStructureEditor.value) {
+ columnActions.push({ label: t("contextMenu.editColumn"), action: openStructureEditor, icon: PencilRuler });
+ }
if (canOpenFieldLineage.value) {
+ columnActions.push({ label: t("lineage.open"), action: openFieldLineage, icon: Network });
+ }
+ if (columnActions.length > 0) {
items.push({ label: "", separator: true });
- items.push({ label: t("lineage.open"), action: openFieldLineage, icon: Network });
+ items.push(...columnActions);
}
if (canDropTableChildObject.value) {
items.push({ label: "", separator: true });
@@ -4775,6 +4797,10 @@ function treeItemMenuItems(): ContextMenuItem[] {
if (node.type === "index" || node.type === "fkey" || node.type === "trigger") {
items.push({ label: t("contextMenu.copyName"), action: copyName, icon: Copy, shortcut: shortcutCopyName.value });
+ if (node.type === "index" && canOpenStructureEditor.value) {
+ items.push({ label: "", separator: true });
+ items.push({ label: t("contextMenu.editIndex"), action: openStructureEditor, icon: PencilRuler });
+ }
if (node.type === "index" && canDropMongoIndex.value) {
items.push({ label: "", separator: true });
items.push({
diff --git a/apps/desktop/src/components/structure/TableStructureEditor.vue b/apps/desktop/src/components/structure/TableStructureEditor.vue
index 743d7c8484..79735641b5 100644
--- a/apps/desktop/src/components/structure/TableStructureEditor.vue
+++ b/apps/desktop/src/components/structure/TableStructureEditor.vue
@@ -28,7 +28,7 @@ import { PRESET_FIELDS_TEMPLATE_ID, createTableColumnTemplateDrafts } from "@/li
import { getTableMetadataCapabilities } from "@/lib/table/tableMetadataCapabilities";
import { canAddTableStructureColumn, getTableStructureCapabilities } from "@/lib/table/tableStructureCapabilities";
import { connectionObjectTreeQuerySchema, tableStructureDatabaseTypeForConnection } from "@/lib/database/jdbcDialect";
-import type { TableInfoTab, TableStructureEditorDraft } from "@/types/database";
+import type { TableInfoTab, TableStructureEditorDraft, TableStructureEditorTarget } from "@/types/database";
import {
buildStructureTargetLabel,
combineDataTypeForDatabase,
@@ -85,6 +85,7 @@ const props = defineProps<{
tableName: string;
initialTab?: TableInfoTab;
initialTabRequestId?: number;
+ initialTarget?: TableStructureEditorTarget;
draft?: TableStructureEditorDraft;
}>();
@@ -494,8 +495,12 @@ const resizing = ref<{ col: number; startX: number; startW: number } | null>(nul
const columnSearchInputRef = ref<InstanceType<typeof Input>>();
const columnSearchText = ref("");
const highlightedColumnId = ref<string | null>(null);
+const indexSearchInputRef = ref<InstanceType<typeof Input>>();
+const indexSearchText = ref("");
+const highlightedIndexId = ref<string | null>(null);
const sqlPreviewCollapsed = ref(loadSqlPreviewCollapsed());
let columnHighlightTimer: ReturnType<typeof window.setTimeout> | undefined;
+let indexHighlightTimer: ReturnType<typeof window.setTimeout> | undefined;
watch(
structureDensity,
@@ -689,6 +694,12 @@ const filteredColumnRowIds = computed(() => {
);
});
const columnSearchMatchCount = computed(() => (columnSearchText.value.trim() ? filteredColumnRowIds.value.size : 0));
+const filteredIndexRowIds = computed(() => {
+ const query = indexSearchText.value.trim().toLowerCase();
+ if (!query) return new Set<string>();
+ return new Set(indexes.value.filter((index) => indexMatchesSearch(index, query)).map((index) => index.id));
+});
+const indexSearchMatchCount = computed(() => (indexSearchText.value.trim() ? filteredIndexRowIds.value.size : 0));
const foreignKeyActionOptions = ["", "CASCADE", "SET NULL", "RESTRICT", "NO ACTION"];
const triggerTimingOptions = ["BEFORE", "AFTER"];
const triggerEventOptions = ["INSERT", "UPDATE", "DELETE"];
@@ -723,6 +734,10 @@ let restoringDraft = false;
let syncingDraft = false;
let draftHydrated = false;
let hydratingRestoredDraft = false;
+// A context-menu target may arrive before metadata rows render, so search text
+// and row scrolling are tracked separately for each request.
+let appliedInitialTargetSearchKey = "";
+let appliedInitialTargetScrollKey = "";
function cloneDraftValue<T>(value: T): T {
return JSON.parse(JSON.stringify(value)) as T;
@@ -977,6 +992,12 @@ function resetState() {
newTableName.value = "";
tableComment.value = "";
originalTableComment.value = "";
+ columnSearchText.value = "";
+ highlightedColumnId.value = null;
+ indexSearchText.value = "";
+ highlightedIndexId.value = null;
+ appliedInitialTargetSearchKey = "";
+ appliedInitialTargetScrollKey = "";
}
async function reloadStructureFromDatabase() {
@@ -1441,6 +1462,76 @@ function onColumnSearchKeydown(event: KeyboardEvent) {
scrollToColumnSearchMatch(event.shiftKey ? -1 : 1);
}
+function indexMatchesSearch(index: EditableStructureIndex, searchQuery = indexSearchText.value.trim().toLowerCase()): boolean {
+ if (!searchQuery) return false;
+ return [index.name, toColumnNames(index.columns), index.includedColumns.join(", "), index.indexType, index.filter, index.comment].some((value) =>
+ String(value ?? "")
+ .toLowerCase()
+ .includes(searchQuery),
+ );
+}
+
+function indexFieldMatchesSearch(value: string | null | undefined): boolean {
+ const query = indexSearchText.value.trim().toLowerCase();
+ return (
+ !!query &&
+ String(value ?? "")
+ .toLowerCase()
+ .includes(query)
+ );
+}
+
+function indexRowClass(index: EditableStructureIndex) {
+ const isSearchMatch = filteredIndexRowIds.value.has(index.id);
+ return {
+ "bg-destructive/5 opacity-60": index.markedForDrop,
+ "structure-column-search-match": isSearchMatch,
+ "structure-column-search-current": highlightedIndexId.value === index.id,
+ };
+}
+
+function indexSearchFieldClass(index: EditableStructureIndex, value: string | null | undefined) {
+ const matches = indexFieldMatchesSearch(value);
+ return {
+ "!border-primary/60 !bg-primary/10": matches,
+ "!border-primary !ring-2 !ring-primary/30": matches && highlightedIndexId.value === index.id,
+ };
+}
+
+function focusIndexSearch() {
+ activeTab.value = "indexes";
+ void nextTick(() => {
+ const input = indexSearchInputRef.value?.$el as HTMLInputElement | undefined;
+ input?.focus();
+ input?.select();
+ });
+}
+
+function scrollToIndexSearchMatch(direction: 1 | -1 = 1) {
+ const query = indexSearchText.value.trim();
+ if (!query) {
+ focusIndexSearch();
+ return;
+ }
+ const rows = Array.from(rootRef.value?.querySelectorAll<HTMLElement>("[data-index-row-index]") ?? []);
+ const matches = indexes.value.map((index, rowIndex) => ({ index, rowIndex })).filter(({ index }) => indexMatchesSearch(index));
+ if (!matches.length) return;
+ const currentIndex = highlightedIndexId.value ? matches.findIndex(({ index }) => index.id === highlightedIndexId.value) : -1;
+ const nextMatch = matches[(currentIndex + direction + matches.length) % matches.length] ?? matches[0];
+ highlightedIndexId.value = nextMatch.index.id;
+ rows[nextMatch.rowIndex]?.scrollIntoView({ block: "center", inline: "nearest" });
+ if (indexHighlightTimer) window.clearTimeout(indexHighlightTimer);
+ indexHighlightTimer = window.setTimeout(() => {
+ highlightedIndexId.value = null;
+ }, 1800);
+}
+
+function onIndexSearchKeydown(event: KeyboardEvent) {
+ if (event.key !== "Enter") return;
+ event.preventDefault();
+ scrollToIndexSearchMatch(event.shiftKey ? -1 : 1);
+}
+
function columnDragInsertionIndex(index: number, event: DragEvent): number {
const target = event.currentTarget;
if (!(target instanceof HTMLElement)) return index;
@@ -1816,16 +1907,18 @@ function unregisterStructureEditorShortcuts() {
onMounted(() => {
resetState();
applyInitialStructureTab();
+ applyInitialStructureTarget();
registerStructureEditorShortcuts();
void loadDynamicDataTypeOptions();
if (props.draft?.initialized) {
restoreDraft(props.draft);
applyInitialStructureTab();
- void hydrateRestoredDraftFromDatabase();
+ applyInitialStructureTarget();
+ void hydrateRestoredDraftFromDatabase().then(() => applyInitialStructureTarget());
} else if (isCreateMode.value) {
markDraftHydratedAndSync();
} else {
- void loadStructure(false, FULL_STRUCTURE_REFRESH_SCOPE, true, { blockSecondaryMetadata: true });
+ void loadStructure(false, FULL_STRUCTURE_REFRESH_SCOPE, true, { blockSecondaryMetadata: true }).then(() => applyInitialStructureTarget());
}
});
@@ -1834,7 +1927,8 @@ onActivated(() => {
void loadDynamicDataTypeOptions();
if (props.draft?.initialized && !draftHydrated) {
restoreDraft(props.draft);
- void hydrateRestoredDraftFromDatabase();
+ applyInitialStructureTarget();
+ void hydrateRestoredDraftFromDatabase().then(() => applyInitialStructureTarget());
}
});
onDeactivated(unregisterStructureEditorShortcuts);
@@ -1843,6 +1937,7 @@ onBeforeUnmount(() => {
unregisterStructureEditorShortcuts();
clearSqlPreviewState();
if (columnHighlightTimer) window.clearTimeout(columnHighlightTimer);
+ if (indexHighlightTimer) window.clearTimeout(indexHighlightTimer);
persistStructureDensity();
});
@@ -1869,13 +1964,53 @@ function applyInitialStructureTab() {
activeTab.value = resolveStructureMetadataTab(props.initialTab);
}
+function initialTargetKey(target: TableStructureEditorTarget): string {
+ return `${props.initialTabRequestId ?? 0}:${target.kind}:${target.name}`;
+}
+
+function applyInitialStructureTarget() {
+ const target = props.initialTarget;
+ const targetName = target?.name.trim();
+ if (!target || !targetName) return;
+
+ const key = initialTargetKey(target);
+ if (appliedInitialTargetSearchKey !== key) {
+ if (target.kind === "column") {
+ activeTab.value = resolveStructureMetadataTab("columns");
+ columnSearchText.value = targetName;
+ highlightedColumnId.value = null;
+ } else {
+ activeTab.value = resolveStructureMetadataTab("indexes");
+ indexSearchText.value = targetName;
+ highlightedIndexId.value = null;
+ }
+ appliedInitialTargetSearchKey = key;
+ }
+
+ if (appliedInitialTargetScrollKey === key) return;
+ const hasMatch = target.kind === "column" ? columns.value.some((column) => columnMatchesSearch(column)) : indexes.value.some((index) => indexMatchesSearch(index));
+ if (!hasMatch) return;
+ appliedInitialTargetScrollKey = key;
+ void nextTick(() => {
+ if (target.kind === "column") {
+ scrollToColumnSearchMatch(1);
+ } else {
+ scrollToIndexSearchMatch(1);
+ }
+ });
+}
+
watch(tableMetadataCapabilities, (capabilities) => {
if (!isStructureMetadataTabSupported(activeTab.value, capabilities)) activeTab.value = firstStructureMetadataTab(capabilities);
});
-watch([() => props.initialTab, () => props.initialTabRequestId], () => {
- if (!props.initialTab) return;
- applyInitialStructureTab();
+watch([() => props.initialTab, () => props.initialTabRequestId, () => props.initialTarget], () => {
+ if (props.initialTab) applyInitialStructureTab();
+ applyInitialStructureTarget();
+});
+
+watch([columns, indexes], () => {
+ applyInitialStructureTarget();
});
watch([() => props.connectionId, () => props.database, databaseType], () => {
@@ -1893,6 +2028,7 @@ watch(
watch(activeTab, () => {
highlightedColumnId.value = null;
+ highlightedIndexId.value = null;
syncDraftToParent();
});
@@ -2036,6 +2172,19 @@ watch(activeTab, (tab) => {
</TooltipTrigger>
<TooltipContent>{{ t("structureEditor.configureColumnTemplates") }}</TooltipContent>
</Tooltip>
+ <div v-if="activeTab === 'indexes'" class="relative flex w-40 shrink-0 items-center">
+ <Search :class="[structureIconClass, 'pointer-events-none absolute left-2 text-muted-foreground']" />
+ <Input ref="indexSearchInputRef" v-model="indexSearchText" :placeholder="t('structureEditor.searchIndexes')" :class="[structureControlClass, 'pl-7 pr-14 text-[length:var(--structure-font-size)] placeholder:text-[length:var(--structure-font-size)]']" @keydown="onIndexSearchKeydown" />
+ <button
+ v-if="indexSearchText"
+ type="button"
+ class="absolute right-1.5 top-1/2 -translate-y-1/2 rounded px-1 text-[length:var(--structure-font-size)] text-muted-foreground hover:bg-muted hover:text-foreground"
+ :title="t('structureEditor.nextIndexMatch')"
+ @click="scrollToIndexSearchMatch(1)"
+ >
+ {{ indexSearchMatchCount }}
+ </button>
+ </div>
<Button v-if="activeTab === 'indexes'" size="sm" :class="structureToolbarButtonClass" :disabled="!structureCapabilities.createIndex || indexesLoading" @click="addIndex">
<Plus :class="structureIconClass" />
{{ t("structureEditor.addIndex") }}
@@ -2345,9 +2494,9 @@ watch(activeTab, (tab) => {
</tr>
</thead>
<tbody>
- <tr v-for="index in indexes" :key="index.id" :class="index.markedForDrop ? 'bg-destructive/5 opacity-60' : ''" :data-new-index-row="!index.original ? 'true' : undefined">
+ <tr v-for="(index, rowIndex) in indexes" :key="index.id" :class="indexRowClass(index)" :data-new-index-row="!index.original ? 'true' : undefined" :data-index-row-index="rowIndex">
<td :class="structureCellClass">
- <Input :model-value="index.name" :class="structureControlClass" :disabled="!canEditIndexDraft(index)" data-index-name-input @update:model-value="(value: string | number) => onIndexNameInput(index, value)" />
+ <Input :model-value="index.name" :class="[structureControlClass, indexSearchFieldClass(index, index.name)]" :disabled="!canEditIndexDraft(index)" data-index-name-input @update:model-value="(value: string | number) => onIndexNameInput(index, value)" />
</td>
<td :class="[structureCellClass, 'overflow-hidden']">
<DropdownMenu v-if="canEditIndexDraft(index)">
@@ -2405,10 +2554,10 @@ watch(activeTab, (tab) => {
<span v-else class="text-[length:var(--structure-font-size)] text-muted-foreground">{{ index.includedColumns.join(", ") }}</span>
</td>
<td :class="structureCellClass">
- <Input v-model="index.filter" :class="structureMonoControlClass" :placeholder="index.original?.filter || ''" :disabled="!canEditIndexFilter(index)" />
+ <Input v-model="index.filter" :class="[structureMonoControlClass, indexSearchFieldClass(index, index.filter)]" :placeholder="index.original?.filter || ''" :disabled="!canEditIndexFilter(index)" />
</td>
<td :class="structureCellClass">
- <Input v-model="index.comment" :class="structureControlClass" :disabled="!canEditIndexComment(index)" />
+ <Input v-model="index.comment" :class="[structureControlClass, indexSearchFieldClass(index, index.comment)]" :disabled="!canEditIndexComment(index)" />
</td>
<td :class="structureLastCellClass">
<Badge v-if="index.isPrimary" variant="outline">{{ t("structureEditor.primary") }}</Badge>
diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts
index f1b3ddf10e..6931f91534 100644
--- a/apps/desktop/src/i18n/locales/en.ts
+++ b/apps/desktop/src/i18n/locales/en.ts
@@ -169,6 +169,8 @@ export default {
createDuckDbFile: "Create DuckDB file",
createSqliteFile: "Create SQLite database",
memoryDatabasePathHint: "Use :memory: to create an in-memory SQLite or DuckDB database.",
+ sqliteCipherKey: "SQLCipher Key",
+ sqliteCipherKeyPlaceholder: "Leave empty for unencrypted SQLite",
sqliteExtensions: "SQLite Extensions",
sqliteExtensionsPlaceholder: "/path/to/regexp.dylib\n/path/to/text.dylib|sqlite3_text_init",
sqliteExtensionsHint: "One .dylib/.so/.dll per line. Use “path|entry point” when an entry point is required. Loaded on connect, then load_extension is disabled.",
@@ -1321,6 +1323,8 @@ export default {
openObjectBrowser: "Browse Objects",
viewData: "View Data",
editStructure: "Edit Structure",
+ editColumn: "Edit Column",
+ editIndex: "Edit Index",
refreshChildren: "Refresh",
expandAll: "Expand All",
pin: "Pin",
@@ -1693,6 +1697,8 @@ export default {
presetFieldsTemplate: "Preset Field Set",
searchColumns: "Search column/comment",
nextColumnMatch: "Go to next matching column",
+ searchIndexes: "Search index",
+ nextIndexMatch: "Go to next matching index",
addIndex: "Add Index",
addForeignKey: "Add Foreign Key",
addTrigger: "Add Trigger",
diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.ts
index d02238e521..1a0bff4615 100644
--- a/apps/desktop/src/i18n/locales/es.ts
+++ b/apps/desktop/src/i18n/locales/es.ts
@@ -171,6 +171,8 @@ export default withEnglishFallback({
createDuckDbFile: "Crear archivo DuckDB",
createSqliteFile: "Crear base de datos SQLite",
memoryDatabasePathHint: "Usa :memory: para crear una base de datos SQLite o DuckDB en memoria.",
+ sqliteCipherKey: "Clave SQLCipher",
+ sqliteCipherKeyPlaceholder: "Déjalo vacío para SQLite sin cifrar",
sqliteExtensions: "Extensiones de SQLite",
sqliteExtensionsPlaceholder: "/ruta/a/regexp.dylib\n/ruta/a/text.dylib|sqlite3_text_init",
sqliteExtensionsHint: 'Una .dylib/.so/.dll por línea. Usa "ruta|punto de entrada" cuando se requiera un punto de entrada. Se cargan al conectar, luego load_extension se deshabilita.',
@@ -1279,6 +1281,8 @@ export default withEnglishFallback({
openObjectBrowser: "Explorar objetos",
viewData: "Ver datos",
editStructure: "Editar estructura",
+ editColumn: "Editar columna",
+ editIndex: "Editar índice",
refreshChildren: "Actualizar",
expandAll: "Expandir todo",
pin: "Fijar",
@@ -1637,6 +1641,8 @@ export default withEnglishFallback({
presetFieldsTemplate: "Conjunto de campos predefinidos",
searchColumns: "Buscar columna/comentario",
nextColumnMatch: "Ir a la siguiente columna coincidente",
+ searchIndexes: "Buscar índice",
+ nextIndexMatch: "Ir al siguiente índice coincidente",
addIndex: "Agregar índice",
addForeignKey: "Agregar clave foránea",
addTrigger: "Agregar disparador",
diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.ts
index 6ad47c7a52..309ba7b7cb 100644
--- a/apps/desktop/src/i18n/locales/it.ts
+++ b/apps/desktop/src/i18n/locales/it.ts
@@ -170,6 +170,8 @@ export default withEnglishFallback({
createDuckDbFile: "Crea file DuckDB",
createSqliteFile: "Crea database SQLite",
memoryDatabasePathHint: "Usa :memory: per creare un database SQLite o DuckDB in memoria.",
+ sqliteCipherKey: "Chiave SQLCipher",
+ sqliteCipherKeyPlaceholder: "Lascia vuoto per SQLite non cifrato",
sqliteExtensions: "Estensioni SQLite",
sqliteExtensionsPlaceholder: "/percorso/per/regexp.dylib\n/percorso/per/text.dylib|sqlite3_text_init",
sqliteExtensionsHint: "Una .dylib/.so/.dll per riga. Usa “percorso|punto di ingresso” quando è richiesto un punto di ingresso. Caricata alla connessione, poi load_extension viene disabilitata.",
@@ -1277,6 +1279,8 @@ export default withEnglishFallback({
openObjectBrowser: "Esplora Oggetti",
viewData: "Visualizza Dati",
editStructure: "Modifica Struttura",
+ editColumn: "Modifica Colonna",
+ editIndex: "Modifica Indice",
refreshChildren: "Aggiorna",
expandAll: "Espandi tutto",
pin: "Fissa",
@@ -1635,6 +1639,8 @@ export default withEnglishFallback({
presetFieldsTemplate: "Set di campi predefiniti",
searchColumns: "Cerca colonna/commento",
nextColumnMatch: "Vai alla prossima colonna corrispondente",
+ searchIndexes: "Cerca indice",
+ nextIndexMatch: "Vai al prossimo indice corrispondente",
addIndex: "Aggiungi Indice",
addForeignKey: "Aggiungi Chiave Esterna",
addTrigger: "Aggiungi Trigger",
diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.ts
index 1def0686e4..b09a0b29c9 100644
--- a/apps/desktop/src/i18n/locales/ja.ts
+++ b/apps/desktop/src/i18n/locales/ja.ts
@@ -170,6 +170,8 @@ export default withEnglishFallback({
createDuckDbFile: "DuckDBファイルを作成",
createSqliteFile: "SQLiteデータベースを作成",
memoryDatabasePathHint: "インメモリのSQLiteまたはDuckDBデータベースを作成するには :memory: を使用してください。",
+ sqliteCipherKey: "SQLCipherキー",
+ sqliteCipherKeyPlaceholder: "暗号化されていないSQLiteでは空のままにします",
sqliteExtensions: "SQLite拡張",
sqliteExtensionsPlaceholder: "/path/to/regexp.dylib\n/path/to/text.dylib|sqlite3_text_init",
sqliteExtensionsHint: "1行に1つの.dylib/.so/.dllファイルを指定します。エントリポイントが必要な場合は「パス|エントリポイント」形式で指定します。接続時に読み込まれ、その後load_extensionは無効になります。",
@@ -1275,6 +1277,8 @@ export default withEnglishFallback({
openObjectBrowser: "オブジェクトを参照",
viewData: "データを表示",
editStructure: "構造を編集",
+ editColumn: "列を編集",
+ editIndex: "インデックスを編集",
refreshChildren: "更新",
expandAll: "すべて展開",
pin: "ピン留め",
@@ -1668,6 +1672,8 @@ export default withEnglishFallback({
presetFieldsTemplate: "プリセット列セット",
searchColumns: "列/コメントを検索",
nextColumnMatch: "次の一致する列へ移動",
+ searchIndexes: "インデックスを検索",
+ nextIndexMatch: "次の一致するインデックスへ移動",
addIndex: "インデックスを追加",
addForeignKey: "外部キーを追加",
addTrigger: "トリガーを追加",
diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.ts
index aa53112898..4e5c280ac1 100644
--- a/apps/desktop/src/i18n/locales/pt-BR.ts
+++ b/apps/desktop/src/i18n/locales/pt-BR.ts
@@ -171,6 +171,8 @@ export default withEnglishFallback({
createDuckDbFile: "Criar arquivo DuckDB",
createSqliteFile: "Criar banco de dados SQLite",
memoryDatabasePathHint: "Use :memory: para criar um banco de dados SQLite ou DuckDB na memória.",
+ sqliteCipherKey: "Chave SQLCipher",
+ sqliteCipherKeyPlaceholder: "Deixe vazio para SQLite não criptografado",
sqliteExtensions: "Extensões SQLite",
sqliteExtensionsPlaceholder: "/caminho/para/regexp.dylib\n/caminho/para/text.dylib|sqlite3_text_init",
sqliteExtensionsHint: "Um .dylib/.so/.dll por linha. Use “caminho|ponto de entrada” quando um ponto de entrada for necessário. Carregado ao conectar, depois load_extension é desabilitado.",
@@ -1278,6 +1280,8 @@ export default withEnglishFallback({
openObjectBrowser: "Explorar Objetos",
viewData: "Ver Dados",
editStructure: "Editar Estrutura",
+ editColumn: "Editar Coluna",
+ editIndex: "Editar Índice",
refreshChildren: "Atualizar",
expandAll: "Expandir tudo",
pin: "Fixar",
@@ -1636,6 +1640,8 @@ export default withEnglishFallback({
presetFieldsTemplate: "Conjunto de campos predefinidos",
searchColumns: "Pesquisar coluna/comentário",
nextColumnMatch: "Ir para a próxima coluna correspondente",
+ searchIndexes: "Pesquisar índice",
+ nextIndexMatch: "Ir para o próximo índice correspondente",
addIndex: "Adicionar índice",
addForeignKey: "Adicionar chave estrangeira",
addTrigger: "Adicionar trigger",
diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts
index bc9179817e..3a363733f4 100644
--- a/apps/desktop/src/i18n/locales/zh-CN.ts
+++ b/apps/desktop/src/i18n/locales/zh-CN.ts
@@ -171,6 +171,8 @@ export default withEnglishFallback({
createDuckDbFile: "新建 DuckDB 文件",
createSqliteFile: "新建 SQLite 数据库",
memoryDatabasePathHint: "输入 :memory: 可创建 SQLite 或 DuckDB 内存数据库。",
+ sqliteCipherKey: "SQLCipher 密码(密钥)",
+ sqliteCipherKeyPlaceholder: "未加密 SQLite 留空",
sqliteExtensions: "SQLite 扩展库",
sqliteExtensionsPlaceholder: "/path/to/regexp.dylib\n/path/to/text.dylib|sqlite3_text_init",
sqliteExtensionsHint: "每行一个 .dylib/.so/.dll;需要入口函数时使用“路径|入口函数”。连接时加载,加载后会关闭 load_extension。",
@@ -1323,6 +1325,8 @@ export default withEnglishFallback({
openObjectBrowser: "浏览对象",
viewData: "查看数据",
editStructure: "编辑表结构",
+ editColumn: "编辑字段",
+ editIndex: "编辑索引",
refreshChildren: "刷新",
expandAll: "展开全部",
pin: "置顶",
@@ -1693,6 +1697,8 @@ export default withEnglishFallback({
presetFieldsTemplate: "预设字段组合",
searchColumns: "搜索字段/注释",
nextColumnMatch: "定位下一个匹配字段",
+ searchIndexes: "搜索索引",
+ nextIndexMatch: "定位下一个匹配索引",
addIndex: "新增索引",
addForeignKey: "新增外键",
addTrigger: "新增触发器",
diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.ts
index 6a7ba99b78..6338942921 100644
--- a/apps/desktop/src/i18n/locales/zh-TW.ts
+++ b/apps/desktop/src/i18n/locales/zh-TW.ts
@@ -171,6 +171,8 @@ export default withEnglishFallback({
createDuckDbFile: "建立 DuckDB 檔案",
createSqliteFile: "建立 SQLite 資料庫",
memoryDatabasePathHint: "輸入 :memory: 可建立 SQLite 或 DuckDB 記憶體資料庫。",
+ sqliteCipherKey: "SQLCipher 密碼(密鑰)",
+ sqliteCipherKeyPlaceholder: "未加密 SQLite 留空",
sqliteExtensions: "SQLite 擴充庫",
sqliteExtensionsPlaceholder: "/path/to/regexp.dylib\n/path/to/text.dylib|sqlite3_text_init",
sqliteExtensionsHint: "每行一個 .dylib/.so/.dll;需要入口函式時使用「路徑|入口函式」。連線時載入,載入後會關閉 load_extension。",
@@ -1278,6 +1280,8 @@ export default withEnglishFallback({
openObjectBrowser: "瀏覽物件",
viewData: "檢視資料",
editStructure: "編輯資料表結構",
+ editColumn: "編輯欄位",
+ editIndex: "編輯索引",
refreshChildren: "重新整理",
expandAll: "展開全部",
pin: "置頂",
@@ -1591,6 +1595,8 @@ export default withEnglishFallback({
presetFieldsTemplate: "預設欄位組合",
searchColumns: "搜尋欄位/註解",
nextColumnMatch: "定位下一個符合欄位",
+ searchIndexes: "搜尋索引",
+ nextIndexMatch: "定位下一個符合索引",
addIndex: "新增索引",
addForeignKey: "新增外鍵",
addTrigger: "新增觸發器",
diff --git a/apps/desktop/src/stores/queryStore.ts b/apps/desktop/src/stores/queryStore.ts
index 5a1b83ad80..5cfbffb11c 100644
--- a/apps/desktop/src/stores/queryStore.ts
+++ b/apps/desktop/src/stores/queryStore.ts
@@ -2,7 +2,7 @@ import { defineStore } from "pinia";
import { uuid } from "@/lib/common/utils";
import { markRaw, ref, watch, computed } from "vue";
import { useI18n } from "vue-i18n";
-import type { DatabaseType, QueryResult, QueryTab, TableInfoTab } from "@/types/database";
+import type { DatabaseType, QueryResult, QueryTab, TableInfoTab, TableStructureEditorTarget } from "@/types/database";
import { orderPinnedFirst } from "@/lib/app/pinnedItems";
import { canCancelQueryExecution } from "@/lib/sql/queryExecutionState";
import { buildExplainSql, parseExplainResult, parseDamengExplainText } from "@/lib/diagram/explainPlan";
@@ -885,18 +885,19 @@ export const useQueryStore = defineStore("query", () => {
return id;
}
- function applyTableStructureInitialTab(tab: QueryTab, initialTab?: TableInfoTab) {
- if (!initialTab) return;
- tab.structureInitialTab = initialTab;
+ function applyTableStructureInitialTab(tab: QueryTab, initialTab?: TableInfoTab, initialTarget?: TableStructureEditorTarget) {
+ if (!initialTab && !initialTarget?.name) return;
+ if (initialTab) tab.structureInitialTab = initialTab;
+ tab.structureInitialTarget = initialTarget?.name ? initialTarget : undefined;
tab.structureInitialTabRequestId = (tab.structureInitialTabRequestId ?? 0) + 1;
}
- function openTableStructure(connectionId: string, database: string, schema?: string, tableName?: string, initialTab?: TableInfoTab) {
+ function openTableStructure(connectionId: string, database: string, schema?: string, tableName?: string, initialTab?: TableInfoTab, initialTarget?: TableStructureEditorTarget) {
const resolvedTableName = tableName || "";
if (resolvedTableName) {
const existing = tabs.value.find((tab) => tab.mode === "structure" && tab.connectionId === connectionId && tab.database === database && (tab.structureTableName || "") === resolvedTableName);
if (existing) {
- applyTableStructureInitialTab(existing, initialTab);
+ applyTableStructureInitialTab(existing, initialTab, initialTarget);
activeTabId.value = existing.id;
return existing.id;
}
@@ -917,7 +918,8 @@ export const useQueryStore = defineStore("query", () => {
mode: "structure",
structureTableName: resolvedTableName,
structureInitialTab: initialTab,
- structureInitialTabRequestId: initialTab ? 1 : undefined,
+ structureInitialTabRequestId: initialTab || initialTarget?.name ? 1 : undefined,
+ structureInitialTarget: initialTarget?.name ? initialTarget : undefined,
};
tabs.value.push(tab);
activeTabId.value = id;
diff --git a/apps/desktop/src/types/database.ts b/apps/desktop/src/types/database.ts
index eebf9ecead..a82f0575cd 100644
--- a/apps/desktop/src/types/database.ts
+++ b/apps/desktop/src/types/database.ts
@@ -612,6 +612,11 @@ export interface TreeNode {
export type TableInfoTab = "columns" | "indexes" | "foreignKeys" | "triggers" | "ddl";
+export interface TableStructureEditorTarget {
+ kind: "column" | "index";
+ name: string;
+}
+
export interface TableStructureEditorDraft {
activeTab: TableInfoTab;
newTableName: string;
@@ -687,6 +692,7 @@ export interface QueryTab {
structureTableName?: string;
structureInitialTab?: TableInfoTab;
structureInitialTabRequestId?: number;
+ structureInitialTarget?: TableStructureEditorTarget;
structureDraft?: TableStructureEditorDraft;
objectBrowser?: {
schema?: string;
diff --git a/packages/app-tests/queryStore.test.ts b/packages/app-tests/queryStore.test.ts
index ff1b7d0f8b..8e75ea2d61 100644
--- a/packages/app-tests/queryStore.test.ts
+++ b/packages/app-tests/queryStore.test.ts
@@ -3526,19 +3526,26 @@ test("reopening table structure tabs records the requested initial tab", () => {
setActivePinia(createPinia());
const store = useQueryStore();
- const structureId = store.openTableStructure("conn-1", "db", "public", "users", "indexes");
+ const structureId = store.openTableStructure("conn-1", "db", "public", "users", "indexes", { kind: "index", name: "idx_users_email" });
const firstTab = store.tabs.find((item) => item.id === structureId);
assert.equal(firstTab?.structureInitialTab, "indexes");
assert.equal(firstTab?.structureInitialTabRequestId, 1);
+ assert.deepEqual(firstTab?.structureInitialTarget, { kind: "index", name: "idx_users_email" });
- const reusedStructureId = store.openTableStructure("conn-1", "db", "public", "users", "foreignKeys");
+ const reusedStructureId = store.openTableStructure("conn-1", "db", "public", "users", "columns", { kind: "column", name: "email" });
const reusedTab = store.tabs.find((item) => item.id === reusedStructureId);
assert.equal(reusedStructureId, structureId);
- assert.equal(reusedTab?.structureInitialTab, "foreignKeys");
+ assert.equal(reusedTab?.structureInitialTab, "columns");
assert.equal(reusedTab?.structureInitialTabRequestId, 2);
+ assert.deepEqual(reusedTab?.structureInitialTarget, { kind: "column", name: "email" });
assert.equal(store.activeTabId, structureId);
+
+ store.openTableStructure("conn-1", "db", "public", "users", "foreignKeys");
+ assert.equal(reusedTab?.structureInitialTab, "foreignKeys");
+ assert.equal(reusedTab?.structureInitialTabRequestId, 3);
+ assert.equal(reusedTab?.structureInitialTarget, undefined);
} finally {
restoreStorage();
}