Add LocalQueryInfo.databaseName getter

This commit is contained in:
Robert
2023-04-25 15:57:20 +01:00
parent ab7ec589ff
commit 912a9e167f
3 changed files with 9 additions and 6 deletions

View File

@@ -80,7 +80,7 @@ export class HistoryItemLabelProvider {
return { return {
t: item.startTime, t: item.startTime,
q: item.getQueryName(), q: item.getQueryName(),
d: item.initialInfo.databaseInfo.name, d: item.databaseName,
r: `(${resultCount} results)`, r: `(${resultCount} results)`,
s: statusString, s: statusString,
f: item.getQueryFileName(), f: item.getQueryFileName(),

View File

@@ -1084,7 +1084,7 @@ export class QueryHistoryManager extends DisposableObject {
fromItem: CompletedLocalQueryInfo, fromItem: CompletedLocalQueryInfo,
allSelectedItems: CompletedLocalQueryInfo[], allSelectedItems: CompletedLocalQueryInfo[],
): Promise<CompletedLocalQueryInfo | undefined> { ): Promise<CompletedLocalQueryInfo | undefined> {
const dbName = fromItem.initialInfo.databaseInfo.name; const dbName = fromItem.databaseName;
// If exactly 2 items are selected, return the one that // If exactly 2 items are selected, return the one that
// isn't being used as the "from" item. // isn't being used as the "from" item.
@@ -1093,7 +1093,7 @@ export class QueryHistoryManager extends DisposableObject {
fromItem === allSelectedItems[0] fromItem === allSelectedItems[0]
? allSelectedItems[1] ? allSelectedItems[1]
: allSelectedItems[0]; : allSelectedItems[0];
if (otherItem.initialInfo.databaseInfo.name !== dbName) { if (otherItem.databaseName !== dbName) {
throw new Error("Query databases must be the same."); throw new Error("Query databases must be the same.");
} }
return otherItem; return otherItem;
@@ -1108,12 +1108,11 @@ export class QueryHistoryManager extends DisposableObject {
.filter(this.isSuccessfulCompletedLocalQueryInfo) .filter(this.isSuccessfulCompletedLocalQueryInfo)
.filter( .filter(
(otherItem) => (otherItem) =>
otherItem !== fromItem && otherItem !== fromItem && otherItem.databaseName === dbName,
otherItem.initialInfo.databaseInfo.name === dbName,
) )
.map((item) => ({ .map((item) => ({
label: this.labelProvider.getLabel(item), label: this.labelProvider.getLabel(item),
description: item.initialInfo.databaseInfo.name, description: item.databaseName,
detail: item.completedQuery.statusString, detail: item.completedQuery.statusString,
query: item, query: item,
})); }));

View File

@@ -313,4 +313,8 @@ export class LocalQueryInfo {
return QueryStatus.Failed; return QueryStatus.Failed;
} }
} }
get databaseName() {
return this.initialInfo.databaseInfo.name;
}
} }