mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-30 01:25:38 -05:00
Refactor vscode-mssql sql bindings logic to sql bindings ext (#18725)
* wip for refactor of mssql to sql-bindings * remove STS dependency * work to bring function over and setup with vscodeMsql APIs * copy typings from vscode-mssql
This commit is contained in:
@@ -3,12 +3,35 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as vscode from 'vscode';
|
||||
import { getAzdataApi } from './common/utils';
|
||||
import { ITreeNodeInfo } from 'vscode-mssql';
|
||||
import { getAzdataApi, getVscodeMssqlApi } from './common/utils';
|
||||
import { launchAddSqlBindingQuickpick } from './dialogs/addSqlBindingQuickpick';
|
||||
import { createAzureFunction } from './services/azureFunctionsService';
|
||||
|
||||
export async function activate(context: vscode.ExtensionContext): Promise<void> {
|
||||
const vscodeMssqlApi = await getVscodeMssqlApi();
|
||||
|
||||
export function activate(context: vscode.ExtensionContext): void {
|
||||
void vscode.commands.executeCommand('setContext', 'azdataAvailable', !!getAzdataApi());
|
||||
// register the add sql binding command
|
||||
context.subscriptions.push(vscode.commands.registerCommand('sqlBindings.addSqlBinding', async (uri: vscode.Uri | undefined) => { return launchAddSqlBindingQuickpick(uri); }));
|
||||
// Generate Azure Function command
|
||||
context.subscriptions.push(vscode.commands.registerCommand('sqlBindings.createAzureFunction', async (node: ITreeNodeInfo) => {
|
||||
let connectionInfo = node.connectionInfo;
|
||||
// set the database containing the selected table so it can be used
|
||||
// for the initial catalog property of the connection string
|
||||
let newNode: ITreeNodeInfo = node;
|
||||
while (newNode) {
|
||||
if (newNode.nodeType === 'Database') {
|
||||
connectionInfo.database = newNode.metadata.name;
|
||||
break;
|
||||
} else {
|
||||
newNode = newNode.parentNode;
|
||||
}
|
||||
}
|
||||
const connectionDetails = vscodeMssqlApi.createConnectionDetails(connectionInfo);
|
||||
const connectionString = await vscodeMssqlApi.getConnectionString(connectionDetails, false, false);
|
||||
await createAzureFunction(connectionString, node.metadata.schema, node.metadata.name);
|
||||
}));
|
||||
}
|
||||
|
||||
export function deactivate(): void {
|
||||
|
||||
Reference in New Issue
Block a user