mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
SQL Operations Studio Public Preview 1 (0.23) release source code
This commit is contained in:
1
extensions/mssql/.gitignore
vendored
Normal file
1
extensions/mssql/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
sqltoolsservice
|
||||
1127
extensions/mssql/client/src/config.json
Normal file
1127
extensions/mssql/client/src/config.json
Normal file
File diff suppressed because it is too large
Load Diff
168
extensions/mssql/client/src/controllers/mainController.ts
Normal file
168
extensions/mssql/client/src/controllers/mainController.ts
Normal file
@@ -0,0 +1,168 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
import vscode = require('vscode');
|
||||
import data = require('data');
|
||||
import { Constants } from '../models/constants';
|
||||
import { Serialization } from '../serialize/serialization';
|
||||
import { AzureResourceProvider } from '../resourceProvider/resourceProvider';
|
||||
import { CredentialStore } from '../credentialstore/credentialstore';
|
||||
import {IExtensionConstants, Telemetry, SharedConstants, SqlToolsServiceClient, VscodeWrapper, Utils, PlatformInformation} from 'extensions-modules';
|
||||
import { LanguageClient } from 'dataprotocol-client';
|
||||
|
||||
/**
|
||||
* The main controller class that initializes the extension
|
||||
*/
|
||||
export default class MainController implements vscode.Disposable {
|
||||
private _context: vscode.ExtensionContext;
|
||||
private _vscodeWrapper: VscodeWrapper;
|
||||
private _initialized: boolean = false;
|
||||
private _serialization: Serialization;
|
||||
private _credentialStore: CredentialStore;
|
||||
private static _extensionConstants: IExtensionConstants = new Constants();
|
||||
private _client: SqlToolsServiceClient;
|
||||
/**
|
||||
* The main controller constructor
|
||||
* @constructor
|
||||
*/
|
||||
constructor(context: vscode.ExtensionContext,
|
||||
vscodeWrapper?: VscodeWrapper) {
|
||||
this._context = context;
|
||||
this._vscodeWrapper = vscodeWrapper || new VscodeWrapper(MainController._extensionConstants);
|
||||
SqlToolsServiceClient.constants = MainController._extensionConstants;
|
||||
this._client = SqlToolsServiceClient.instance;
|
||||
this._credentialStore = new CredentialStore(this._client);
|
||||
this._serialization = new Serialization(this._client);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disposes the controller
|
||||
*/
|
||||
dispose(): void {
|
||||
this.deactivate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivates the extension
|
||||
*/
|
||||
public deactivate(): void {
|
||||
Utils.logDebug(SharedConstants.extensionDeactivated, MainController._extensionConstants.extensionConfigSectionName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the extension
|
||||
*/
|
||||
public activate(): Promise<boolean> {
|
||||
return this.initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a flag indicating if the extension is initialized
|
||||
*/
|
||||
public isInitialized(): boolean {
|
||||
return this._initialized;
|
||||
}
|
||||
|
||||
private createClient( executableFiles: string[]): Promise<LanguageClient> {
|
||||
return PlatformInformation.getCurrent(SqlToolsServiceClient.constants.getRuntimeId, SqlToolsServiceClient.constants.extensionName).then( platformInfo => {
|
||||
return SqlToolsServiceClient.instance.createClient(this._context, platformInfo.runtimeId, undefined, executableFiles);
|
||||
});
|
||||
}
|
||||
|
||||
private createCredentialClient(): Promise<LanguageClient> {
|
||||
return this.createClient(['MicrosoftSqlToolsCredentials.exe', 'MicrosoftSqlToolsCredentials']);
|
||||
}
|
||||
|
||||
private createSerializationClient(): Promise<LanguageClient> {
|
||||
return this.createClient(['MicrosoftSqlToolsSerialization.exe', 'MicrosoftSqlToolsSerialization']);
|
||||
}
|
||||
|
||||
private createResourceProviderClient(): Promise<LanguageClient> {
|
||||
return this.createClient(['SqlToolsResourceProviderService.exe', 'SqlToolsResourceProviderService']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the extension
|
||||
*/
|
||||
public initialize(): Promise<boolean> {
|
||||
const self = this;
|
||||
|
||||
// initialize language service client
|
||||
return new Promise<boolean>( (resolve, reject) => {
|
||||
const self = this;
|
||||
SqlToolsServiceClient.instance.initialize(self._context).then(serverResult => {
|
||||
|
||||
// Initialize telemetry
|
||||
Telemetry.initialize(self._context, new Constants());
|
||||
|
||||
// telemetry for activation
|
||||
Telemetry.sendTelemetryEvent('ExtensionActivated', {},
|
||||
{ serviceInstalled: serverResult.installedBeforeInitializing ? 1 : 0 }
|
||||
);
|
||||
|
||||
/*
|
||||
self.createSerializationClient().then(serializationClient => {
|
||||
let serialization = new Serialization(self._client, serializationClient);
|
||||
// Serialization
|
||||
let serializationProvider: data.SerializationProvider = {
|
||||
handle: 0,
|
||||
saveAs(saveFormat: string, savePath: string, results: string, appendToFile: boolean): Thenable<data.SaveResultRequestResult> {
|
||||
return self._serialization.saveAs(saveFormat, savePath, results, appendToFile);
|
||||
}
|
||||
};
|
||||
data.serialization.registerProvider(serializationProvider);
|
||||
}, error => {
|
||||
Utils.logDebug('Cannot find Serialization executables. error: ' + error , MainController._extensionConstants.extensionConfigSectionName);
|
||||
});
|
||||
|
||||
self.createResourceProviderClient().then(rpClient => {
|
||||
let resourceProvider = new AzureResourceProvider(self._client, rpClient);
|
||||
data.resources.registerResourceProvider({
|
||||
displayName: 'Azure SQL Resource Provider', // TODO Localize
|
||||
id: 'Microsoft.Azure.SQL.ResourceProvider',
|
||||
settings: {
|
||||
|
||||
}
|
||||
}, resourceProvider);
|
||||
Utils.logDebug('resourceProvider registered', MainController._extensionConstants.extensionConfigSectionName);
|
||||
}, error => {
|
||||
Utils.logDebug('Cannot find ResourceProvider executables. error: ' + error , MainController._extensionConstants.extensionConfigSectionName);
|
||||
});
|
||||
*/
|
||||
|
||||
self.createCredentialClient().then(credentialClient => {
|
||||
|
||||
self._credentialStore.languageClient = credentialClient;
|
||||
let credentialProvider: data.CredentialProvider = {
|
||||
handle: 0,
|
||||
saveCredential(credentialId: string, password: string): Thenable<boolean> {
|
||||
return self._credentialStore.saveCredential(credentialId, password);
|
||||
},
|
||||
readCredential(credentialId: string): Thenable<data.Credential> {
|
||||
return self._credentialStore.readCredential(credentialId);
|
||||
},
|
||||
deleteCredential(credentialId: string): Thenable<boolean> {
|
||||
return self._credentialStore.deleteCredential(credentialId);
|
||||
}
|
||||
};
|
||||
data.credentials.registerProvider(credentialProvider);
|
||||
Utils.logDebug('credentialProvider registered', MainController._extensionConstants.extensionConfigSectionName);
|
||||
}, error => {
|
||||
Utils.logDebug('Cannot find credentials executables. error: ' + error , MainController._extensionConstants.extensionConfigSectionName);
|
||||
});
|
||||
|
||||
|
||||
|
||||
Utils.logDebug(SharedConstants.extensionActivated, MainController._extensionConstants.extensionConfigSectionName);
|
||||
self._initialized = true;
|
||||
resolve(true);
|
||||
}).catch(err => {
|
||||
Telemetry.sendTelemetryEventForException(err, 'initialize', MainController._extensionConstants.extensionConfigSectionName);
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as Contracts from '../models/contracts';
|
||||
import { ICredentialStore } from './icredentialstore';
|
||||
import { SqlToolsServiceClient, Utils } from 'extensions-modules';
|
||||
import { LanguageClient } from 'dataprotocol-client';
|
||||
|
||||
/**
|
||||
* Implements a credential storage for Windows, Mac (darwin), or Linux.
|
||||
*
|
||||
* Allows a single credential to be stored per service (that is, one username per service);
|
||||
*/
|
||||
export class CredentialStore implements ICredentialStore {
|
||||
|
||||
public languageClient: LanguageClient;
|
||||
|
||||
constructor(private _client?: SqlToolsServiceClient) {
|
||||
if (!this._client) {
|
||||
this._client = SqlToolsServiceClient.instance;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a credential saved in the credential store
|
||||
*
|
||||
* @param {string} credentialId the ID uniquely identifying this credential
|
||||
* @returns {Promise<Credential>} Promise that resolved to the credential, or undefined if not found
|
||||
*/
|
||||
public readCredential(credentialId: string): Promise<Contracts.Credential> {
|
||||
Utils.logDebug(this.languageClient, 'MainController._extensionConstants');
|
||||
let self = this;
|
||||
let cred: Contracts.Credential = new Contracts.Credential();
|
||||
cred.credentialId = credentialId;
|
||||
return new Promise<Contracts.Credential>( (resolve, reject) => {
|
||||
self._client
|
||||
.sendRequest(Contracts.ReadCredentialRequest.type, cred, this.languageClient)
|
||||
.then(returnedCred => {
|
||||
resolve(<Contracts.Credential>returnedCred);
|
||||
}, err => reject(err));
|
||||
});
|
||||
}
|
||||
|
||||
public saveCredential(credentialId: string, password: any): Promise<boolean> {
|
||||
let self = this;
|
||||
let cred: Contracts.Credential = new Contracts.Credential();
|
||||
cred.credentialId = credentialId;
|
||||
cred.password = password;
|
||||
return new Promise<boolean>( (resolve, reject) => {
|
||||
self._client
|
||||
.sendRequest(Contracts.SaveCredentialRequest.type, cred, this.languageClient)
|
||||
.then(status => {
|
||||
resolve(<boolean>status);
|
||||
}, err => reject(err));
|
||||
});
|
||||
}
|
||||
|
||||
public deleteCredential(credentialId: string): Promise<boolean> {
|
||||
let self = this;
|
||||
let cred: Contracts.Credential = new Contracts.Credential();
|
||||
cred.credentialId = credentialId;
|
||||
return new Promise<boolean>( (resolve, reject) => {
|
||||
self._client
|
||||
.sendRequest(Contracts.DeleteCredentialRequest.type, cred, this.languageClient)
|
||||
.then(status => {
|
||||
resolve(<boolean>status);
|
||||
}, err => reject(err));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
|
||||
// This code is originally from https://github.com/microsoft/vsts-vscode
|
||||
// License: https://github.com/Microsoft/vsts-vscode/blob/master/LICENSE.txt
|
||||
|
||||
import { Credential } from '../models/contracts';
|
||||
|
||||
/**
|
||||
* A credential store that securely stores sensitive information in a platform-specific manner
|
||||
*
|
||||
* @export
|
||||
* @interface ICredentialStore
|
||||
*/
|
||||
export interface ICredentialStore {
|
||||
readCredential(credentialId: string): Promise<Credential>;
|
||||
saveCredential(credentialId: string, password: any): Promise<boolean>;
|
||||
deleteCredential(credentialId: string): Promise<boolean>;
|
||||
}
|
||||
317
extensions/mssql/client/src/models/constants.ts
Normal file
317
extensions/mssql/client/src/models/constants.ts
Normal file
@@ -0,0 +1,317 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import {IExtensionConstants} from 'extensions-modules/lib/models/contracts/contracts';
|
||||
import {Runtime, LinuxDistribution} from 'extensions-modules/lib/models/platform';
|
||||
|
||||
// constants
|
||||
export class Constants implements IExtensionConstants {
|
||||
public readonly languageId = 'sql';
|
||||
public readonly extensionName = 'mssql';
|
||||
public readonly extensionConfigSectionName = 'mssql';
|
||||
public readonly connectionApplicationName = 'vscode-mssql';
|
||||
public readonly outputChannelName = 'MSSQL';
|
||||
public readonly connectionConfigFilename = 'settings.json';
|
||||
public readonly connectionsArrayName = 'mssql.connections';
|
||||
public readonly cmdRunQuery = 'extension.runQuery';
|
||||
public readonly cmdCancelQuery = 'extension.cancelQuery';
|
||||
public readonly cmdConnect = 'extension.connect';
|
||||
public readonly cmdDisconnect = 'extension.disconnect';
|
||||
public readonly cmdChooseDatabase = 'extension.chooseDatabase';
|
||||
public readonly cmdShowReleaseNotes = 'extension.showReleaseNotes';
|
||||
public readonly cmdShowGettingStarted = 'extension.showGettingStarted';
|
||||
public readonly cmdNewQuery = 'extension.newQuery';
|
||||
public readonly cmdManageConnectionProfiles = 'extension.manageProfiles';
|
||||
public readonly sqlDbPrefix = '.database.windows.net';
|
||||
public readonly defaultConnectionTimeout = 15;
|
||||
public readonly azureSqlDbConnectionTimeout = 30;
|
||||
public readonly azureDatabase = 'Azure';
|
||||
public readonly defaultPortNumber = 1433;
|
||||
public readonly sqlAuthentication = 'SqlLogin';
|
||||
public readonly defaultDatabase = 'master';
|
||||
public readonly errorPasswordExpired = 18487;
|
||||
public readonly errorPasswordNeedsReset = 18488;
|
||||
public readonly maxDisplayedStatusTextLength = 50;
|
||||
public readonly outputContentTypeRoot = 'root';
|
||||
public readonly outputContentTypeMessages = 'messages';
|
||||
public readonly outputContentTypeResultsetMeta = 'resultsetsMeta';
|
||||
public readonly outputContentTypeColumns = 'columns';
|
||||
public readonly outputContentTypeRows = 'rows';
|
||||
public readonly outputContentTypeConfig = 'config';
|
||||
public readonly outputContentTypeSaveResults = 'saveResults';
|
||||
public readonly outputContentTypeOpenLink = 'openLink';
|
||||
public readonly outputContentTypeCopy = 'copyResults';
|
||||
public readonly outputContentTypeEditorSelection = 'setEditorSelection';
|
||||
public readonly outputContentTypeShowError = 'showError';
|
||||
public readonly outputContentTypeShowWarning = 'showWarning';
|
||||
public readonly outputServiceLocalhost = 'http://localhost:';
|
||||
public readonly msgContentProviderSqlOutputHtml = 'dist/html/sqlOutput.ejs';
|
||||
public readonly contentProviderMinFile = 'dist/js/app.min.js';
|
||||
public readonly configLogDebugInfo = 'logDebugInfo';
|
||||
public readonly providerId = 'MSSQL';
|
||||
public readonly installFolderName = 'sqltoolsservice';
|
||||
public readonly telemetryExtensionName = 'carbon-mssql';
|
||||
|
||||
// localizable strings
|
||||
public readonly configMyConnectionsNoServerName = 'Missing server name in user preferences connection: ';
|
||||
public readonly msgLocalWebserviceStaticContent = 'LocalWebService: added static html content path: ';
|
||||
public readonly msgLocalWebserviceStarted = 'LocalWebService listening on port ';
|
||||
public readonly msgRunQueryAllBatchesExecuted = 'runQuery: all batches executed';
|
||||
public readonly msgStartedExecute = 'Started query execution for document "{0}"';
|
||||
public readonly msgFinishedExecute = 'Finished query execution for document "{0}"';
|
||||
public readonly msgRunQueryError = 'runQuery: error: ';
|
||||
public readonly msgRunQueryExecutingBatch = 'runQuery: executeBatch called with SQL: ';
|
||||
public readonly msgRunQueryAddBatchResultsets = 'runQuery: adding resultsets for batch: ';
|
||||
public readonly msgRunQueryAddBatchError = 'runQuery: adding error message for batch: ';
|
||||
public readonly msgRunQueryConnectionActive = 'runQuery: active connection is connected, using it to run query';
|
||||
public readonly msgRunQueryConnectionDisconnected = 'runQuery: active connection is disconnected, reconnecting';
|
||||
public readonly msgRunQueryNoConnection = 'runQuery: no active connection - prompting for user';
|
||||
public readonly msgRunQueryInProgress = 'A query is already running for this editor session. Please cancel this query or wait for its completion.';
|
||||
public readonly runQueryBatchStartMessage = 'Started executing query at ';
|
||||
public readonly runQueryBatchStartLine = 'Line {0}';
|
||||
public readonly msgCancelQueryFailed = 'Canceling the query failed: {0}';
|
||||
public readonly msgCancelQueryNotRunning = 'Cannot cancel query as no query is running.';
|
||||
public readonly msgCancelQuerySuccess = 'Successfully canceled the query.';
|
||||
public readonly msgContentProviderOnContentUpdated = 'Content provider: onContentUpdated called';
|
||||
public readonly msgContentProviderAssociationFailure = 'Content provider: Unable to associate status view for current file';
|
||||
public readonly msgContentProviderOnRootEndpoint = 'LocalWebService: Root end-point called';
|
||||
public readonly msgContentProviderOnResultsEndpoint = 'LocalWebService: ResultsetsMeta endpoint called';
|
||||
public readonly msgContentProviderOnMessagesEndpoint = 'LocalWebService: Messages end-point called';
|
||||
public readonly msgContentProviderOnColumnsEndpoint = 'LocalWebService: Columns end-point called for index = ';
|
||||
public readonly msgContentProviderOnRowsEndpoint = 'LocalWebService: Rows end-point called for index = ';
|
||||
public readonly msgContentProviderOnClear = 'Content provider: clear called';
|
||||
public readonly msgContentProviderOnUpdateContent = 'Content provider: updateContent called';
|
||||
public readonly msgContentProviderProvideContent = 'Content provider: provideTextDocumentContent called: ';
|
||||
public readonly msgChooseDatabaseNotConnected = 'No connection was found. Please connect to a server first.';
|
||||
public readonly msgChooseDatabasePlaceholder = 'Choose a database from the list below';
|
||||
public readonly msgConnectionError = 'Error {0}: {1}';
|
||||
public readonly msgConnectionError2 = 'Failed to connect: {0}';
|
||||
public readonly msgConnectionErrorPasswordExpired = 'Error {0}: {1} Please login as a different user and change the password using ALTER LOGIN.';
|
||||
public readonly connectionErrorChannelName = 'Connection Errors';
|
||||
public readonly msgPromptCancelConnect = 'Server connection in progress. Do you want to cancel?';
|
||||
public readonly msgPromptClearRecentConnections = 'Confirm to clear recent connections list';
|
||||
public readonly msgOpenSqlFile = 'To use this command, Open a .sql file -or- ' +
|
||||
'Change editor language to "SQL" -or- ' +
|
||||
'Select T-SQL text in the active SQL editor.';
|
||||
public readonly recentConnectionsPlaceholder = 'Choose a connection profile from the list below';
|
||||
public readonly msgNoConnectionsInSettings = 'To use this command, add connection profile to User Settings.';
|
||||
public readonly labelOpenGlobalSettings = 'Open Global Settings';
|
||||
public readonly labelOpenWorkspaceSettings = 'Open Workspace Settings';
|
||||
public readonly CreateProfileFromConnectionsListLabel = 'Create Connection Profile';
|
||||
public readonly CreateProfileLabel = 'Create';
|
||||
public readonly ClearRecentlyUsedLabel = 'Clear Recent Connections List';
|
||||
public readonly EditProfilesLabel = 'Edit';
|
||||
public readonly RemoveProfileLabel = 'Remove';
|
||||
public readonly ManageProfilesPrompt = 'Manage Connection Profiles';
|
||||
public readonly SampleServerName = '{{put-server-name-here}}';
|
||||
public readonly serverPrompt = 'Server name';
|
||||
public readonly serverPlaceholder = 'hostname\\instance or <server>.database.windows.net';
|
||||
public readonly databasePrompt = 'Database name';
|
||||
public readonly databasePlaceholder = '[Optional] Database to connect (press Enter to connect to <default> database)';
|
||||
public readonly databaseDefaultValue = 'master';
|
||||
public readonly authTypePrompt = 'Authentication Type';
|
||||
public readonly authTypeIntegrated = 'Integrated';
|
||||
public readonly authTypeSql = 'SQL Login';
|
||||
public readonly authTypeAdUniversal = 'Active Directory Universal';
|
||||
public readonly usernamePrompt = 'User name';
|
||||
public readonly usernamePlaceholder = 'User name (SQL Login)';
|
||||
public readonly passwordPrompt = 'Password';
|
||||
public readonly passwordPlaceholder = 'Password (SQL Login)';
|
||||
public readonly msgSavePassword = 'Save Password? If \'No\', password will be required each time you connect';
|
||||
public readonly profileNamePrompt = 'Profile Name';
|
||||
public readonly profileNamePlaceholder = '[Optional] Enter a name for this profile';
|
||||
public readonly filepathPrompt = 'File path';
|
||||
public readonly filepathPlaceholder = 'File name';
|
||||
public readonly filepathMessage = 'File name';
|
||||
public readonly overwritePrompt = 'A file with this name already exists. Do you want to replace the existing file?';
|
||||
public readonly overwritePlaceholder = 'A file with this name already exists';
|
||||
public readonly msgSaveResultInProgress = 'A save request is already executing. Please wait for its completion.';
|
||||
public readonly msgCannotOpenContent = 'Error occurred opening content in editor.';
|
||||
public readonly msgSaveStarted = 'Started saving results to ';
|
||||
public readonly msgSaveFailed = 'Failed to save results. ';
|
||||
public readonly msgSaveSucceeded = 'Successfully saved results to ';
|
||||
public readonly msgSelectProfile = 'Select connection profile';
|
||||
public readonly msgSelectProfileToRemove = 'Select profile to remove';
|
||||
public readonly confirmRemoveProfilePrompt = 'Confirm to remove this profile.';
|
||||
public readonly msgNoProfilesSaved = 'No connection profile to remove.';
|
||||
public readonly msgProfileRemoved = 'Profile removed successfully';
|
||||
public readonly msgProfileCreated = 'Profile created successfully';
|
||||
public readonly msgProfileCreatedAndConnected = 'Profile created and connected';
|
||||
public readonly msgClearedRecentConnections = 'Recent connections list cleared';
|
||||
public readonly msgSelectionIsRequired = 'Selection is required.';
|
||||
public readonly msgIsRequired = ' is required.';
|
||||
public readonly msgRetry = 'Retry';
|
||||
public readonly msgError = 'Error: ';
|
||||
public readonly msgYes = 'Yes';
|
||||
public readonly msgNo = 'No';
|
||||
public readonly defaultDatabaseLabel = '<default>';
|
||||
public readonly notConnectedLabel = 'Disconnected';
|
||||
public readonly notConnectedTooltip = 'Click to connect to a database';
|
||||
public readonly connectingLabel = 'Connecting';
|
||||
public readonly connectingTooltip = 'Connecting to: ';
|
||||
public readonly connectedLabel = 'Connected.';
|
||||
public readonly connectErrorLabel = 'Connection error';
|
||||
public readonly connectErrorTooltip = 'Error connecting to: ';
|
||||
public readonly connectErrorCode = 'Errorcode: ';
|
||||
public readonly connectErrorMessage = 'ErrorMessage: ';
|
||||
public readonly executeQueryLabel = 'Executing query ';
|
||||
public readonly cancelingQueryLabel = 'Canceling query ';
|
||||
public readonly updatingIntelliSenseLabel = 'Updating IntelliSense...';
|
||||
public readonly unfoundResult = 'Data was disposed when text editor was closed; to view data please reexecute query.';
|
||||
public readonly serviceCompatibleVersion = '1.0.0';
|
||||
public readonly serviceNotCompatibleError = 'Client is not compatible with the service layer';
|
||||
public readonly serviceInstallingTo = 'Installing SQL tools service to';
|
||||
public readonly serviceInitializing = 'Initializing SQL tools service for the mssql extension.';
|
||||
public readonly commandsNotAvailableWhileInstallingTheService = 'Note: mssql commands will be available after installing the service.';
|
||||
public readonly serviceInstalled = 'Sql Tools Service installed';
|
||||
public readonly serviceInstallationFailed = 'Failed to install Sql Tools Service';
|
||||
public readonly serviceLoadingFailed = 'Failed to load Sql Tools Service';
|
||||
public readonly invalidServiceFilePath = 'Invalid file path for Sql Tools Service';
|
||||
public readonly extensionNotInitializedError = 'Unable to execute the command while the extension is initializing. Please try again later.';
|
||||
public readonly untitledScheme = 'untitled';
|
||||
public readonly untitledSaveTimeThreshold = 10.0;
|
||||
public readonly renamedOpenTimeThreshold = 10.0;
|
||||
public readonly msgChangeLanguageMode = 'To use this command, you must set the language to \"SQL\". Confirm to change language mode.';
|
||||
public readonly timeToWaitForLanguageModeChange = 10000.0;
|
||||
public readonly msgChangedDatabaseContext = 'Changed database context to \"{0}\" for document \"{1}\"';
|
||||
public readonly msgPromptRetryCreateProfile = 'Error: Unable to connect using the connection information provided. Retry profile creation?';
|
||||
public readonly retryLabel = 'Retry';
|
||||
public readonly msgConnecting = 'Connecting to server \"{0}\" on document \"{1}\".';
|
||||
public readonly msgConnectedServerInfo = 'Connected to server \"{0}\" on document \"{1}\". Server information: {2}';
|
||||
public readonly msgConnectionFailed = 'Error connecting to server \"{0}\". Details: {1}';
|
||||
public readonly msgChangingDatabase = 'Changing database context to \"{0}\" on server \"{1}\" on document \"{2}\".';
|
||||
public readonly msgChangedDatabase = 'Changed database context to \"{0}\" on server \"{1}\" on document \"{2}\".';
|
||||
public readonly msgDisconnected = 'Disconnected on document \"{0}\"';
|
||||
public readonly msgErrorReadingConfigFile = 'Error: Unable to load connection profiles from [{0}]. Check if the file is formatted correctly.';
|
||||
public readonly msgErrorOpeningConfigFile = 'Error: Unable to open connection profile settings file.';
|
||||
public readonly extConfigResultKeys = ['shortcuts', 'messagesDefaultOpen'];
|
||||
public readonly extConfigResultFontFamily = 'resultsFontFamily';
|
||||
public readonly extConfigResultFontSize = 'resultsFontSize';
|
||||
public readonly titleResultsPane = 'Results: {0}';
|
||||
public readonly macOpenSslErrorMessage = `OpenSSL version >=1.0.1 is required to connect.`;
|
||||
public readonly macOpenSslHelpButton = 'Help';
|
||||
public readonly macOpenSslHelpLink = 'https://github.com/Microsoft/vscode-mssql/wiki/OpenSSL-Configuration';
|
||||
public readonly serviceName = 'SQLToolsService';
|
||||
public readonly serviceInitializingOutputChannelName = 'SqlToolsService Initialization';
|
||||
public readonly gettingStartedGuideLink = 'https://aka.ms/mssql-getting-started';
|
||||
public readonly serviceCrashMessage = 'SQL Tools Service component exited unexpectedly. Please restart SQL Operations Studio.';
|
||||
public readonly serviceCrashLink = 'https://github.com/Microsoft/vscode-mssql/wiki/SqlToolsService-Known-Issues';
|
||||
public readonly gettingDefinitionMessage = 'Getting definition ...';
|
||||
public readonly definitionRequestedStatus = 'DefinitionRequested';
|
||||
public readonly definitionRequestCompletedStatus = 'DefinitionRequestCompleted';
|
||||
public readonly updatingIntelliSenseStatus = 'updatingIntelliSense';
|
||||
public readonly intelliSenseUpdatedStatus = 'intelliSenseUpdated';
|
||||
|
||||
/**
|
||||
* Returns a supported .NET Core Runtime ID (RID) for the current platform. The list of Runtime IDs
|
||||
* is available at https://github.com/dotnet/corefx/tree/master/pkg/Microsoft.NETCore.Platforms.
|
||||
*/
|
||||
public getRuntimeId(platform: string, architecture: string, distribution: LinuxDistribution): Runtime {
|
||||
switch (platform) {
|
||||
case 'win32':
|
||||
switch (architecture) {
|
||||
case 'x86': return Runtime.Windows_86;
|
||||
case 'x86_64': return Runtime.Windows_64;
|
||||
default:
|
||||
}
|
||||
|
||||
throw new Error(`Unsupported Windows architecture: ${architecture}`);
|
||||
|
||||
case 'darwin':
|
||||
if (architecture === 'x86_64') {
|
||||
// Note: We return the El Capitan RID for Sierra
|
||||
return Runtime.OSX;
|
||||
}
|
||||
|
||||
throw new Error(`Unsupported macOS architecture: ${architecture}`);
|
||||
|
||||
case 'linux':
|
||||
if (architecture === 'x86_64') {
|
||||
|
||||
// First try the distribution name
|
||||
let runtimeId = Constants.getRuntimeIdHelper(distribution.name, distribution.version);
|
||||
|
||||
// If the distribution isn't one that we understand, but the 'ID_LIKE' field has something that we understand, use that
|
||||
//
|
||||
// NOTE: 'ID_LIKE' doesn't specify the version of the 'like' OS. So we will use the 'VERSION_ID' value. This will restrict
|
||||
// how useful ID_LIKE will be since it requires the version numbers to match up, but it is the best we can do.
|
||||
if (runtimeId === Runtime.UnknownRuntime && distribution.idLike && distribution.idLike.length > 0) {
|
||||
for (let id of distribution.idLike) {
|
||||
runtimeId = Constants.getRuntimeIdHelper(id, distribution.version);
|
||||
if (runtimeId !== Runtime.UnknownRuntime) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (runtimeId !== Runtime.UnknownRuntime && runtimeId !== Runtime.UnknownVersion) {
|
||||
return runtimeId;
|
||||
}
|
||||
}
|
||||
|
||||
// If we got here, this is not a Linux distro or architecture that we currently support.
|
||||
throw new Error(`Unsupported Linux distro: ${distribution.name}, ${distribution.version}, ${architecture}`);
|
||||
default :
|
||||
// If we got here, we've ended up with a platform we don't support like 'freebsd' or 'sunos'.
|
||||
// Chances are, VS Code doesn't support these platforms either.
|
||||
throw Error('Unsupported platform ' + platform);
|
||||
}
|
||||
}
|
||||
|
||||
private static getRuntimeIdHelper(distributionName: string, distributionVersion: string): Runtime {
|
||||
switch (distributionName) {
|
||||
case 'ubuntu':
|
||||
if (distributionVersion.startsWith('14')) {
|
||||
// This also works for Linux Mint
|
||||
return Runtime.Ubuntu_14;
|
||||
} else if (distributionVersion.startsWith('16')) {
|
||||
return Runtime.Ubuntu_16;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'elementary':
|
||||
case 'elementary OS':
|
||||
if (distributionVersion.startsWith('0.3')) {
|
||||
// Elementary OS 0.3 Freya is binary compatible with Ubuntu 14.04
|
||||
return Runtime.Ubuntu_14;
|
||||
} else if (distributionVersion.startsWith('0.4')) {
|
||||
// Elementary OS 0.4 Loki is binary compatible with Ubuntu 16.04
|
||||
return Runtime.Ubuntu_16;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'linuxmint':
|
||||
if (distributionVersion.startsWith('18')) {
|
||||
// Linux Mint 18 is binary compatible with Ubuntu 16.04
|
||||
return Runtime.Ubuntu_16;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'centos':
|
||||
case 'ol':
|
||||
// Oracle Linux is binary compatible with CentOS
|
||||
return Runtime.CentOS_7;
|
||||
case 'fedora':
|
||||
return Runtime.Fedora_23;
|
||||
case 'opensuse':
|
||||
return Runtime.OpenSUSE_13_2;
|
||||
case 'sles':
|
||||
return Runtime.SLES_12_2;
|
||||
case 'rhel':
|
||||
return Runtime.RHEL_7;
|
||||
case 'debian':
|
||||
return Runtime.Debian_8;
|
||||
case 'galliumos':
|
||||
if (distributionVersion.startsWith('2.0')) {
|
||||
return Runtime.Ubuntu_16;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return Runtime.UnknownRuntime;
|
||||
}
|
||||
|
||||
return Runtime.UnknownVersion;
|
||||
}
|
||||
}
|
||||
104
extensions/mssql/client/src/models/contracts.ts
Normal file
104
extensions/mssql/client/src/models/contracts.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import {RequestType} from 'dataprotocol-client';
|
||||
import * as data from 'data';
|
||||
|
||||
// DEV-NOTE: Still finalizing what we'll need as part of this interface
|
||||
/**
|
||||
* Contains necessary information for serializing and saving results
|
||||
* @param {string} saveFormat the format / type that the results will be saved in
|
||||
* @param {string} savePath path the results will be saved to
|
||||
* @param {string} results either a subset or all of the results we wish to save to savePath
|
||||
* @param {boolean} appendToFile Whether we should append or overwrite the file in savePath
|
||||
*/
|
||||
export class SaveResultsInfo {
|
||||
|
||||
|
||||
constructor(public saveFormat: string, public savePath: string, public results: string,
|
||||
public appendToFile: boolean) {
|
||||
}
|
||||
}
|
||||
|
||||
export namespace SaveAsRequest {
|
||||
export const type: RequestType<SaveResultsInfo, data.SaveResultRequestResult, void> = { get method(): string { return 'query/saveAs'; } };
|
||||
}
|
||||
|
||||
// --------------------------------- < Read Credential Request > -------------------------------------------------
|
||||
|
||||
// Read Credential request message callback declaration
|
||||
export namespace ReadCredentialRequest {
|
||||
export const type: RequestType<Credential, Credential, void> = { get method(): string { return 'credential/read'; } };
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters to initialize a connection to a database
|
||||
*/
|
||||
export class Credential {
|
||||
/**
|
||||
* Unique ID identifying the credential
|
||||
*/
|
||||
public credentialId: string;
|
||||
|
||||
/**
|
||||
* password
|
||||
*/
|
||||
public password: string;
|
||||
}
|
||||
|
||||
// --------------------------------- </ Read Credential Request > -------------------------------------------------
|
||||
|
||||
// --------------------------------- < Save Credential Request > -------------------------------------------------
|
||||
|
||||
// Save Credential request message callback declaration
|
||||
export namespace SaveCredentialRequest {
|
||||
export const type: RequestType<Credential, boolean, void> = { get method(): string { return 'credential/save'; } };
|
||||
}
|
||||
// --------------------------------- </ Save Credential Request > -------------------------------------------------
|
||||
|
||||
|
||||
// --------------------------------- < Delete Credential Request > -------------------------------------------------
|
||||
|
||||
// Delete Credential request message callback declaration
|
||||
export namespace DeleteCredentialRequest {
|
||||
export const type: RequestType<Credential, boolean, void> = { get method(): string { return 'credential/delete'; } };
|
||||
}
|
||||
// --------------------------------- </ Delete Credential Request > -------------------------------------------------
|
||||
|
||||
// ------------------------------- < Resource Events > ------------------------------------
|
||||
export namespace CreateFirewallRuleRequest {
|
||||
export const type: RequestType<CreateFirewallRuleParams, CreateFirewallRuleResponse, void> = { get method(): string { return 'resource/createFirewallRule'; } };
|
||||
}
|
||||
|
||||
export namespace HandleFirewallRuleRequest {
|
||||
export const type: RequestType<HandleFirewallRuleParams, HandleFirewallRuleResponse, void> = { get method(): string { return 'resource/handleFirewallRule'; } };
|
||||
}
|
||||
|
||||
// Firewall rule interfaces
|
||||
export interface CreateFirewallRuleParams {
|
||||
account: data.Account;
|
||||
serverName: string;
|
||||
startIpAddress: string;
|
||||
endIpAddress: string;
|
||||
securityTokenMappings: {};
|
||||
}
|
||||
|
||||
export interface CreateFirewallRuleResponse {
|
||||
result: boolean;
|
||||
errorMessage: string;
|
||||
}
|
||||
|
||||
export interface HandleFirewallRuleParams {
|
||||
errorCode: number;
|
||||
errorMessage: string;
|
||||
connectionTypeId: string;
|
||||
}
|
||||
|
||||
export interface HandleFirewallRuleResponse {
|
||||
result: boolean;
|
||||
ipAddress: string;
|
||||
}
|
||||
|
||||
30
extensions/mssql/client/src/mssqlMain.ts
Normal file
30
extensions/mssql/client/src/mssqlMain.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import vscode = require('vscode');
|
||||
import MainController from './controllers/mainController';
|
||||
|
||||
let controller: MainController = undefined;
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
controller = new MainController(context);
|
||||
context.subscriptions.push(controller);
|
||||
controller.activate();
|
||||
}
|
||||
|
||||
// this method is called when your extension is deactivated
|
||||
export function deactivate(): void {
|
||||
if (controller) {
|
||||
controller.deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Exposed for testing purposes
|
||||
*/
|
||||
export function getController(): MainController {
|
||||
return controller;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as Contracts from '../models/contracts';
|
||||
import { SqlToolsServiceClient } from 'extensions-modules';
|
||||
import { LanguageClient } from 'dataprotocol-client';
|
||||
import * as data from 'data';
|
||||
|
||||
|
||||
/**
|
||||
* Implements a credential storage for Windows, Mac (darwin), or Linux.
|
||||
*
|
||||
* Allows a single credential to be stored per service (that is, one username per service);
|
||||
*/
|
||||
export class AzureResourceProvider implements data.ResourceProvider {
|
||||
|
||||
public languageClient: LanguageClient;
|
||||
|
||||
constructor(private _client?: SqlToolsServiceClient, langClient?: LanguageClient) {
|
||||
if (!this._client) {
|
||||
this._client = SqlToolsServiceClient.instance;
|
||||
}
|
||||
this.languageClient = langClient;
|
||||
}
|
||||
|
||||
public createFirewallRule(account: data.Account, firewallruleInfo: data.FirewallRuleInfo): Thenable<data.CreateFirewallRuleResponse> {
|
||||
let self = this;
|
||||
return new Promise<data.CreateFirewallRuleResponse>((resolve, reject) => {
|
||||
self._client.
|
||||
sendRequest(Contracts.CreateFirewallRuleRequest.type, self.asCreateFirewallRuleParams(account, firewallruleInfo), self.languageClient)
|
||||
.then(response => {
|
||||
resolve(response);
|
||||
}, err => reject(err));
|
||||
});
|
||||
}
|
||||
|
||||
public handleFirewallRule(errorCode: number, errorMessage: string, connectionTypeId: string): Thenable<data.HandleFirewallRuleResponse> {
|
||||
let self = this;
|
||||
return new Promise<data.HandleFirewallRuleResponse>((resolve, reject) => {
|
||||
let params: Contracts.HandleFirewallRuleParams = { errorCode: errorCode, errorMessage: errorMessage, connectionTypeId: connectionTypeId };
|
||||
|
||||
self._client.
|
||||
sendRequest(Contracts.HandleFirewallRuleRequest.type, params, self.languageClient)
|
||||
.then(response => {
|
||||
resolve(response);
|
||||
}, err => reject(err));
|
||||
});
|
||||
}
|
||||
|
||||
private asCreateFirewallRuleParams(account: data.Account, params: data.FirewallRuleInfo): Contracts.CreateFirewallRuleParams {
|
||||
return {
|
||||
account: account,
|
||||
serverName: params.serverName,
|
||||
startIpAddress: params.startIpAddress,
|
||||
endIpAddress: params.endIpAddress,
|
||||
securityTokenMappings: params.securityTokenMappings
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
18
extensions/mssql/client/src/serialize/iserialization.ts
Normal file
18
extensions/mssql/client/src/serialize/iserialization.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { SaveResultsInfo } from '../models/contracts';
|
||||
import * as data from 'data';
|
||||
|
||||
/**
|
||||
* Serializer for saving results into a different format
|
||||
*
|
||||
* @export
|
||||
* @interface ISerialization
|
||||
*/
|
||||
export interface ISerialization {
|
||||
saveAs(saveFormat: string, savePath: string, results: string, appendToFile: boolean): Promise<data.SaveResultRequestResult>;
|
||||
}
|
||||
41
extensions/mssql/client/src/serialize/serialization.ts
Normal file
41
extensions/mssql/client/src/serialize/serialization.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as Contracts from '../models/contracts';
|
||||
import { ISerialization } from './iserialization';
|
||||
import { SqlToolsServiceClient } from 'extensions-modules';
|
||||
import * as data from 'data';
|
||||
import { LanguageClient } from 'dataprotocol-client';
|
||||
|
||||
/**
|
||||
* Implements serializer for query results
|
||||
*/
|
||||
export class Serialization implements ISerialization {
|
||||
|
||||
constructor(private _client?: SqlToolsServiceClient, private _languageClient?: LanguageClient) {
|
||||
if (!this._client) {
|
||||
this._client = SqlToolsServiceClient.instance;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves results as a specified path
|
||||
*
|
||||
* @param {string} credentialId the ID uniquely identifying this credential
|
||||
* @returns {Promise<ISaveResultsInfo>} Promise that resolved to the credential, or undefined if not found
|
||||
*/
|
||||
public saveAs(saveFormat: string, savePath: string, results: string, appendToFile: boolean): Promise<data.SaveResultRequestResult> {
|
||||
let self = this;
|
||||
let resultsInfo: Contracts.SaveResultsInfo = new Contracts.SaveResultsInfo(saveFormat, savePath, results, appendToFile);
|
||||
return new Promise<data.SaveResultRequestResult>( (resolve, reject) => {
|
||||
self._client
|
||||
.sendRequest(Contracts.SaveAsRequest.type, resultsInfo, this._languageClient)
|
||||
.then(result => {
|
||||
resolve(<data.SaveResultRequestResult>result);
|
||||
}, err => reject(err));
|
||||
});
|
||||
}
|
||||
}
|
||||
8
extensions/mssql/client/src/typings/ref.d.ts
vendored
Normal file
8
extensions/mssql/client/src/typings/ref.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/// <reference path='../../../../../src/vs/vscode.d.ts'/>
|
||||
/// <reference path='../../../../../src/sql/data.d.ts'/>
|
||||
/// <reference types='@types/node'/>
|
||||
19
extensions/mssql/client/tsconfig.json
Normal file
19
extensions/mssql/client/tsconfig.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"compileOnSave": true,
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"outDir": "./out",
|
||||
"lib": [
|
||||
"es6", "es2015.promise"
|
||||
],
|
||||
"sourceMap": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"moduleResolution": "node",
|
||||
"declaration": true
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
335
extensions/mssql/npm-shrinkwrap.json
generated
Normal file
335
extensions/mssql/npm-shrinkwrap.json
generated
Normal file
@@ -0,0 +1,335 @@
|
||||
{
|
||||
"name": "mssql",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"agent-base": {
|
||||
"version": "4.1.1",
|
||||
"from": "agent-base@>=4.0.0 <5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.1.1.tgz"
|
||||
},
|
||||
"applicationinsights": {
|
||||
"version": "0.18.0",
|
||||
"from": "applicationinsights@0.18.0",
|
||||
"resolved": "https://registry.npmjs.org/applicationinsights/-/applicationinsights-0.18.0.tgz"
|
||||
},
|
||||
"base64-js": {
|
||||
"version": "0.0.8",
|
||||
"from": "base64-js@0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-0.0.8.tgz"
|
||||
},
|
||||
"bl": {
|
||||
"version": "1.2.1",
|
||||
"from": "bl@>=1.0.0 <2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/bl/-/bl-1.2.1.tgz"
|
||||
},
|
||||
"bluebird": {
|
||||
"version": "3.5.0",
|
||||
"from": "bluebird@>=3.5.0 <4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.0.tgz"
|
||||
},
|
||||
"buffer": {
|
||||
"version": "3.6.0",
|
||||
"from": "buffer@>=3.0.1 <4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/buffer/-/buffer-3.6.0.tgz"
|
||||
},
|
||||
"buffer-crc32": {
|
||||
"version": "0.2.13",
|
||||
"from": "buffer-crc32@>=0.2.3 <0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz"
|
||||
},
|
||||
"commander": {
|
||||
"version": "2.8.1",
|
||||
"from": "commander@>=2.8.1 <2.9.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz"
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
"from": "core-util-is@>=1.0.0 <1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz"
|
||||
},
|
||||
"dataprotocol-client": {
|
||||
"version": "2.6.3",
|
||||
"from": "..\\..\\dataprotocol-node\\client",
|
||||
"resolved": "file:..\\..\\dataprotocol-node\\client"
|
||||
},
|
||||
"dataprotocol-jsonrpc": {
|
||||
"version": "2.4.0",
|
||||
"from": "..\\..\\dataprotocol-node\\jsonrpc",
|
||||
"resolved": "file:..\\..\\dataprotocol-node\\jsonrpc"
|
||||
},
|
||||
"dataprotocol-languageserver-types": {
|
||||
"version": "1.0.4",
|
||||
"from": "..\\..\\dataprotocol-node\\types",
|
||||
"resolved": "file:..\\..\\dataprotocol-node\\types"
|
||||
},
|
||||
"debug": {
|
||||
"version": "2.6.8",
|
||||
"from": "debug@>=2.0.0 <3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz"
|
||||
},
|
||||
"decompress": {
|
||||
"version": "4.2.0",
|
||||
"from": "decompress@>=4.2.0 <5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/decompress/-/decompress-4.2.0.tgz"
|
||||
},
|
||||
"decompress-tar": {
|
||||
"version": "4.1.1",
|
||||
"from": "decompress-tar@>=4.0.0 <5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/decompress-tar/-/decompress-tar-4.1.1.tgz"
|
||||
},
|
||||
"decompress-tarbz2": {
|
||||
"version": "4.1.1",
|
||||
"from": "decompress-tarbz2@>=4.0.0 <5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/decompress-tarbz2/-/decompress-tarbz2-4.1.1.tgz",
|
||||
"dependencies": {
|
||||
"file-type": {
|
||||
"version": "6.1.0",
|
||||
"from": "file-type@>=6.1.0 <7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/file-type/-/file-type-6.1.0.tgz"
|
||||
}
|
||||
}
|
||||
},
|
||||
"decompress-targz": {
|
||||
"version": "4.1.1",
|
||||
"from": "decompress-targz@>=4.0.0 <5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/decompress-targz/-/decompress-targz-4.1.1.tgz"
|
||||
},
|
||||
"decompress-unzip": {
|
||||
"version": "4.0.1",
|
||||
"from": "decompress-unzip@>=4.0.1 <5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/decompress-unzip/-/decompress-unzip-4.0.1.tgz",
|
||||
"dependencies": {
|
||||
"file-type": {
|
||||
"version": "3.9.0",
|
||||
"from": "file-type@>=3.8.0 <4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/file-type/-/file-type-3.9.0.tgz"
|
||||
}
|
||||
}
|
||||
},
|
||||
"end-of-stream": {
|
||||
"version": "1.4.0",
|
||||
"from": "end-of-stream@>=1.0.0 <2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.0.tgz"
|
||||
},
|
||||
"es6-promise": {
|
||||
"version": "4.1.1",
|
||||
"from": "es6-promise@>=4.0.3 <5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.1.1.tgz"
|
||||
},
|
||||
"es6-promisify": {
|
||||
"version": "5.0.0",
|
||||
"from": "es6-promisify@>=5.0.0 <6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz"
|
||||
},
|
||||
"extensions-modules": {
|
||||
"version": "0.1.0",
|
||||
"from": "..\\..\\extensions-modules",
|
||||
"resolved": "file:..\\..\\extensions-modules"
|
||||
},
|
||||
"fd-slicer": {
|
||||
"version": "1.0.1",
|
||||
"from": "fd-slicer@>=1.0.1 <1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz"
|
||||
},
|
||||
"file-type": {
|
||||
"version": "5.2.0",
|
||||
"from": "file-type@>=5.2.0 <6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/file-type/-/file-type-5.2.0.tgz"
|
||||
},
|
||||
"fs-extra": {
|
||||
"version": "2.1.2",
|
||||
"from": "fs-extra@>=2.1.2 <3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-2.1.2.tgz"
|
||||
},
|
||||
"fs-extra-promise": {
|
||||
"version": "1.0.1",
|
||||
"from": "fs-extra-promise@>=1.0.1 <2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra-promise/-/fs-extra-promise-1.0.1.tgz"
|
||||
},
|
||||
"get-stream": {
|
||||
"version": "2.3.1",
|
||||
"from": "get-stream@>=2.2.0 <3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz"
|
||||
},
|
||||
"graceful-fs": {
|
||||
"version": "4.1.11",
|
||||
"from": "graceful-fs@>=4.1.10 <5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz"
|
||||
},
|
||||
"graceful-readlink": {
|
||||
"version": "1.0.1",
|
||||
"from": "graceful-readlink@>=1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz"
|
||||
},
|
||||
"http-proxy-agent": {
|
||||
"version": "2.0.0",
|
||||
"from": "http-proxy-agent@>=2.0.0 <3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-2.0.0.tgz"
|
||||
},
|
||||
"https-proxy-agent": {
|
||||
"version": "2.1.0",
|
||||
"from": "https-proxy-agent@>=2.1.0 <3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.1.0.tgz"
|
||||
},
|
||||
"ieee754": {
|
||||
"version": "1.1.8",
|
||||
"from": "ieee754@>=1.1.4 <2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.8.tgz"
|
||||
},
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"from": "inherits@>=2.0.3 <2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz"
|
||||
},
|
||||
"is-natural-number": {
|
||||
"version": "4.0.1",
|
||||
"from": "is-natural-number@>=4.0.1 <5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-natural-number/-/is-natural-number-4.0.1.tgz"
|
||||
},
|
||||
"is-stream": {
|
||||
"version": "1.1.0",
|
||||
"from": "is-stream@>=1.1.0 <2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz"
|
||||
},
|
||||
"isarray": {
|
||||
"version": "1.0.0",
|
||||
"from": "isarray@>=1.0.0 <1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz"
|
||||
},
|
||||
"jsonfile": {
|
||||
"version": "2.4.0",
|
||||
"from": "jsonfile@>=2.1.0 <3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz"
|
||||
},
|
||||
"make-dir": {
|
||||
"version": "1.0.0",
|
||||
"from": "make-dir@>=1.0.0 <2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.0.0.tgz"
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.0.0",
|
||||
"from": "ms@2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz"
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
"from": "object-assign@>=4.0.1 <5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz"
|
||||
},
|
||||
"once": {
|
||||
"version": "1.4.0",
|
||||
"from": "once@>=1.4.0 <2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz"
|
||||
},
|
||||
"opener": {
|
||||
"version": "1.4.3",
|
||||
"from": "opener@>=1.4.3 <2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/opener/-/opener-1.4.3.tgz"
|
||||
},
|
||||
"os-tmpdir": {
|
||||
"version": "1.0.2",
|
||||
"from": "os-tmpdir@>=1.0.2 <1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz"
|
||||
},
|
||||
"pend": {
|
||||
"version": "1.2.0",
|
||||
"from": "pend@>=1.2.0 <1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz"
|
||||
},
|
||||
"pify": {
|
||||
"version": "2.3.0",
|
||||
"from": "pify@>=2.3.0 <3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz"
|
||||
},
|
||||
"pinkie": {
|
||||
"version": "2.0.4",
|
||||
"from": "pinkie@>=2.0.0 <3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz"
|
||||
},
|
||||
"pinkie-promise": {
|
||||
"version": "2.0.1",
|
||||
"from": "pinkie-promise@>=2.0.0 <3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz"
|
||||
},
|
||||
"process-nextick-args": {
|
||||
"version": "1.0.7",
|
||||
"from": "process-nextick-args@>=1.0.6 <1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz"
|
||||
},
|
||||
"readable-stream": {
|
||||
"version": "2.3.3",
|
||||
"from": "readable-stream@>=2.0.0 <3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz"
|
||||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.1.1",
|
||||
"from": "safe-buffer@>=5.1.1 <5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz"
|
||||
},
|
||||
"seek-bzip": {
|
||||
"version": "1.0.5",
|
||||
"from": "seek-bzip@>=1.0.5 <2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/seek-bzip/-/seek-bzip-1.0.5.tgz"
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.0.3",
|
||||
"from": "string_decoder@>=1.0.3 <1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz"
|
||||
},
|
||||
"strip-dirs": {
|
||||
"version": "2.0.0",
|
||||
"from": "strip-dirs@>=2.0.0 <3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-dirs/-/strip-dirs-2.0.0.tgz"
|
||||
},
|
||||
"tar-stream": {
|
||||
"version": "1.5.4",
|
||||
"from": "tar-stream@>=1.5.2 <2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-1.5.4.tgz"
|
||||
},
|
||||
"through": {
|
||||
"version": "2.3.8",
|
||||
"from": "through@>=2.3.6 <3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz"
|
||||
},
|
||||
"tmp": {
|
||||
"version": "0.0.33",
|
||||
"from": "tmp@0.0.33",
|
||||
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz"
|
||||
},
|
||||
"unbzip2-stream": {
|
||||
"version": "1.2.5",
|
||||
"from": "unbzip2-stream@>=1.0.9 <2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.2.5.tgz"
|
||||
},
|
||||
"util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
"from": "util-deprecate@>=1.0.1 <1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz"
|
||||
},
|
||||
"vscode-extension-telemetry": {
|
||||
"version": "0.0.8",
|
||||
"from": "vscode-extension-telemetry@0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/vscode-extension-telemetry/-/vscode-extension-telemetry-0.0.8.tgz"
|
||||
},
|
||||
"winreg": {
|
||||
"version": "1.2.3",
|
||||
"from": "winreg@1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/winreg/-/winreg-1.2.3.tgz"
|
||||
},
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"from": "wrappy@>=1.0.0 <2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz"
|
||||
},
|
||||
"xtend": {
|
||||
"version": "4.0.1",
|
||||
"from": "xtend@>=4.0.0 <5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz"
|
||||
},
|
||||
"yauzl": {
|
||||
"version": "2.8.0",
|
||||
"from": "yauzl@>=2.4.2 <3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.8.0.tgz"
|
||||
}
|
||||
}
|
||||
}
|
||||
113
extensions/mssql/package.json
Normal file
113
extensions/mssql/package.json
Normal file
@@ -0,0 +1,113 @@
|
||||
{
|
||||
"name": "mssql",
|
||||
"version": "0.1.0",
|
||||
"publisher": "Microsoft",
|
||||
"aiKey": "AIF-5574968e-856d-40d2-af67-c89a14e76412",
|
||||
"engines": {
|
||||
"vscode": "0.10.x"
|
||||
},
|
||||
"activationEvents": [
|
||||
"*"
|
||||
],
|
||||
"main": "./client/out/mssqlMain",
|
||||
"extensionDependencies": [
|
||||
"vscode.sql"
|
||||
],
|
||||
"scripts": {
|
||||
"compile": "gulp compile-extension:mssql-client",
|
||||
"postinstall": "node ./node_modules/vscode/bin/install"
|
||||
},
|
||||
"contributes": {
|
||||
"languages": [
|
||||
{
|
||||
"id": "sql",
|
||||
"extensions": [
|
||||
".sql"
|
||||
],
|
||||
"aliases": [
|
||||
"SQL"
|
||||
],
|
||||
"configuration": "./syntaxes/sql.configuration.json"
|
||||
}
|
||||
],
|
||||
"grammars": [
|
||||
{
|
||||
"language": "sql",
|
||||
"scopeName": "source.sql",
|
||||
"path": "./syntaxes/SQL.plist"
|
||||
}
|
||||
],
|
||||
"outputChannels": [
|
||||
"MSSQL"
|
||||
],
|
||||
"snippets": [
|
||||
{
|
||||
"language": "sql",
|
||||
"path": "./snippets/mssql.json"
|
||||
}
|
||||
],
|
||||
"configuration": {
|
||||
"type": "object",
|
||||
"title": "MSSQL configuration",
|
||||
"properties": {
|
||||
"mssql.query.displayBitAsNumber": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Should BIT columns be displayed as numbers (1 or 0)? If false, BIT columns will be displayed as 'true' or 'false'"
|
||||
},
|
||||
"mssql.format.alignColumnDefinitionsInColumns": {
|
||||
"type": "boolean",
|
||||
"description": "Should column definitions be aligned?",
|
||||
"default": false
|
||||
},
|
||||
"mssql.format.datatypeCasing": {
|
||||
"type": "string",
|
||||
"description": "Should data types be formatted as UPPERCASE, lowercase, or none (not formatted)",
|
||||
"default": "none",
|
||||
"enum": [
|
||||
"none",
|
||||
"uppercase",
|
||||
"lowercase"
|
||||
]
|
||||
},
|
||||
"mssql.format.keywordCasing": {
|
||||
"type": "string",
|
||||
"description": "Should keywords be formatted as UPPERCASE, lowercase, or none (not formatted)",
|
||||
"default": "none",
|
||||
"enum": [
|
||||
"none",
|
||||
"uppercase",
|
||||
"lowercase"
|
||||
]
|
||||
},
|
||||
"mssql.format.placeCommasBeforeNextStatement": {
|
||||
"type": "boolean",
|
||||
"description": "should commas be placed at the beginning of each statement in a list e.g. ', mycolumn2' instead of at the end e.g. 'mycolumn1,'",
|
||||
"default": false
|
||||
},
|
||||
"mssql.format.placeSelectStatementReferencesOnNewLine": {
|
||||
"type": "boolean",
|
||||
"description": "Should references to objects in a select statements be split into separate lines? E.g. for 'SELECT C1, C2 FROM T1' both C1 and C2 will be on separate lines",
|
||||
"default": false
|
||||
},
|
||||
"mssql.logDebugInfo": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "[Optional] Log debug output to the VS Code console (Help -> Toggle Developer Tools)"
|
||||
},
|
||||
"ignorePlatformWarning": {
|
||||
"type": "boolean",
|
||||
"description": "[Optional] Do not show unsupported platform warnings",
|
||||
"default": false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"dataprotocol-client": "file:../../dataprotocol-node/client",
|
||||
"extensions-modules": "file:../../extensions-modules"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vscode": "1.0.1"
|
||||
}
|
||||
}
|
||||
8
extensions/mssql/package.nls.json
Normal file
8
extensions/mssql/package.nls.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"json.schemas.desc": "Associate schemas to JSON files in the current project",
|
||||
"json.schemas.url.desc": "A URL to a schema or a relative path to a schema in the current directory",
|
||||
"json.schemas.fileMatch.desc": "An array of file patterns to match against when resolving JSON files to schemas.",
|
||||
"json.schemas.fileMatch.item.desc": "A file pattern that can contain '*' to match against when resolving JSON files to schemas.",
|
||||
"json.schemas.schema.desc": "The schema definition for the given URL. The schema only needs to be provided to avoid accesses to the schema URL.",
|
||||
"json.format.enable.desc": "Enable/disable default JSON formatter (requires restart)"
|
||||
}
|
||||
298
extensions/mssql/snippets/mssql.json
Normal file
298
extensions/mssql/snippets/mssql.json
Normal file
@@ -0,0 +1,298 @@
|
||||
{
|
||||
"Get extension help": {
|
||||
"prefix": "sqlExtensionHelp",
|
||||
"body": [
|
||||
"/*",
|
||||
"mssql getting started:",
|
||||
"-----------------------------",
|
||||
"1. Change language mode to SQL: Open a .sql file or press Ctrl+K M (Cmd+K M on Mac) and choose 'SQL'.",
|
||||
"2. Connect to a database: Press F1 to show the command palette, type 'sqlcon' or 'sql' then click 'Connect'.",
|
||||
"3. Use the T-SQL editor: Type T-SQL statements in the editor using T-SQL IntelliSense or type 'sql' to see a list of code snippets you can tweak & reuse.",
|
||||
"4. Run T-SQL statements: Press F1 and type 'sqlex' or press Ctrl+Shift+e (Cmd+Shift+e on Mac) to execute all the T-SQL code in the editor.",
|
||||
"",
|
||||
"Tip #1: Put GO on a line by itself to separate T-SQL batches.",
|
||||
"Tip #2: Select some T-SQL text in the editor and press `Ctrl+Shift+e` (`Cmd+Shift+e` on Mac) to execute the selection",
|
||||
"*/"
|
||||
],
|
||||
"description": "Get extension help"
|
||||
},
|
||||
|
||||
"Create a new Database": {
|
||||
"prefix": "sqlCreateDatabase",
|
||||
"body": [
|
||||
"-- Create a new database called '${1:DatabaseName}'",
|
||||
"-- Connect to the 'master' database to run this snippet",
|
||||
"USE master",
|
||||
"GO",
|
||||
"-- Create the new database if it does not exist already",
|
||||
"IF NOT EXISTS (",
|
||||
"\tSELECT name",
|
||||
"\t\tFROM sys.databases",
|
||||
"\t\tWHERE name = N'${1:DatabaseName}'",
|
||||
")",
|
||||
"CREATE DATABASE ${1:DatabaseName}",
|
||||
"GO"
|
||||
],
|
||||
"description": "Create a new Database"
|
||||
},
|
||||
|
||||
"Drop a Database": {
|
||||
"prefix": "sqlDropDatabase",
|
||||
"body": [
|
||||
"-- Drop the database '${1:DatabaseName}'",
|
||||
"-- Connect to the 'master' database to run this snippet",
|
||||
"USE master",
|
||||
"GO",
|
||||
"-- Uncomment the ALTER DATABASE statement below to set the database to SINGLE_USER mode if the drop database command fails because the database is in use.",
|
||||
"-- ALTER DATABASE ${1:DatabaseName} SET SINGLE_USER WITH ROLLBACK IMMEDIATE;",
|
||||
"-- Drop the database if it exists",
|
||||
"IF EXISTS (",
|
||||
" SELECT name",
|
||||
" FROM sys.databases",
|
||||
" WHERE name = N'${1:DatabaseName}'",
|
||||
")",
|
||||
"DROP DATABASE ${1:DatabaseName}",
|
||||
"GO"
|
||||
],
|
||||
"description": "Drop a Database"
|
||||
},
|
||||
|
||||
"Create a new Table": {
|
||||
"prefix": "sqlCreateTable",
|
||||
"body": [
|
||||
"-- Create a new table called '${1:TableName}' in schema '${2:SchemaName}'",
|
||||
"-- Drop the table if it already exists",
|
||||
"IF OBJECT_ID('${2:SchemaName}.${1:TableName}', 'U') IS NOT NULL",
|
||||
"DROP TABLE ${2:SchemaName}.${1:TableName}",
|
||||
"GO",
|
||||
"-- Create the table in the specified schema",
|
||||
"CREATE TABLE ${2:SchemaName}.${1:TableName}",
|
||||
"(",
|
||||
"\t${1:TableName}Id INT NOT NULL PRIMARY KEY, -- primary key column",
|
||||
"\t$3Column1 [NVARCHAR](50) NOT NULL,",
|
||||
"\t$4Column2 [NVARCHAR](50) NOT NULL",
|
||||
"\t-- specify more columns here",
|
||||
");",
|
||||
"GO"
|
||||
],
|
||||
"description": "Create a new Table"
|
||||
},
|
||||
|
||||
"Drop a Table": {
|
||||
"prefix": "sqlDropTable",
|
||||
"body": [
|
||||
"-- Drop the table '${1:TableName}' in schema '${2:SchemaName}'",
|
||||
"IF EXISTS (",
|
||||
"\tSELECT *",
|
||||
"\t\tFROM sys.tables",
|
||||
"\t\tJOIN sys.schemas",
|
||||
"\t\t\tON sys.tables.schema_id = sys.schemas.schema_id",
|
||||
"\tWHERE sys.schemas.name = N'${2:SchemaName}'",
|
||||
"\t\tAND sys.tables.name = N'${1:TableName}'",
|
||||
")",
|
||||
"\tDROP TABLE ${2:SchemaName}.${1:TableName}",
|
||||
"GO"
|
||||
],
|
||||
"description": "Drop a Table"
|
||||
},
|
||||
|
||||
"Add a new column to a Table": {
|
||||
"prefix": "sqlAddColumn",
|
||||
"body": [
|
||||
"-- Add a new column '${1:NewColumnName}' to table '${2:TableName}' in schema '${3:SchemaName}'",
|
||||
"ALTER TABLE ${3:SchemaName}.${2:TableName}",
|
||||
"\tADD ${1:NewColumnName} /*new_column_name*/ int /*new_column_datatype*/ NULL /*new_column_nullability*/",
|
||||
"GO"
|
||||
],
|
||||
"description": "Add a new column to a Table"
|
||||
},
|
||||
|
||||
"Drop a column from a Table": {
|
||||
"prefix": "sqlDropColumn",
|
||||
"body": [
|
||||
"-- Drop '${1:ColumnName}' from table '${2:TableName}' in schema '${3:SchemaName}'",
|
||||
"ALTER TABLE ${3:SchemaName}.${2:TableName}",
|
||||
"\tDROP COLUMN ${1:ColumnName}",
|
||||
"GO"
|
||||
],
|
||||
"description": "Add a new column to a Table"
|
||||
},
|
||||
|
||||
"Select rows from a Table or a View": {
|
||||
"prefix": "sqlSelect",
|
||||
"body": [
|
||||
"-- Select rows from a Table or View '${1:TableOrViewName}' in schema '${2:SchemaName}'",
|
||||
"SELECT * FROM ${2:SchemaName}.${1:TableOrViewName}",
|
||||
"WHERE $3\t/* add search conditions here */",
|
||||
"GO"
|
||||
],
|
||||
"description": "Select rows from a Table or a View"
|
||||
},
|
||||
|
||||
"Insert rows into a Table": {
|
||||
"prefix": "sqlInsertRows",
|
||||
"body": [
|
||||
"-- Insert rows into table '${1:TableName}'",
|
||||
"INSERT INTO ${1:TableName}",
|
||||
"( -- columns to insert data into",
|
||||
" $2[Column1], [Column2], [Column3]",
|
||||
")",
|
||||
"VALUES",
|
||||
"( -- first row: values for the columns in the list above",
|
||||
" $3Column1_Value, Column2_Value, Column3_Value",
|
||||
"),",
|
||||
"( -- second row: values for the columns in the list above",
|
||||
" $4Column1_Value, Column2_Value, Column3_Value",
|
||||
")",
|
||||
"-- add more rows here",
|
||||
"GO"
|
||||
],
|
||||
"description": "Insert rows into a Table"
|
||||
},
|
||||
|
||||
"Delete rows from a Table": {
|
||||
"prefix": "sqlDeleteRows",
|
||||
"body": [
|
||||
"-- Delete rows from table '${1:TableName}'",
|
||||
"DELETE FROM ${1:TableName}",
|
||||
"WHERE $2\t/* add search conditions here */",
|
||||
"GO"
|
||||
],
|
||||
"description": "Delete rows from a Table"
|
||||
},
|
||||
|
||||
"Update rows in a Table": {
|
||||
"prefix": "sqlUpdateRows",
|
||||
"body": [
|
||||
"-- Update rows in table '${1:TableName}'",
|
||||
"UPDATE ${1:TableName}",
|
||||
"SET",
|
||||
"\t$2[Colum1] = Colum1_Value,",
|
||||
"\t$3[Colum2] = Colum2_Value",
|
||||
"\t-- add more columns and values here",
|
||||
"WHERE $4\t/* add search conditions here */",
|
||||
"GO"
|
||||
],
|
||||
"description": "Update rows in a Table"
|
||||
},
|
||||
|
||||
"Create a stored procedure": {
|
||||
"prefix": "sqlCreateStoredProc",
|
||||
"body": [
|
||||
"-- Create a new stored procedure called '${1:StoredProcedureName}' in schema '${2:SchemaName}'",
|
||||
"-- Drop the stored procedure if it already exists",
|
||||
"IF EXISTS (",
|
||||
"SELECT *",
|
||||
"\tFROM INFORMATION_SCHEMA.ROUTINES",
|
||||
"WHERE SPECIFIC_SCHEMA = N'${2:SchemaName}'",
|
||||
"\tAND SPECIFIC_NAME = N'${1:StoredProcedureName}'",
|
||||
")",
|
||||
"DROP PROCEDURE ${2:SchemaName}.${1:StoredProcedureName}",
|
||||
"GO",
|
||||
"-- Create the stored procedure in the specified schema",
|
||||
"CREATE PROCEDURE ${2:SchemaName}.${1:StoredProcedureName}",
|
||||
"\t$3@param1 /*parameter name*/ int /*datatype_for_param1*/ = 0, /*default_value_for_param1*/",
|
||||
"\t$4@param2 /*parameter name*/ int /*datatype_for_param1*/ = 0 /*default_value_for_param2*/",
|
||||
"-- add more stored procedure parameters here",
|
||||
"AS",
|
||||
"\t-- body of the stored procedure",
|
||||
"\tSELECT @param1, @param2",
|
||||
"GO",
|
||||
"-- example to execute the stored procedure we just created",
|
||||
"EXECUTE ${2:SchemaName}.${1:StoredProcedureName} 1 /*value_for_param1*/, 2 /*value_for_param2*/",
|
||||
"GO"
|
||||
],
|
||||
"description": "Create a stored procedure"
|
||||
},
|
||||
|
||||
"Drop a stored procedure": {
|
||||
"prefix": "sqlDropStoredProc",
|
||||
"body": [
|
||||
"-- Drop the stored procedure called '${1:StoredProcedureName}' in schema '${2:SchemaName}'",
|
||||
"IF EXISTS (",
|
||||
"SELECT *",
|
||||
"\tFROM INFORMATION_SCHEMA.ROUTINES",
|
||||
"WHERE SPECIFIC_SCHEMA = N'${2:SchemaName}'",
|
||||
"\tAND SPECIFIC_NAME = N'${1:StoredProcedureName}'",
|
||||
")",
|
||||
"DROP PROCEDURE ${2:SchemaName}.${1:StoredProcedureName}",
|
||||
"GO"
|
||||
],
|
||||
"description": "Drop a stored procedure"
|
||||
},
|
||||
|
||||
"List tables": {
|
||||
"prefix": "sqlListTablesAndViews",
|
||||
"body": [
|
||||
"-- Get a list of tables and views in the current database",
|
||||
"SELECT table_catalog [database], table_schema [schema], table_name name, table_type type",
|
||||
"FROM information_schema.tables",
|
||||
"GO"
|
||||
],
|
||||
"description": "List tables and vies in the current database"
|
||||
},
|
||||
|
||||
"List databases": {
|
||||
"prefix": "sqlListDatabases",
|
||||
"body": [
|
||||
"-- Get a list of databases",
|
||||
"SELECT name FROM sys.databases",
|
||||
"GO"
|
||||
],
|
||||
"description": "List databases"
|
||||
},
|
||||
|
||||
"List columns": {
|
||||
"prefix": "sqlListColumns",
|
||||
"body": [
|
||||
"-- List columns in all tables whose name is like '${1:TableName}'",
|
||||
"SELECT ",
|
||||
"\tTableName = tbl.table_schema + '.' + tbl.table_name, ",
|
||||
"\tColumnName = col.column_name, ",
|
||||
"\tColumnDataType = col.data_type",
|
||||
"FROM information_schema.tables tbl",
|
||||
"INNER JOIN information_schema.columns col ",
|
||||
"\tON col.table_name = tbl.table_name",
|
||||
"\tAND col.table_schema = tbl.table_schema",
|
||||
"",
|
||||
"WHERE tbl.table_type = 'base table' and tbl.table_name like '%${1:TableName}%'",
|
||||
"GO"
|
||||
],
|
||||
"description": "Lists all the columns and their types for tables matching a LIKE statement"
|
||||
},
|
||||
|
||||
"Show space used by tables": {
|
||||
"prefix": "sqlGetSpaceUsed",
|
||||
"body": [
|
||||
"-- Get the space used by table ${1:TableName}",
|
||||
"SELECT TABL.name AS table_name,",
|
||||
"INDX.name AS index_name,",
|
||||
"SUM(PART.rows) AS rows_count,",
|
||||
"SUM(ALOC.total_pages) AS total_pages,",
|
||||
"SUM(ALOC.used_pages) AS used_pages,",
|
||||
"SUM(ALOC.data_pages) AS data_pages,",
|
||||
"(SUM(ALOC.total_pages)*8/1024) AS total_space_MB,",
|
||||
"(SUM(ALOC.used_pages)*8/1024) AS used_space_MB,",
|
||||
"(SUM(ALOC.data_pages)*8/1024) AS data_space_MB",
|
||||
"FROM sys.Tables AS TABL",
|
||||
"INNER JOIN sys.Indexes AS INDX",
|
||||
"ON TABL.object_id = INDX.object_id",
|
||||
"INNER JOIN sys.Partitions AS PART",
|
||||
"ON INDX.object_id = PART.object_id",
|
||||
"AND INDX.index_id = PART.index_id",
|
||||
"INNER JOIN sys.Allocation_Units AS ALOC",
|
||||
"ON PART.partition_id = ALOC.container_id",
|
||||
"WHERE TABL.name LIKE '%${1:TableName}%'",
|
||||
"AND INDX.object_id > 255",
|
||||
"AND INDX.index_id <= 1",
|
||||
"GROUP BY TABL.name, ",
|
||||
"INDX.object_id,",
|
||||
"INDX.index_id,",
|
||||
"INDX.name",
|
||||
"ORDER BY Object_Name(INDX.object_id),",
|
||||
"(SUM(ALOC.total_pages)*8/1024) DESC",
|
||||
"GO"
|
||||
],
|
||||
"description": "Get Space Used by Tables"
|
||||
}
|
||||
}
|
||||
771
extensions/mssql/syntaxes/SQL.plist
Normal file
771
extensions/mssql/syntaxes/SQL.plist
Normal file
File diff suppressed because one or more lines are too long
3
extensions/mssql/syntaxes/sql.configuration.json
Normal file
3
extensions/mssql/syntaxes/sql.configuration.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user