fix(kingbase): resolve schema for unqualified grid edits
This commit is contained in:
6 files changed
+260
-57
No files matched your search
@@ -328,13 +328,13 @@ export async function loadTableMetadata(request: TableMetadataRequest): Promise<
|
||||
scope,
|
||||
async () => {
|
||||
// Column discovery can be especially slow on Oracle. Start row-identity
|
||||
// discovery independently unless an unqualified Vastbase relation must
|
||||
// first report its visible schema for the index lookup.
|
||||
const resolveVastbaseSchema = request.databaseType === "vastbase" && !request.schema;
|
||||
const indexesPromise = resolveVastbaseSchema ? undefined : loadTableIndexes(request).catch((): IndexInfo[] => []);
|
||||
// discovery independently unless an agent-backed PostgreSQL-family
|
||||
// relation must first report its visible schema for the index lookup.
|
||||
const resolveReportedSchema = (request.databaseType === "vastbase" || request.databaseType === "kingbase") && !request.schema;
|
||||
const indexesPromise = resolveReportedSchema ? undefined : loadTableIndexes(request).catch((): IndexInfo[] => []);
|
||||
const columnsResult = await columnsPromise;
|
||||
const columns = columnsResult.columns;
|
||||
const resolvedSchema = resolveVastbaseSchema ? columns.find((column) => column.resolved_schema)?.resolved_schema : request.schema;
|
||||
const resolvedSchema = resolveReportedSchema ? columns.find((column) => column.resolved_schema)?.resolved_schema : request.schema;
|
||||
const indexes = columns.length > 0 ? await (indexesPromise ?? loadTableIndexes({ ...request, schema: resolvedSchema }).catch((): IndexInfo[] => [])) : [];
|
||||
const primaryKeys = editableRowIdentifierColumns(request.databaseType as DatabaseType, columns, indexes, request.tableType);
|
||||
return {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user