fix(gaussdb): support M-mode type metadata

This commit is contained in:
Andrew authored and GitHub committed 2026-08-12 02:05:54 +08:00
1 parent dbe3375739
commit 26bb10dad0
13 files changed
+904 -146

No files matched your search

@@ -5,6 +5,8 @@ import { Button } from "@/components/ui/button";
import { Badge } from "@/components/ui/badge";
import { useToast } from "@/composables/useToast";
import { copyToClipboard } from "@/lib/common/clipboard";
import { gaussdbMTypeDisplayName } from "@/lib/table/postgresDataTypeHelp";
import type { DatabaseType } from "@/types/database";
export interface ColumnInfo {
name: string;
@@ -17,10 +19,12 @@ export interface ColumnInfo {
extra?: string | null;
}
defineProps<{
const props = defineProps<{
columns: ColumnInfo[];
loading: boolean;
error?: string;
databaseType?: DatabaseType;
isGaussdbM?: boolean;
}>();
const emit = defineEmits<{
@@ -30,6 +34,14 @@ const emit = defineEmits<{
const { t } = useI18n();
const { toast } = useToast();
function displayDataType(dataType: string | undefined): string {
if (!dataType) return "—";
if (props.databaseType === "gaussdb" && props.isGaussdbM) {
return gaussdbMTypeDisplayName(dataType);
}
return dataType;
}
async function copyText(text: string) {
try {
await copyToClipboard(text);
@@ -81,8 +93,8 @@ async function copyText(text: string) {
<div class="rounded-md border border-border divide-y divide-border text-xs">
<div class="flex items-center justify-between px-2 py-1">
<span class="text-muted-foreground">{{ t("grid.columnType") }}</span>
<span class="font-medium max-w-[180px] truncate" :title="col.dataType">
{{ col.dataType || "—" }}
<span class="font-medium max-w-[180px] truncate" :title="displayDataType(col.dataType)">
{{ displayDataType(col.dataType) }}
</span>
</div>
<div class="flex items-center justify-between px-2 py-1">
File diff suppressed because it is too large. Load diff
@@ -1040,7 +1040,15 @@ defineExpose({ focusSearch, refreshData, refreshQueryEditorCompletionCache, hand
@click-column="onHandleClickColumn"
@close-column-panel="onHandleCloseColumnPanel"
/>
<ColumnInfoPanel v-if="showColumnInfo" :columns="columnInfoColumns" :loading="columnInfoLoading" :error="columnInfoError" @close="closeColumnInfo" />
<ColumnInfoPanel
v-if="showColumnInfo"
:columns="columnInfoColumns"
:loading="columnInfoLoading"
:error="columnInfoError"
:database-type="activeEffectiveDatabaseType"
:is-gaussdb-m="activeEffectiveDatabaseType === 'gaussdb' && activeResultConnection?.driver_profile?.toLowerCase() === 'gaussdb-m'"
@close="closeColumnInfo"
/>
<Button v-if="hasQueryOutput && !resultsPaneOpen" variant="secondary" size="sm" class="absolute bottom-3 right-3 z-20 h-7 gap-1.5 rounded-full border bg-background/95 px-3 text-xs shadow-lg hover:bg-accent" @click="resultsPaneOpen = true">
<ChevronUp class="h-3.5 w-3.5" />
{{ t("editor.showResultsPane") }}
@@ -125,6 +125,7 @@ import { filterObjectBrowserTableColumns } from "@/lib/table/objectBrowserTableI
import { createSidePanelRequestGuard } from "@/lib/table/sidePanelRequestGuard";
import { runBatchTableTruncate } from "@/lib/table/batchTableTruncate";
import { tableColumnDefaultDisplayValue } from "@/lib/table/tableColumnDefaultPresentation";
import { gaussdbMTypeDisplayName } from "@/lib/table/postgresDataTypeHelp";
import { cacheObjectBrowserRows, createObjectBrowserRowsCacheWriteToken, getCachedObjectBrowserRows, type ObjectBrowserRowsCacheScope, type ObjectBrowserRowsCacheWriteToken } from "@/lib/table/objectBrowserRowsCache";
import { createObjectBrowserRowsLoadGuard, type ObjectBrowserRowsLoadHandle } from "@/lib/table/objectBrowserRowsLoadGuard";
@@ -202,8 +203,16 @@ const sidePanelGuard = createSidePanelRequestGuard();
const sidePanelRef = ref<InstanceType<typeof CustomTypeInfoPanel> | null>(null);
const tableMetadataCapabilities = computed<TableMetadataCapabilities>(() => getTableMetadataCapabilities(effectiveDatabaseType.value));
const effectiveDatabaseType = computed(() => effectiveDatabaseTypeForConnection(props.connection) ?? props.connection.db_type);
const isGaussdbM = computed(() => effectiveDatabaseType.value === "gaussdb" && props.connection.driver_profile?.toLowerCase() === "gaussdb-m");
const isVictoriaMetrics = computed(() => effectiveDatabaseType.value === "victoriametrics");
const objectRowsLabel = computed(() => t(isVictoriaMetrics.value ? "objects.series" : "objects.rows"));
function gaussdbMColumnType(dataType: string): string {
if (isGaussdbM.value) {
return gaussdbMTypeDisplayName(dataType);
}
return dataType;
}
const tableStructureDatabaseType = computed(() => tableStructureDatabaseTypeForConnection(props.connection) ?? props.connection.db_type);
const sourceEditableText = ref("");
const sourceDraft = ref("");
@@ -3200,7 +3209,7 @@ function getObjectBrowserMenuItems(item: ObjectBrowserRow): ContextMenuItem[] {
{{ column.comment }}
</div>
</td>
<td class="px-3 py-2 font-mono text-[11px] text-muted-foreground">{{ column.data_type }}</td>
<td class="px-3 py-2 font-mono text-[11px] text-muted-foreground">{{ gaussdbMColumnType(column.data_type) }}</td>
<td class="px-3 py-2">{{ column.is_nullable ? "YES" : "NO" }}</td>
<td data-table-info-column-default class="max-w-56 px-3 py-2 font-mono text-[11px]" :class="{ 'text-muted-foreground/70': column.column_default == null }" :title="column.column_default ?? undefined">
<span class="block max-w-56 truncate">{{ tableColumnDefaultDisplayValue(column.column_default) }}</span>
@@ -32,7 +32,7 @@ import { invalidateTableMetadataCache } from "@/lib/metadata/tableMetadataCache"
import { type BuildTableStructureChangeSqlOptions, type EditableStructureColumn, type EditableStructureForeignKey, type EditableStructureIndex, type EditableStructureTrigger } from "@/lib/table/tableStructureEditorSql";
import { PRESET_FIELDS_TEMPLATE_ID, createTableColumnTemplateDrafts } from "@/lib/table/tableColumnTemplates";
import { getMysqlDataTypeHelp } from "@/lib/table/mysqlDataTypeHelp";
import { getPostgresDataTypeHelp } from "@/lib/table/postgresDataTypeHelp";
import { getPostgresDataTypeHelp, gaussdbMTypeDisplayName } from "@/lib/table/postgresDataTypeHelp";
import { getSqliteDataTypeHelp } from "@/lib/table/sqliteDataTypeHelp";
import { getTableMetadataCapabilities, firstStructureMetadataTab, isStructureMetadataTabSupported } from "@/lib/table/tableMetadataCapabilities";
import { hasTableStructureRefreshWork, unloadedTableStructureRefreshScope, visibleTableStructureRefreshScope, type TableStructureRefreshScope } from "@/lib/table/tableStructureMetadataLoading";
@@ -1079,6 +1079,16 @@ function dataTypeTooltip(option: string): string | undefined {
return undefined;
}
function gaussdbMDataTypeDisplayName(option: string): string {
if (databaseType.value === "gaussdb") {
const conn = connection.value;
if (conn?.driver_profile?.toLowerCase() === "gaussdb-m") {
return gaussdbMTypeDisplayName(option);
}
}
return option;
}
async function loadDynamicDataTypeOptions() {
const requestId = ++dataTypeOptionsRequestId;
const connectionId = props.connectionId;
@@ -2801,10 +2811,11 @@ watch([activeTab, ddlLoading], ([tab, loading]) => {
:loading-text="t('common.loading')"
:allow-custom="true"
:option-tooltip="dataTypeTooltip"
:display-name="gaussdbMDataTypeDisplayName"
:trigger-class="[structureMonoControlClass, 'w-full']"
@update:model-value="(v: string) => updateColumnDataType(column, v)"
/>
<Input v-else :model-value="splitDataType(column.dataType).baseType" :class="[structureMonoControlClass, 'w-full']" disabled />
<Input v-else :model-value="gaussdbMDataTypeDisplayName(splitDataType(column.dataType).baseType)" :class="[structureMonoControlClass, 'w-full']" disabled />
</td>
<td v-if="columnEditorControls.length" :class="structureCellClass">
<Popover v-if="isMysqlEnumDataType(databaseType, column.dataType)">