diff --git a/dataprotocol-client/src/codeConverter.ts b/dataprotocol-client/src/codeConverter.ts index 8f9db2e14c..66c34d842f 100644 --- a/dataprotocol-client/src/codeConverter.ts +++ b/dataprotocol-client/src/codeConverter.ts @@ -4,7 +4,7 @@ import * as types from './types'; export interface Ic2p { asConnectionParams(connectionUri: string, connectionInfo: data.ConnectionInfo): proto.ConnectParams; - asExecutionPlanOptions(planOptions: data.ExecutionPlanOptions): data.ExecutionPlanOptions; + asExecutionPlanOptions(planOptions: data.ExecutionPlanOptions): types.ExecutionPlanOptions; asScriptingParams(connectionUri: string, operation: data.ScriptOperation, metadata: data.ObjectMetadata, paramDetails: data.ScriptingParamDetails): types.ScriptingParams; } @@ -17,10 +17,10 @@ function asConnectionParams(ownerUri: string, connInfo: data.ConnectionInfo): pr }; } -function asExecutionPlanOptions(planOptions: data.ExecutionPlanOptions): data.ExecutionPlanOptions { +function asExecutionPlanOptions(planOptions: data.ExecutionPlanOptions): types.ExecutionPlanOptions { return { - displayEstimatedQueryPlan: planOptions ? planOptions.displayEstimatedQueryPlan : undefined, - displayActualQueryPlan: planOptions ? planOptions.displayActualQueryPlan : undefined + includeEstimatedExecutionPlanXml: planOptions ? planOptions.displayEstimatedQueryPlan : undefined, + includeActualExecutionPlanXml: planOptions ? planOptions.displayActualQueryPlan : undefined }; } diff --git a/dataprotocol-client/src/main.ts b/dataprotocol-client/src/main.ts index 4c4558abaf..9975976393 100644 --- a/dataprotocol-client/src/main.ts +++ b/dataprotocol-client/src/main.ts @@ -108,7 +108,7 @@ class CapabilitiesFeature extends SqlOpsFeature { let getServerCapabilities = (cap: data.DataProtocolClientCapabilities): Thenable => { return client.sendRequest(protocol.CapabiltiesDiscoveryRequest.type, cap).then( - r => r.capabilities, + client.sqlp2c.asServerCapabilities, e => { client.logFailedRequest(protocol.CapabiltiesDiscoveryRequest.type, e); return Promise.resolve(undefined); @@ -310,7 +310,7 @@ class QueryFeature extends SqlOpsFeature { protected registerProvider(options: undefined): Disposable { const client = this._client; let runQuery = (ownerUri: string, querySelection: data.ISelectionData, executionPlanOptions?: data.ExecutionPlanOptions): Thenable => { - let params: data.QueryExecuteParams = { + let params: types.QueryExecuteParams = { ownerUri, querySelection, executionPlanOptions: client.sqlc2p.asExecutionPlanOptions(executionPlanOptions) diff --git a/dataprotocol-client/src/protocol.ts b/dataprotocol-client/src/protocol.ts index 114be781ab..df1ba2242a 100644 --- a/dataprotocol-client/src/protocol.ts +++ b/dataprotocol-client/src/protocol.ts @@ -335,7 +335,7 @@ export namespace QueryExecuteMessageNotification { // ------------------------------- < Query Execution Request > ------------------------------------ export namespace QueryExecuteRequest { - export const type = new RequestType('query/executeDocumentSelection'); + export const type = new RequestType('query/executeDocumentSelection'); } export interface QueryExecuteResult { } diff --git a/dataprotocol-client/src/protocolConverter.ts b/dataprotocol-client/src/protocolConverter.ts index b5c351a646..7e4b877974 100644 --- a/dataprotocol-client/src/protocolConverter.ts +++ b/dataprotocol-client/src/protocolConverter.ts @@ -3,6 +3,8 @@ import * as types from './types'; export interface Ip2c { asProviderMetadata(params: types.MetadataQueryResult): data.ProviderMetadata; + + asServerCapabilities(result: types.CapabiltiesDiscoveryResult): data.DataProtocolServerCapabilities; } function asProviderMetadata(params: types.MetadataQueryResult): data.ProviderMetadata { @@ -45,6 +47,152 @@ function asProviderMetadata(params: types.MetadataQueryResult): data.ProviderMet }; } +function asServiceOptionType(val: string): data.ServiceOptionType { + if (val === 'string') { + return data.ServiceOptionType.string; + } else if (val === 'multistring') { + return data.ServiceOptionType.multistring; + } else if (val === 'password') { + return data.ServiceOptionType.password; + } else if (val === 'number') { + return data.ServiceOptionType.number; + } else if (val === 'boolean') { + return data.ServiceOptionType.boolean; + } else if (val === 'category') { + return data.ServiceOptionType.category; + } else if (val === 'object') { + return data.ServiceOptionType.object; + } + + // assume string for unknown value types + return data.ServiceOptionType.string; +} + + + +function buildServiceOption(srcOption: types.ServiceOption): data.ServiceOption { + return { + name: srcOption.name, + displayName: srcOption.displayName ? srcOption.displayName : srcOption.name, + description: srcOption.description, + groupName: srcOption.groupName, + defaultValue: srcOption.defaultValue, + categoryValues: srcOption.categoryValues, + isRequired: srcOption.isRequired, + isArray: srcOption.isArray, + objectType: srcOption.objectType, + valueType: asServiceOptionType(srcOption.valueType), + }; +} + + +function asServerCapabilities(result: types.CapabiltiesDiscoveryResult): data.DataProtocolServerCapabilities { + let capabilities: data.DataProtocolServerCapabilities = { + protocolVersion: result.capabilities.protocolVersion, + providerName: result.capabilities.providerName, + providerDisplayName: result.capabilities.providerDisplayName, + connectionProvider: undefined, + adminServicesProvider: undefined, + features: [] + }; + + if (result.capabilities.adminServicesProvider) { + capabilities.adminServicesProvider = { + databaseInfoOptions: new Array(), + databaseFileInfoOptions: new Array(), + fileGroupInfoOptions: new Array() + }; + + if (result.capabilities.adminServicesProvider.databaseInfoOptions + && result.capabilities.adminServicesProvider.databaseInfoOptions.length > 0) { + for (let i = 0; i < result.capabilities.adminServicesProvider.databaseInfoOptions.length; ++i) { + let srcOption: any = result.capabilities.adminServicesProvider.databaseInfoOptions[i]; + let descOption: data.ServiceOption = buildServiceOption(srcOption); + capabilities.adminServicesProvider.databaseInfoOptions.push(descOption); + } + } + + if (result.capabilities.adminServicesProvider.databaseFileInfoOptions + && result.capabilities.adminServicesProvider.databaseFileInfoOptions.length > 0) { + for (let i = 0; i < result.capabilities.adminServicesProvider.databaseFileInfoOptions.length; ++i) { + //let srcOption: types.ServiceOption = result.capabilities.adminServicesProvider.databaseFileInfoOptions[i]; + let srcOption: any = result.capabilities.adminServicesProvider.databaseFileInfoOptions[i]; + let descOption: data.ServiceOption = buildServiceOption(srcOption); + capabilities.adminServicesProvider.databaseFileInfoOptions.push(descOption); + } + } + + if (result.capabilities.adminServicesProvider.fileGroupInfoOptions + && result.capabilities.adminServicesProvider.fileGroupInfoOptions.length > 0) { + for (let i = 0; i < result.capabilities.adminServicesProvider.fileGroupInfoOptions.length; ++i) { + //let srcOption: types.ServiceOption = result.capabilities.adminServicesProvider.fileGroupInfoOptions[i]; + let srcOption: any = result.capabilities.adminServicesProvider.fileGroupInfoOptions[i]; + let descOption: data.ServiceOption = buildServiceOption(srcOption); + capabilities.adminServicesProvider.fileGroupInfoOptions.push(descOption); + } + } + } + + if (result.capabilities.connectionProvider + && result.capabilities.connectionProvider.options + && result.capabilities.connectionProvider.options.length > 0) { + capabilities.connectionProvider = { + options: new Array() + }; + for (let i = 0; i < result.capabilities.connectionProvider.options.length; ++i) { + let srcOption: any = result.capabilities.connectionProvider.options[i]; + let descOption: data.ConnectionOption = { + name: srcOption.name, + displayName: srcOption.displayName ? srcOption.displayName : srcOption.name, + description: srcOption.description, + groupName: srcOption.groupName, + defaultValue: srcOption.defaultValue, + categoryValues: srcOption.categoryValues, + isIdentity: srcOption.isIdentity, + isRequired: srcOption.isRequired, + valueType: asServiceOptionType(srcOption.valueType), + specialValueType: undefined + }; + + if (srcOption.specialValueType === 'serverName') { + descOption.specialValueType = data.ConnectionOptionSpecialType.serverName; + } else if (srcOption.specialValueType === 'databaseName') { + descOption.specialValueType = data.ConnectionOptionSpecialType.databaseName; + } else if (srcOption.specialValueType === 'authType') { + descOption.specialValueType = data.ConnectionOptionSpecialType.authType; + } else if (srcOption.specialValueType === 'userName') { + descOption.specialValueType = data.ConnectionOptionSpecialType.userName; + } else if (srcOption.specialValueType === 'password') { + descOption.specialValueType = data.ConnectionOptionSpecialType.password; + } else if (srcOption.specialValueType === 'appName') { + descOption.specialValueType = data.ConnectionOptionSpecialType.appName; + } + + capabilities.connectionProvider.options.push(descOption); + } + } + + if (result.capabilities.features + && result.capabilities.features.length > 0) { + result.capabilities.features.forEach(feature => { + let descFeature: data.FeatureMetadataProvider = { + enabled: feature.enabled, + featureName: feature.featureName, + optionsMetadata: [] + }; + capabilities.features.push(descFeature); + if (feature.optionsMetadata) { + feature.optionsMetadata.forEach(srcOption => { + descFeature.optionsMetadata.push(buildServiceOption(srcOption)); + }); + } + }); + } + + return capabilities; +} + export const p2c: Ip2c = { - asProviderMetadata + asProviderMetadata, + asServerCapabilities }; diff --git a/dataprotocol-client/src/types.ts b/dataprotocol-client/src/types.ts index 28cb268b11..0a370bc4c9 100644 --- a/dataprotocol-client/src/types.ts +++ b/dataprotocol-client/src/types.ts @@ -509,6 +509,17 @@ export interface IResultMessage { message: string; } +export interface ExecutionPlanOptions { + includeEstimatedExecutionPlanXml?: boolean; + includeActualExecutionPlanXml?: boolean; +} + +export interface QueryExecuteParams { + ownerUri: string; + querySelection: data.ISelectionData; + executionPlanOptions?: ExecutionPlanOptions; +} + export enum EditRowState { clean = 0, dirtyInsert = 1, diff --git a/package.json b/package.json index cba63597d5..fe0ec76803 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "reflect-metadata": "^0.1.8", "rxjs": "5.4.0", "semver": "4.3.6", - "slickgrid": "github:anthonydresser/SlickGrid#2.3.12", + "slickgrid": "github:anthonydresser/SlickGrid#2.3.7", "spdlog": "0.3.7", "svg.js": "^2.2.5", "systemjs": "0.19.40", diff --git a/src/sql/base/browser/ui/modal/optionsDialogHelper.ts b/src/sql/base/browser/ui/modal/optionsDialogHelper.ts index 8a7b25d69c..aa0ea7d643 100644 --- a/src/sql/base/browser/ui/modal/optionsDialogHelper.ts +++ b/src/sql/base/browser/ui/modal/optionsDialogHelper.ts @@ -14,7 +14,7 @@ import { InputBox } from 'sql/base/browser/ui/inputBox/inputBox'; import * as types from 'vs/base/common/types'; import data = require('data'); import { localize } from 'vs/nls'; -import { ServiceOptionType, ServiceOptionTypeNames } from 'sql/workbench/api/common/sqlExtHostTypes'; +import { ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes'; export interface IOptionElement { optionWidget: any; @@ -31,8 +31,7 @@ export function createOptionElement(option: data.ServiceOption, rowContainer: Bu let missingErrorMessage = localize('missingRequireField', ' is required.'); let invalidInputMessage = localize('invalidInput', 'Invalid input. Numeric value expected.'); - let typeName: string = option.valueType.toString(); - if (typeName === ServiceOptionTypeNames.number) { + if (option.valueType === ServiceOptionType.number) { optionWidget = new InputBox(rowContainer.getHTMLElement(), contextViewService, { validationOptions: { validation: (value: string) => { @@ -48,11 +47,11 @@ export function createOptionElement(option: data.ServiceOption, rowContainer: Bu }); optionWidget.value = optionValue; inputElement = this.findElement(rowContainer, 'input'); - } else if (typeName === ServiceOptionTypeNames.category || typeName === ServiceOptionTypeNames.boolean) { + } else if (option.valueType === ServiceOptionType.category || option.valueType === ServiceOptionType.boolean) { optionWidget = new SelectBox(possibleInputs, optionValue.toString()); DialogHelper.appendInputSelectBox(rowContainer, optionWidget); inputElement = this.findElement(rowContainer, 'select-box'); - } else if (typeName === ServiceOptionTypeNames.string || typeName === ServiceOptionTypeNames.password) { + } else if (option.valueType === ServiceOptionType.string || option.valueType === ServiceOptionType.password) { optionWidget = new InputBox(rowContainer.getHTMLElement(), contextViewService, { validationOptions: { validation: (value: string) => (!value && option.isRequired) ? ({ type: MessageType.ERROR, content: option.displayName + missingErrorMessage }) : null @@ -70,11 +69,10 @@ export function createOptionElement(option: data.ServiceOption, rowContainer: Bu export function getOptionValueAndCategoryValues(option: data.ServiceOption, options: { [optionName: string]: any }, possibleInputs: string[]): any { - let valueTypeName:string = option.valueType.toString(); var optionValue = option.defaultValue; if (options[option.name]) { // if the value type is boolean, the option value can be either boolean or string - if (valueTypeName === ServiceOptionTypeNames.boolean) { + if (option.valueType === ServiceOptionType.boolean) { if (options[option.name] === true || options[option.name] === this.trueInputValue) { optionValue = this.trueInputValue; } else { @@ -85,13 +83,13 @@ export function getOptionValueAndCategoryValues(option: data.ServiceOption, opti } } - if (valueTypeName === ServiceOptionTypeNames.boolean || valueTypeName === ServiceOptionTypeNames.category) { + if (option.valueType === ServiceOptionType.boolean || option.valueType === ServiceOptionType.category) { // If the option is not required, the empty string should be add at the top of possible choices if (!option.isRequired) { possibleInputs.push(''); } - if (valueTypeName === ServiceOptionTypeNames.boolean) { + if (option.valueType === ServiceOptionType.boolean) { possibleInputs.push(this.trueInputValue, this.falseInputValue); } else { option.categoryValues.map(c => possibleInputs.push(c.name)); @@ -111,9 +109,9 @@ export function validateInputs(optionsMap: { [optionName: string]: IOptionElemen for (var optionName in optionsMap) { var optionElement: IOptionElement = optionsMap[optionName]; var widget = optionElement.optionWidget; - var isInputBox = (optionElement.option.valueType.toString() === ServiceOptionTypeNames.string || - optionElement.option.valueType.toString() === ServiceOptionTypeNames.password || - optionElement.option.valueType.toString() === ServiceOptionTypeNames.number); + var isInputBox = (optionElement.option.valueType === ServiceOptionType.string || + optionElement.option.valueType === ServiceOptionType.password || + optionElement.option.valueType === ServiceOptionType.number); if (isInputBox) { if (!widget.validate()) { diff --git a/src/sql/data.d.ts b/src/sql/data.d.ts index b676b38738..d797f402e6 100644 --- a/src/sql/data.d.ts +++ b/src/sql/data.d.ts @@ -661,12 +661,6 @@ declare module 'data' { ownerUri: string; } - export interface QueryExecuteParams { - ownerUri: string; - querySelection: ISelectionData; - executionPlanOptions?: ExecutionPlanOptions; - } - export interface QueryExecuteSubsetParams { ownerUri: string; batchIndex: number; diff --git a/src/sql/parts/connection/common/connectionConfig.ts b/src/sql/parts/connection/common/connectionConfig.ts index 8c3f8ffda5..df28c31fe4 100644 --- a/src/sql/parts/connection/common/connectionConfig.ts +++ b/src/sql/parts/connection/common/connectionConfig.ts @@ -68,10 +68,9 @@ export class ConnectionConfig implements IConnectionConfig { allGroups = allGroups.concat(userGroups); } allGroups = allGroups.map(g => { - // @SQLTODO - // if (g.parentId === '' || !g.parentId) { - // g.parentId = undefined; - // } + if (g.parentId === '' || !g.parentId) { + g.parentId = undefined; + } return g; }); return allGroups; diff --git a/src/sql/workbench/api/common/sqlExtHostTypes.ts b/src/sql/workbench/api/common/sqlExtHostTypes.ts index 0ea2bfadf0..89beaad413 100644 --- a/src/sql/workbench/api/common/sqlExtHostTypes.ts +++ b/src/sql/workbench/api/common/sqlExtHostTypes.ts @@ -15,17 +15,6 @@ export enum ServiceOptionType { object = 6 } -// SQL added extension host types -export enum ServiceOptionTypeNames { - string = 'string', - multistring = 'multistring', - password = 'password', - number = 'number', - category = 'category', - boolean = 'boolean', - object = 'object' -} - export enum ConnectionOptionSpecialType { serverName = 'serverName', databaseName = 'databaseName', diff --git a/src/sqltest/parts/common/optionsDialogHelper.test.ts b/src/sqltest/parts/common/optionsDialogHelper.test.ts index 5f1155e4ce..2bcf763e3a 100644 --- a/src/sqltest/parts/common/optionsDialogHelper.test.ts +++ b/src/sqltest/parts/common/optionsDialogHelper.test.ts @@ -10,7 +10,7 @@ import data = require('data'); import { Builder, $ } from 'vs/base/browser/builder'; import * as TypeMoq from 'typemoq'; import * as assert from 'assert'; -import { ServiceOptionType, ServiceOptionTypeNames } from 'sql/workbench/api/common/sqlExtHostTypes'; +import { ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes'; suite('Advanced options helper tests', () => { var possibleInputs: string[]; @@ -41,7 +41,7 @@ suite('Advanced options helper tests', () => { ], defaultValue: null, isRequired: false, - valueType: ServiceOptionTypeNames.category, + valueType: ServiceOptionType.category, objectType: undefined, isArray: undefined }; @@ -54,7 +54,7 @@ suite('Advanced options helper tests', () => { categoryValues: null, defaultValue: null, isRequired: false, - valueType: ServiceOptionTypeNames.boolean, + valueType: ServiceOptionType.boolean, objectType: undefined, isArray: undefined }; @@ -67,7 +67,7 @@ suite('Advanced options helper tests', () => { categoryValues: null, defaultValue: '15', isRequired: false, - valueType: ServiceOptionTypeNames.number, + valueType: ServiceOptionType.number, objectType: undefined, isArray: undefined }; @@ -80,7 +80,7 @@ suite('Advanced options helper tests', () => { categoryValues: null, defaultValue: null, isRequired: false, - valueType: ServiceOptionTypeNames.string, + valueType: ServiceOptionType.string, objectType: undefined, isArray: undefined }; @@ -93,7 +93,7 @@ suite('Advanced options helper tests', () => { categoryValues: null, defaultValue: null, isRequired: false, - valueType: ServiceOptionTypeNames.string, + valueType: ServiceOptionType.string, objectType: undefined, isArray: undefined }; diff --git a/yarn.lock b/yarn.lock index c02483aab2..36092a5938 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5173,9 +5173,9 @@ slice-ansi@0.0.4: version "0.0.4" resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-0.0.4.tgz#edbf8903f66f7ce2f8eafd6ceed65e264c831b35" -"slickgrid@github:anthonydresser/SlickGrid#2.3.12": - version "2.3.12" - resolved "https://codeload.github.com/anthonydresser/SlickGrid/tar.gz/5610e05166cd7068dcf196498ae20054382b1684" +"slickgrid@github:anthonydresser/SlickGrid#2.3.7": + version "2.3.4" + resolved "https://codeload.github.com/anthonydresser/SlickGrid/tar.gz/fa7911c34b5449f9ce1e7148480fbc24fd20743a" dependencies: jquery ">=1.8.0" jquery-ui ">=1.8.0"