mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-22 01:25:38 -05:00
Add support for setting query options in settings and through API (#5484)
Initial query execution options PR. This is the second in a set of query editor extensibility improvements I'm making. The PRs include (1) bug fix for webview in query tab (2) dynamic toolbars and (3) fix query event sequencing and event metadata info.
This commit is contained in:
@@ -260,6 +260,14 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
|
||||
return this._resolveProvider<azdata.QueryProvider>(handle).runQueryAndReturn(ownerUri, queryString);
|
||||
}
|
||||
|
||||
$setQueryExecutionOptions(handle: number, ownerUri: string, options: azdata.QueryExecutionOptions): Thenable<void> {
|
||||
if (this._resolveProvider<azdata.QueryProvider>(handle).setQueryExecutionOptions) {
|
||||
return this._resolveProvider<azdata.QueryProvider>(handle).setQueryExecutionOptions(ownerUri, options);
|
||||
} else {
|
||||
return new Promise((r) => r());
|
||||
}
|
||||
}
|
||||
|
||||
$parseSyntax(handle: number, ownerUri: string, query: string): Thenable<azdata.SyntaxParseResult> {
|
||||
return this._resolveProvider<azdata.QueryProvider>(handle).parseSyntax(ownerUri, query);
|
||||
}
|
||||
|
||||
@@ -15,17 +15,14 @@ class ExtHostQueryDocument implements azdata.queryeditor.QueryDocument {
|
||||
private _proxy: MainThreadQueryEditorShape) {
|
||||
}
|
||||
|
||||
// get the document's execution options
|
||||
getOptions(): Map<string, string> {
|
||||
return undefined;
|
||||
public setExecutionOptions(options: Map<string, any>): Thenable<void> {
|
||||
let executionOptions: azdata.QueryExecutionOptions = {
|
||||
options: options
|
||||
};
|
||||
return this._proxy.$setQueryExecutionOptions(this.uri, executionOptions);
|
||||
}
|
||||
|
||||
// set the document's execution optionsß
|
||||
setOptions(options: Map<string, string>): void {
|
||||
|
||||
}
|
||||
|
||||
createQueryTab(tab: azdata.window.DialogTab): void {
|
||||
public createQueryTab(tab: azdata.window.DialogTab): void {
|
||||
this._proxy.$createQueryTab(this.uri, tab.title, tab.content);
|
||||
}
|
||||
}
|
||||
@@ -63,4 +60,11 @@ export class ExtHostQueryEditor implements ExtHostQueryEditorShape {
|
||||
listener.onQueryEvent(event.type, new ExtHostQueryDocument('MSSQL', fileUri, this._proxy), planXml);
|
||||
}
|
||||
}
|
||||
|
||||
public $getQueryDocument(fileUri: string): Thenable<azdata.queryeditor.QueryDocument> {
|
||||
return new Promise((resolve) => {
|
||||
resolve(new ExtHostQueryDocument('MSSQL', fileUri, this._proxy));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -127,6 +127,9 @@ export class MainThreadDataProtocol implements MainThreadDataProtocolShape {
|
||||
getQueryRows(rowData: azdata.QueryExecuteSubsetParams): Thenable<azdata.QueryExecuteSubsetResult> {
|
||||
return self._proxy.$getQueryRows(handle, rowData);
|
||||
},
|
||||
setQueryExecutionOptions(ownerUri: string, options: azdata.QueryExecutionOptions): Thenable<void> {
|
||||
return self._proxy.$setQueryExecutionOptions(handle, ownerUri, options);
|
||||
},
|
||||
disposeQuery(ownerUri: string): Thenable<void> {
|
||||
return self._proxy.$disposeQuery(handle, ownerUri);
|
||||
},
|
||||
|
||||
@@ -7,11 +7,12 @@ import { SqlExtHostContext, SqlMainContext, ExtHostQueryEditorShape, MainThreadQ
|
||||
import { IExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
import { IConnectionManagementService, IConnectionCompletionOptions, ConnectionType, RunQueryOnConnectionMode } from 'sql/platform/connection/common/connectionManagement';
|
||||
import { IQueryEditorService } from 'sql/workbench/services/queryEditor/common/queryEditorService';
|
||||
import { QueryEditor } from 'sql/workbench/parts/query/browser/queryEditor';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IQueryModelService, IQueryEvent } from 'sql/platform/query/common/queryModel';
|
||||
import { IQueryManagementService } from 'sql/platform/query/common/queryManagement';
|
||||
import * as azdata from 'azdata';
|
||||
|
||||
@extHostNamedCustomer(SqlMainContext.MainThreadQueryEditor)
|
||||
export class MainThreadQueryEditor implements MainThreadQueryEditorShape {
|
||||
@@ -22,7 +23,7 @@ export class MainThreadQueryEditor implements MainThreadQueryEditorShape {
|
||||
constructor(
|
||||
extHostContext: IExtHostContext,
|
||||
@IConnectionManagementService private _connectionManagementService: IConnectionManagementService,
|
||||
@IQueryEditorService private _queryEditorService: IQueryEditorService,
|
||||
@IQueryManagementService private _queryManagementService: IQueryManagementService,
|
||||
@IQueryModelService private _queryModelService: IQueryModelService,
|
||||
@IEditorService private _editorService: IEditorService
|
||||
) {
|
||||
@@ -96,4 +97,8 @@ export class MainThreadQueryEditor implements MainThreadQueryEditorShape {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public $setQueryExecutionOptions(fileUri: string, options: azdata.QueryExecutionOptions): Thenable<void> {
|
||||
return this._queryManagementService.setQueryExecutionOptions(fileUri, options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import { ExtHostConfiguration, ExtHostConfigProvider } from 'vs/workbench/api/co
|
||||
import { ExtHostStorage } from 'vs/workbench/api/common/extHostStorage';
|
||||
import * as extHostTypes from 'vs/workbench/api/common/extHostTypes';
|
||||
import { ISchemeTransformer } from 'vs/workbench/api/common/extHostLanguageFeatures';
|
||||
import { AzureResource } from 'sql/platform/accounts/common/interfaces';
|
||||
|
||||
export interface ISqlExtensionApiFactory {
|
||||
vsCodeFactory(extension: IExtensionDescription, registry: ExtensionDescriptionRegistry, configProvider: ExtHostConfigProvider): typeof vscode;
|
||||
@@ -462,8 +463,8 @@ export function createApiFactory(
|
||||
extHostQueryEditor.$registerQueryInfoListener('MSSQL', listener);
|
||||
},
|
||||
|
||||
getQueryDocument(fileUri: string): azdata.queryeditor.QueryDocument {
|
||||
return undefined;
|
||||
getQueryDocument(fileUri: string): Thenable<azdata.queryeditor.QueryDocument> {
|
||||
return extHostQueryEditor.$getQueryDocument(fileUri);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -662,7 +663,7 @@ export function createApiFactory(
|
||||
extHostDataProvider.$onEditSessionReady(provider.handle, ownerUri, success, message);
|
||||
});
|
||||
|
||||
return extHostDataProvider.$registerQueryProvider(provider);
|
||||
return extHostDataProvider.$registerQueryProvider(<azdata.QueryProvider>provider);
|
||||
};
|
||||
|
||||
let registerObjectExplorerProvider = (provider: sqlops.ObjectExplorerProvider): vscode.Disposable => {
|
||||
|
||||
@@ -173,6 +173,10 @@ export abstract class ExtHostDataProtocolShape {
|
||||
* Gets a subset of rows in a result set in order to display in the UI
|
||||
*/
|
||||
$getQueryRows(handle: number, rowData: azdata.QueryExecuteSubsetParams): Thenable<azdata.QueryExecuteSubsetResult> { throw ni(); }
|
||||
/**
|
||||
* Sets the query execution options for a query editor document
|
||||
*/
|
||||
$setQueryExecutionOptions(handle: number, ownerUri: string, options: azdata.QueryExecutionOptions): Thenable<void> { throw ni(); }
|
||||
|
||||
/**
|
||||
* Disposes the cached information regarding a query
|
||||
@@ -793,6 +797,7 @@ export interface MainThreadQueryEditorShape extends IDisposable {
|
||||
$connect(fileUri: string, connectionId: string): Thenable<void>;
|
||||
$runQuery(fileUri: string): void;
|
||||
$createQueryTab(fileUri: string, title: string, content: string): void;
|
||||
$setQueryExecutionOptions(fileUri: string, options: azdata.QueryExecutionOptions): Thenable<void>;
|
||||
$registerQueryInfoListener(handle: number, providerId: string): void;
|
||||
}
|
||||
|
||||
|
||||
@@ -404,6 +404,116 @@ let registryProperties = {
|
||||
'type': 'boolean',
|
||||
'default': false,
|
||||
'description': localize('mssql.intelliSense.lowerCaseSuggestions', 'Should IntelliSense suggestions be lowercase')
|
||||
},
|
||||
'mssql.query.rowCount': {
|
||||
'type': 'number',
|
||||
'default': 0,
|
||||
'description': localize('mssql.query.setRowCount', 'Maximum number of rows to return before the server stops processing your query.')
|
||||
},
|
||||
'mssql.query.textSize': {
|
||||
'type': 'number',
|
||||
'default': 2147483647,
|
||||
'description': localize('mssql.query.textSize', 'Maximum size of text and ntext data returned from a SELECT statement')
|
||||
},
|
||||
'mssql.query.executionTimeout': {
|
||||
'type': 'number',
|
||||
'default': 0,
|
||||
'description': localize('mssql.query.executionTimeout', 'An execution time-out of 0 indicates an unlimited wait (no time-out)')
|
||||
},
|
||||
'mssql.query.noCount': {
|
||||
'type': 'boolean',
|
||||
'default': false,
|
||||
'description': localize('mssql.query.noCount', 'Enable SET NOCOUNT option')
|
||||
},
|
||||
'mssql.query.noExec': {
|
||||
'type': 'boolean',
|
||||
'default': false,
|
||||
'description': localize('mssql.query.noExec', 'Enable SET NOEXEC option')
|
||||
},
|
||||
'mssql.query.parseOnly': {
|
||||
'type': 'boolean',
|
||||
'default': false,
|
||||
'description': localize('mssql.query.parseOnly', 'Enable SET PARSEONLY option')
|
||||
},
|
||||
'mssql.query.arithAbort': {
|
||||
'type': 'boolean',
|
||||
'default': false,
|
||||
'description': localize('mssql.query.arithAbort', 'Enable SET ARITHABORT option')
|
||||
},
|
||||
'mssql.query.statisticsTime': {
|
||||
'type': 'boolean',
|
||||
'default': false,
|
||||
'description': localize('mssql.query.statisticsTime', 'Enable SET STATISTICS TIME option')
|
||||
},
|
||||
'mssql.query.statisticsIO': {
|
||||
'type': 'boolean',
|
||||
'default': false,
|
||||
'description': localize('mssql.query.statisticsIO', 'Enable SET STATISTICS IO option')
|
||||
},
|
||||
'mssql.query.xactAbortOn': {
|
||||
'type': 'boolean',
|
||||
'default': false,
|
||||
'description': localize('mssql.query.xactAbortOn', 'Enable SET XACT_ABORT ON option')
|
||||
},
|
||||
'mssql.query.transactionIsolationLevel': {
|
||||
'enum': ['READ COMMITTED', 'READ UNCOMMITTED', 'REPEATABLE READ', 'SERIALIZABLE'],
|
||||
'default': 'READ COMMITTED',
|
||||
'description': localize('mssql.query.transactionIsolationLevel', 'Enable SET TRANSACTION ISOLATION LEVEL option')
|
||||
},
|
||||
'mssql.query.deadlockPriority': {
|
||||
'enum': ['Normal', 'Low'],
|
||||
'default': 'Normal',
|
||||
'description': localize('mssql.query.deadlockPriority', 'Enable SET DEADLOCK_PRIORITY option')
|
||||
},
|
||||
'mssql.query.lockTimeout': {
|
||||
'type': 'number',
|
||||
'default': -1,
|
||||
'description': localize('mssql.query.lockTimeout', 'Enable SET LOCK TIMEOUT option (in milliseconds)')
|
||||
},
|
||||
'mssql.query.queryGovernorCostLimit': {
|
||||
'type': 'number',
|
||||
'default': -1,
|
||||
'description': localize('mssql.query.queryGovernorCostLimit', 'Enable SET QUERY_GOVERNOR_COST_LIMIT')
|
||||
},
|
||||
'mssql.query.ansiDefaults': {
|
||||
'type': 'boolean',
|
||||
'default': false,
|
||||
'description': localize('mssql.query.ansiDefaults', 'Enable SET ANSI_DEFAULTS')
|
||||
},
|
||||
'mssql.query.quotedIdentifier': {
|
||||
'type': 'boolean',
|
||||
'default': true,
|
||||
'description': localize('mssql.query.quotedIdentifier', 'Enable SET QUOTED_IDENTIFIER')
|
||||
},
|
||||
'mssql.query.ansiNullDefaultOn': {
|
||||
'type': 'boolean',
|
||||
'default': true,
|
||||
'description': localize('mssql.query.ansiNullDefaultOn', 'Enable SET ANSI_NULL_DFLT_ON')
|
||||
},
|
||||
'mssql.query.implicitTransactions': {
|
||||
'type': 'boolean',
|
||||
'default': false,
|
||||
'description': localize('mssql.query.implicitTransactions', 'Enable SET IMPLICIT_TRANSACTIONS')
|
||||
},
|
||||
'mssql.query.cursorCloseOnCommit': {
|
||||
'type': 'boolean',
|
||||
'default': false,
|
||||
'description': localize('mssql.query.cursorCloseOnCommit', 'Enable SET CURSOR_CLOSE_ON_COMMIT')
|
||||
},
|
||||
'mssql.query.ansiPadding': {
|
||||
'type': 'boolean',
|
||||
'default': true,
|
||||
'description': localize('mssql.query.ansiPadding', 'Enable SET ANSI_PADDING')
|
||||
},
|
||||
'mssql.query.ansiWarnings': {
|
||||
'type': 'boolean',
|
||||
'default': true,
|
||||
'description': localize('mssql.query.ansiWarnings', 'Enable SET ANSI_WARNINGS')
|
||||
},
|
||||
'mssql.query.ansiNulls': {
|
||||
'type': 'boolean',
|
||||
'default': true,
|
||||
'description': localize('mssql.query.ansiNulls', 'Enable SET ANSI_NULLS')
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user