fix(kingbase): honor MySQL-compatible identifier quoting

This commit is contained in:
dienaso authored and GitHub committed 2026-08-13 12:40:50 +08:00
1 parent 6f4f6f373e
commit 7eac5dd610
9 files changed
+150 -46

No files matched your search

@@ -76,6 +76,7 @@ import { isXuguTypeMemberContainer } from "@/lib/sidebar/xuguTypeMembers";
import { isXuguPublicSynonymTreeNode } from "@/lib/sidebar/xuguPublicSynonyms";
import { mysqlObjectTemplateForGroup } from "@/lib/sidebar/mysqlObjectTemplates";
import { buildTableDeleteTemplate, buildTableInsertTemplate, buildTableSelectTemplate, buildTableUpdateTemplate } from "@/lib/table/tableSqlTemplates";
import { qualifiedTableName } from "@/lib/table/tableSelectSql";
import { driverStoreFocusForInstallError } from "@/lib/connection/agentDriverInstallHint";
import {
canCreateConnectionNamespace,
@@ -1540,6 +1541,7 @@ async function generateDdlTemplate() {
const result = await api.getObjectSource(target.connectionId, target.database, schema, target.label, "VIEW");
return buildViewDdl({
databaseType: databaseTypeForNode(target),
identifierQuote: connectionStore.connectionIdentifierQuote?.(target.connectionId),
schema,
name: target.label,
source: result.source,
@@ -3486,7 +3488,17 @@ function createView() {
connectionStore.activeConnectionId = node.connectionId;
const viewName = "new_view";
const effectiveDbType = effectiveDatabaseTypeForConnection(connectionStore.getConfig(node.connectionId));
const viewSqlName = effectiveDbType === "informix" || !node.schema ? viewName : `${node.schema}.${viewName}`;
// Quote the schema/name with the driver-reported identifier quote so
// hyphenated schemas (Kingbase MySQL compat) render as valid identifiers.
const viewSqlName =
effectiveDbType === "informix" || !node.schema
? viewName
: qualifiedTableName({
databaseType: effectiveDbType,
identifierQuote: connectionStore.connectionIdentifierQuote?.(node.connectionId),
schema: node.schema,
tableName: viewName,
});
const tabId = queryStore.createTab(node.connectionId, node.database, t("contextMenu.createView"), "query", node.schema, undefined, node.catalog);
queryStore.updateSql(tabId, `CREATE VIEW ${viewSqlName} AS\nSELECT\n *\nFROM table_name;\n`);
queryStore.setObjectSource(tabId, {