fix(editor): avoid metadata wait for wildcard queries
This commit is contained in:
1 parent
e381aa4ee1
commit
a8592af97a
2 files changed
+85
-2
No files matched your search
@@ -339,6 +339,10 @@ function editableQuerySources(analysis: EditableQueryInfo): EditableQuerySource[
|
||||
];
|
||||
}
|
||||
|
||||
function projectsAllColumnsForSource(analysis: EditableQueryInfo, sourceKey: string): boolean {
|
||||
return analysis.selectStar || analysis.columns.some((column) => column.star && (!column.sourceKey || column.sourceKey === sourceKey));
|
||||
}
|
||||
|
||||
function cloneAnalysisForSource(analysis: EditableQueryInfo, source: EditableQuerySource): EditableQueryInfo {
|
||||
return {
|
||||
...analysis,
|
||||
@@ -2729,6 +2733,9 @@ export const useQueryStore = defineStore("query", () => {
|
||||
const analysis = editability.analysis;
|
||||
const sources = editableQuerySources(analysis);
|
||||
if (sources.length !== 1 || analysis.distinct) return unchanged;
|
||||
// Whole-source projections already include declared primary keys. Only
|
||||
// Oracle needs preflight metadata here to add ROWID for a keyless table.
|
||||
if (databaseType !== "oracle" && projectsAllColumnsForSource(analysis, sources[0]!.key)) return unchanged;
|
||||
|
||||
const target = resolveEditableSourceMetadataTarget(tab, analysis, sources[0]!, conn, databaseType, executionDatabase);
|
||||
const cached = getCachedTableMetadata(target.request);
|
||||
@@ -2743,8 +2750,7 @@ export const useQueryStore = defineStore("query", () => {
|
||||
});
|
||||
void fullMetadataPromise.catch((error) => queryExecutionLog("warn", "metadata:table-prefetch:failed", { traceId, error, elapsed: elapsed() }));
|
||||
const indexes = await loadTableIndexes(target.request);
|
||||
const projectsAllColumns = target.analysis.selectStar || target.analysis.columns.some((column) => column.star && (!column.sourceKey || column.sourceKey === target.source.key));
|
||||
if (primaryKeyIndex(indexes) && projectsAllColumns) {
|
||||
if (primaryKeyIndex(indexes) && projectsAllColumnsForSource(target.analysis, target.source.key)) {
|
||||
return unchanged;
|
||||
}
|
||||
loaded = loadedEditableSourceFromMetadata(target, (await fullMetadataPromise).metadata);
|
||||
|
||||
Reference in new issue
Block a user