From a2fb0ec029b994d87ceaa448dd124a01529d2428 Mon Sep 17 00:00:00 2001 From: Aditya Bist Date: Tue, 18 Sep 2018 13:42:14 -0700 Subject: [PATCH] fixed actual show plan command (#2620) --- src/sql/parts/query/editor/gridPanel.ts | 5 ++++- src/sql/parts/query/editor/queryEditor.ts | 20 +++++++++++++++++++ src/sql/parts/query/execution/queryActions.ts | 6 +++++- src/sql/parts/queryPlan/queryPlan.ts | 1 - 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/sql/parts/query/editor/gridPanel.ts b/src/sql/parts/query/editor/gridPanel.ts index f3ef4c11ba..f083fccc6b 100644 --- a/src/sql/parts/query/editor/gridPanel.ts +++ b/src/sql/parts/query/editor/gridPanel.ts @@ -553,7 +553,10 @@ class GridTable extends Disposable implements IView { private loadData(offset: number, count: number): Thenable { return this.runner.getQueryRows(offset, count, this.resultSet.batchId, this.resultSet.id).then(response => { if (this.runner.isQueryPlan) { - this.instantiationService.createInstance(ShowQueryPlanAction).run(response.resultSubset.rows[0][0].displayValue); + // it's a show plan response + if (response.resultSubset.rowCount === 1) { + this.instantiationService.createInstance(ShowQueryPlanAction).run(response.resultSubset.rows[0][0].displayValue); + } } return response.resultSubset.rows.map(r => { let dataWithSchema = {}; diff --git a/src/sql/parts/query/editor/queryEditor.ts b/src/sql/parts/query/editor/queryEditor.ts index 4b28f01b8a..1f54624a6f 100644 --- a/src/sql/parts/query/editor/queryEditor.ts +++ b/src/sql/parts/query/editor/queryEditor.ts @@ -377,6 +377,26 @@ export class QueryEditor extends BaseEditor { return undefined; } + public getAllSelection(): ISelectionData { + if (this._sqlEditor && this._sqlEditor.getControl()) { + let control = this._sqlEditor.getControl(); + let codeEditor: ICodeEditor = control; + if (codeEditor) { + let model = codeEditor.getModel(); + let totalLines = model.getLineCount(); + let endColumn = model.getLineMaxColumn(totalLines); + let selection: ISelectionData = { + startLine: 0, + startColumn: 0, + endLine: totalLines - 1, + endColumn: endColumn - 1, + }; + return selection; + } + } + return undefined; + } + public getSelectionText(): string { if (this._sqlEditor && this._sqlEditor.getControl()) { let control = this._sqlEditor.getControl(); diff --git a/src/sql/parts/query/execution/queryActions.ts b/src/sql/parts/query/execution/queryActions.ts index 5a40d7fe23..b7c7c087ad 100644 --- a/src/sql/parts/query/execution/queryActions.ts +++ b/src/sql/parts/query/execution/queryActions.ts @@ -271,7 +271,11 @@ export class ActualQueryPlanAction extends QueryTaskbarAction { } if (this.isConnected(editor)) { - editor.currentQueryInput.runQuery(editor.getSelection(), { + let selection = editor.getSelection(); + if (!selection) { + selection = editor.getAllSelection(); + } + editor.currentQueryInput.runQuery(selection, { displayActualQueryPlan: true }); } diff --git a/src/sql/parts/queryPlan/queryPlan.ts b/src/sql/parts/queryPlan/queryPlan.ts index 06564692c2..420ee11bce 100644 --- a/src/sql/parts/queryPlan/queryPlan.ts +++ b/src/sql/parts/queryPlan/queryPlan.ts @@ -42,7 +42,6 @@ export class QueryPlanView implements IPanelView { } container.appendChild(this.container); container.style.overflow = 'scroll'; - container.style.background = '#FFFFFF'; } public layout(dimension: Dimension): void {