CB-3185 stop executing on cancel (#1696)

This commit is contained in:
alex
2023-05-26 15:20:54 +02:00
committed by GitHub
parent 7f81977e5e
commit 52c171f4dc
5 changed files with 19 additions and 1 deletions
@@ -30,6 +30,10 @@ export class ContainerDataSource extends DatabaseDataSource<IDataContainerOption
return this.currentTask?.cancellable || false;
}
get cancelled(): boolean {
return this.currentTask?.cancelled || false;
}
constructor(
readonly serviceInjector: IServiceInjector,
private readonly graphQLService: GraphQLService,
@@ -36,6 +36,7 @@ implements IDatabaseDataSource<TOptions, TResult> {
outdated: boolean;
abstract get canCancel(): boolean;
abstract get cancelled(): boolean;
readonly serviceInjector: IServiceInjector;
protected disabled: boolean;
@@ -42,6 +42,7 @@ export interface IDatabaseDataSource<TOptions, TResult extends IDatabaseDataResu
readonly error: Error | null;
readonly executionContext: IConnectionExecutionContext | null;
readonly canCancel: boolean;
readonly cancelled: boolean;
readonly serviceInjector: IServiceInjector;
readonly outdated: boolean;
@@ -31,6 +31,10 @@ export class QueryDataSource<TOptions extends IDataQueryOptions = IDataQueryOpti
return this.currentTask?.cancellable || false;
}
get cancelled(): boolean {
return this.currentTask?.cancelled || false;
}
constructor(
readonly serviceInjector: IServiceInjector,
protected readonly graphQLService: GraphQLService,
@@ -257,6 +257,8 @@ export class SqlQueryService {
.setSlice(0)
.request();
const cancelled = model.source.cancelled;
statistics.executedQueries++;
statistics.executeTime += source.requestInfo.requestDuration;
@@ -285,7 +287,13 @@ export class SqlQueryService {
model = source = undefined;
}
options?.onQueryExecuted?.(query, i, true);
if (cancelled) {
break;
}
} catch (exception: any) {
if (model) {
const tabGroup = this.sqlQueryResultService.createGroup(editorState, model.id, query);
@@ -331,7 +339,7 @@ export class SqlQueryService {
DatabaseEditAction
);
const edited = editor?.isEdited() && model.source.executionContext?.context;
const edited = editor?.isEdited() && model.source.executionContext?.context;
if (edited && activeGroupId !== tabGroup.groupId) {
this.sqlQueryResultService.selectResult(