1 parent
e04dad4622
commit
79eb0a21e7
2 files changed
+152
-10
No files matched your search
@@ -3317,12 +3317,20 @@ export const useQueryStore = defineStore("query", () => {
|
||||
return primaryKeys.filter((primaryKey) => !selectedColumns.has(primaryKey));
|
||||
}
|
||||
|
||||
async function oracleRowIdIsSafeForQuery(tab: QueryTab, loaded: LoadedEditableSource): Promise<boolean> {
|
||||
function oracleRowIdIsSafeForQuery(tab: QueryTab, loaded: LoadedEditableSource): boolean {
|
||||
const knownType = loaded.tableMeta.tableType?.trim().toUpperCase();
|
||||
if (knownType) return knownType === "TABLE";
|
||||
const objects = await api.listObjects(tab.connectionId!, loaded.tableMeta.database ?? tab.database, loaded.tableMeta.schema ?? "", ["TABLE", "VIEW", "MATERIALIZED_VIEW"], loaded.tableMeta.tableName, 20, 0, loaded.tableMeta.catalog);
|
||||
const matching = objects.find((object) => object.name.toLowerCase() === loaded.tableMeta.tableName.toLowerCase());
|
||||
return matching?.object_type.trim().toUpperCase() === "TABLE";
|
||||
const connectionStore = useConnectionStore();
|
||||
const normalizeIdentifier = (value: string | undefined) => value?.trim().toLowerCase() ?? "";
|
||||
const targetName = normalizeIdentifier(loaded.tableMeta.tableName);
|
||||
const resolvedSchema = loaded.tableMeta.schema?.trim() || tab.schema?.trim() || connectionStore.getConfig(tab.connectionId!)?.default_schema?.trim();
|
||||
if (!resolvedSchema) return false;
|
||||
const targetSchema = normalizeIdentifier(resolvedSchema);
|
||||
const targetCatalog = loaded.tableMeta.catalog?.trim() ? normalizeIdentifier(loaded.tableMeta.catalog) : undefined;
|
||||
const matches = connectionStore
|
||||
.lookupLocalCompletionTables(tab.connectionId!, loaded.tableMeta.database ?? tab.database, loaded.tableMeta.tableName, 20, resolvedSchema, loaded.tableMeta.catalog)
|
||||
.filter((table) => normalizeIdentifier(table.name) === targetName && normalizeIdentifier(table.schema) === targetSchema && (!targetCatalog || normalizeIdentifier(table.catalog) === targetCatalog));
|
||||
return matches.length === 1 && matches[0]?.type === "table";
|
||||
}
|
||||
|
||||
function primaryKeyIndex(indexes: IndexInfo[]): IndexInfo | undefined {
|
||||
@@ -3395,7 +3403,7 @@ export const useQueryStore = defineStore("query", () => {
|
||||
// Oracle base tables without declared keys use the same ROWID identity as
|
||||
// table-data tabs. Confirm the object is a base table because selecting
|
||||
// ROWID from a view can fail with ORA-01445.
|
||||
if (databaseType === "oracle" && declaredPrimaryKeys.length === 0 && !(await oracleRowIdIsSafeForQuery(tab, loaded))) return unchanged;
|
||||
if (databaseType === "oracle" && declaredPrimaryKeys.length === 0 && !oracleRowIdIsSafeForQuery(tab, loaded)) return unchanged;
|
||||
const primaryKeys = editablePrimaryKeys(databaseType, loaded.tableMeta.columns, loaded.tableMeta.tableType);
|
||||
return buildHiddenPrimaryKeyPreparation(sql, databaseType, loaded, primaryKeys, declaredPrimaryKeys, traceId, elapsed);
|
||||
} catch (error) {
|
||||
|
||||
Reference in new issue
Block a user