feat(spanner): add Google Cloud Spanner support

This commit is contained in:
Frost authored and GitHub committed 2026-08-20 16:33:09 +08:00
1 parent 2cc8d78e64
commit f494f90c30
74 files changed
+2920 -53

No files matched your search

@@ -105,6 +105,7 @@ import {
supportsPackageMemberExpansion,
usesTreeSchemaMode,
isSingleDatabase,
schemaNodeHasLoadableName,
} from "@/lib/database/databaseCapabilities";
import { copyDisplayPathForTreeNode, copyNameForTreeNode, isDirectNavigationTreeNode, isDocumentBrowserTreeNode, isRepeatableNavigationTreeNode, objectSourceTargetForTreeNode, shouldRunTreeNodeRowAction, treeNodeRowAction, treeNodeRowDoubleClickAction } from "@/lib/sidebar/treeNodeClick";
import { customTypeCapabilities, supportsTypeObjectSource } from "@/lib/database/databaseObjectCapabilities";
@@ -896,7 +897,7 @@ async function toggle(requestId = beginNavigationRequest()) {
}
} else if (node.type === "doris-catalog" && node.connectionId) {
await connectionStore.loadDorisCatalogDatabases(node, treeLoadSearchOptions);
} else if (node.type === "schema" && node.connectionId && hasTreeNodeDatabaseContext(node) && node.schema) {
} else if (node.type === "schema" && node.connectionId && hasTreeNodeDatabaseContext(node) && schemaNodeHasLoadableName(effectiveDatabaseTypeForConnection(connectionStore.getConfig(node.connectionId)), node.schema)) {
await connectionStore.loadTables(node.connectionId, node.database, node.schema, treeLoadSearchOptions);
} else if (node.type === "linked-server-root" && node.connectionId) {
await connectionStore.loadSqlServerLinkedServers(node.connectionId, treeLoadSearchOptions);
@@ -1990,6 +1991,8 @@ function dropObjectSqlOptionsForNode(node: TreeNode): DropObjectSqlOptions | nul
schema: node.schema,
name: node.objectName || node.label,
signature: node.signature,
// Cloud Spanner's dialect decides the quote; the static per-type mapping cannot.
identifierQuote: connectionStore.connectionIdentifierQuote?.(node.connectionId),
};
}
@@ -3638,6 +3641,7 @@ async function confirmDuplicateStructure() {
sourceName: node.label,
targetName: newName,
tableComment: node.comment,
identifierQuote: connectionStore.connectionIdentifierQuote?.(node.connectionId),
});
await executeTreeNodeSqlWithProductionGuard(node, plan.sql, {
database: node.database,
@@ -3688,6 +3692,7 @@ async function confirmPasteTable() {
sourceName: entry.sourceName,
targetName,
tableComment: entry.tableComment,
identifierQuote: connectionStore.connectionIdentifierQuote?.(entry.connectionId),
});
sourceColumns = plan.sourceColumns;
const structureExecuted = await executeTreeNodeSqlWithProductionGuard(entry, plan.sql, {
@@ -3716,6 +3721,7 @@ async function confirmPasteTable() {
sourceName: entry.sourceName,
targetName,
normalizeNewTargetName: mode === "structure-and-data",
identifierQuote: connectionStore.connectionIdentifierQuote?.(entry.connectionId),
...dataCopyColumnOptions,
});
const dataExecuted = await executeTreeNodeSqlWithProductionGuard(entry, dataSql, { database: entry.database, schema: entry.schema });
@@ -58,6 +58,7 @@ import { formatSidebarObjectStorage } from "@/lib/sidebar/sidebarDatabaseStorage
import { dataTabOpenModeFromTreeClick } from "@/lib/sidebar/dataTabOpenPolicy";
import { effectiveDatabaseTypeForConnection } from "@/lib/database/jdbcDialect";
import { connectionDisplayUrlScheme } from "@/lib/connection/connectionPresentation";
import { encodeSpannerResourcePath } from "@/lib/connection/spannerResourcePath";
import { hexToRgba } from "@/lib/common/color";
import { sidebarDisplayTableName } from "@/lib/sidebar/sidebarTableNameDisplay";
import { shouldMeasureSidebarLabelOverflow } from "@/lib/sidebar/sidebarLabelTooltip";
@@ -458,7 +459,8 @@ function connectionTooltipUrl(config: ConnectionConfig): string {
const user = cleanTooltipValue(config.username);
const userInfo = user ? `${encodeURIComponent(user)}@` : "";
const database = cleanTooltipValue(config.database);
const path = database ? `/${encodeURIComponent(database)}` : "";
const encodedDatabase = config.db_type === "spanner" ? encodeSpannerResourcePath(database) : encodeURIComponent(database);
const path = database ? `/${encodedDatabase}` : "";
const params = cleanTooltipValue(config.url_params);
const query = params ? (params.startsWith("?") ? params : `?${params}`) : "";
return redactedConnectionString(`${scheme}://${userInfo}${hostForDisplay(host)}${port}${path}${query}`);