fix(kingbase): resolve schema for unqualified grid edits

This commit is contained in:
Zzz authored and GitHub committed 2026-08-25 21:26:00 +08:00
1 parent 7494cf8011
commit a66590868e
6 files changed
+260 -57

No files matched your search

+8 -6
View File
@@ -3823,15 +3823,16 @@ export const useQueryStore = defineStore("query", () => {
// Oracle-family connection databases are service names, not schemas. When
// the query does not qualify a schema, let the driver resolve the current
// login user's schema instead of looking up metadata under the service name.
// An unqualified Vastbase query runs in the connection's current
// search_path. Do not reinterpret the selected database as a schema; the
// agent resolves the visible relation's actual namespace with the columns.
const useCurrentVastbaseSchema = dbType === "vastbase" && !source.schema && !tab.schema;
// Unqualified agent-backed PostgreSQL-family queries run in the
// connection's current search_path. Do not reinterpret the selected
// database as a schema; the agent reports the visible relation's actual
// namespace with the columns.
const resolveAgentSearchPathSchema = (dbType === "vastbase" || dbType === "kingbase") && !source.schema && !tab.schema;
// PostgreSQL-compatible unqualified names also resolve through the
// connection's search_path. Keep the metadata request unqualified when no
// schema was selected instead of assuming public (or the database name).
const useCurrentPostgresSchema = (dbType === "postgres" || dbType === "kwdb") && !source.schema && !tab.schema;
const resolvedSchema = (dbType === "sqlserver" && !source.schema) || (ORACLE_LIKE_METADATA_TYPES.has(dbType) && !schema) || useCurrentVastbaseSchema || useCurrentPostgresSchema ? "" : metadataSchemaForConnection(conn, metadataDatabase, schema || undefined);
const resolvedSchema = (dbType === "sqlserver" && !source.schema) || (ORACLE_LIKE_METADATA_TYPES.has(dbType) && !schema) || resolveAgentSearchPathSchema || useCurrentPostgresSchema ? "" : metadataSchemaForConnection(conn, metadataDatabase, schema || undefined);
const metadataSchema = normalizeUppercaseFoldedMetadataIdentifier(dbType, resolvedSchema || undefined, source.schema ? source.schemaQuoted : false) || "";
const metadataTableName = normalizeUppercaseFoldedMetadataIdentifier(dbType, source.tableName, source.tableNameQuoted)!;
const metadataCatalog = normalizeUppercaseFoldedMetadataIdentifier(dbType, source.catalog, source.catalogQuoted);
@@ -3863,7 +3864,8 @@ export const useQueryStore = defineStore("query", () => {
}
function loadedEditableSourceFromMetadata(target: EditableSourceMetadataTarget, metadata: Awaited<ReturnType<typeof loadTableMetadata>>["metadata"]): LoadedEditableSource {
const writeSchema = target.request.databaseType === "vastbase" && !target.writeSchema ? metadata.schema : target.writeSchema;
const usesReportedSchema = target.request.databaseType === "vastbase" || target.request.databaseType === "kingbase";
const writeSchema = usesReportedSchema && !target.writeSchema ? metadata.schema : target.writeSchema;
return {
source: target.source,
analysis: target.analysis,