Fix connection when changing kernel from Kusto to SQL (#12881)

* Fix Kusto to SQL kernel connection change

* Updated Fix - removes kernel alias mapping while ensuring multi kusto notebooks work properly

* Fix tests
This commit is contained in:
Vasu Bhog
2020-10-10 00:10:33 -05:00
committed by GitHub
parent 0f6bb683d6
commit 53f00bee12

View File

@@ -845,6 +845,15 @@ export class NotebookModel extends Disposable implements INotebookModel {
if (newConnection) {
if (newConnection.serverCapabilities?.notebookKernelAlias) {
this._currentKernelAlias = newConnection.serverCapabilities.notebookKernelAlias;
// Removes SQL kernel to Kernel Alias Connection Provider map
let sqlConnectionProvider = this._kernelDisplayNameToConnectionProviderIds.get('SQL');
if (sqlConnectionProvider) {
let index = sqlConnectionProvider.indexOf(newConnection.serverCapabilities.notebookKernelAlias.toUpperCase());
if (index > -1) {
sqlConnectionProvider.splice(index, 1);
}
this._kernelDisplayNameToConnectionProviderIds.set('SQL', sqlConnectionProvider);
}
this._kernelDisplayNameToConnectionProviderIds.set(newConnection.serverCapabilities.notebookKernelAlias, [newConnection.providerName]);
}
this._activeConnection = newConnection;
@@ -971,6 +980,9 @@ export class NotebookModel extends Disposable implements INotebookModel {
private async loadActiveContexts(kernelChangedArgs: nb.IKernelChangedArgs): Promise<void> {
if (kernelChangedArgs && kernelChangedArgs.newValue && kernelChangedArgs.newValue.name) {
let kernelDisplayName = this.getDisplayNameFromSpecName(kernelChangedArgs.newValue);
if (this.context?.serverCapabilities?.notebookKernelAlias && this.selectedKernelDisplayName === this.context?.serverCapabilities?.notebookKernelAlias) {
kernelDisplayName = this.context.serverCapabilities?.notebookKernelAlias;
}
let context;
if (this._activeConnection) {
context = NotebookContexts.getContextForKernel(this._activeConnection, this.getApplicableConnectionProviderIds(kernelDisplayName));