mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Preserve name and group when using Connection String (#22341)
This commit is contained in:
@@ -20,6 +20,7 @@ import { IAccountManagementService } from 'sql/platform/accounts/common/interfac
|
|||||||
|
|
||||||
import * as azdata from 'azdata';
|
import * as azdata from 'azdata';
|
||||||
|
|
||||||
|
import * as utils from 'vs/base/common/errors';
|
||||||
import * as lifecycle from 'vs/base/common/lifecycle';
|
import * as lifecycle from 'vs/base/common/lifecycle';
|
||||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||||
import { localize } from 'vs/nls';
|
import { localize } from 'vs/nls';
|
||||||
@@ -1194,12 +1195,17 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
|||||||
let validInputs = this.validateInputs();
|
let validInputs = this.validateInputs();
|
||||||
if (validInputs) {
|
if (validInputs) {
|
||||||
if (this.useConnectionString) {
|
if (this.useConnectionString) {
|
||||||
|
try {
|
||||||
const connInfo = await this._connectionManagementService.buildConnectionInfo(this.connectionString, this._providerName);
|
const connInfo = await this._connectionManagementService.buildConnectionInfo(this.connectionString, this._providerName);
|
||||||
if (connInfo) {
|
if (!connInfo) {
|
||||||
|
throw Error(localize('connectionWidget.ConnectionStringUndefined', 'No connection info returned.'));
|
||||||
|
}
|
||||||
model.options = connInfo.options;
|
model.options = connInfo.options;
|
||||||
model.savePassword = true;
|
model.savePassword = true;
|
||||||
} else {
|
} catch (err) {
|
||||||
this._errorMessageService.showDialog(Severity.Error, localize('connectionWidget.Error', "Error"), localize('connectionWidget.ConnectionStringError', "Failed to parse the connection string."));
|
this._logService.error(`${this._providerName} Failed to parse the connection string : ${err}`)
|
||||||
|
this._errorMessageService.showDialog(Severity.Error, localize('connectionWidget.Error', "Error"),
|
||||||
|
localize('connectionWidget.ConnectionStringError', "Failed to parse the connection string. {0}", utils.getErrorMessage(err)), err.stack);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1209,13 +1215,14 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
|||||||
model.authenticationType = this.authenticationType;
|
model.authenticationType = this.authenticationType;
|
||||||
model.azureAccount = this.authToken;
|
model.azureAccount = this.authToken;
|
||||||
model.savePassword = this._rememberPasswordCheckBox.checked;
|
model.savePassword = this._rememberPasswordCheckBox.checked;
|
||||||
model.connectionName = this.connectionName;
|
|
||||||
model.databaseName = this.databaseName;
|
model.databaseName = this.databaseName;
|
||||||
if (this._customOptionWidgets) {
|
if (this._customOptionWidgets) {
|
||||||
this._customOptionWidgets.forEach((widget, i) => {
|
this._customOptionWidgets.forEach((widget, i) => {
|
||||||
model.options[this._customOptions[i].name] = widget.value;
|
model.options[this._customOptions[i].name] = widget.value;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
model.connectionName = this.connectionName;
|
||||||
if (this._serverGroupSelectBox) {
|
if (this._serverGroupSelectBox) {
|
||||||
if (this._serverGroupSelectBox.value === this.DefaultServerGroup.name) {
|
if (this._serverGroupSelectBox.value === this.DefaultServerGroup.name) {
|
||||||
model.groupFullName = '';
|
model.groupFullName = '';
|
||||||
@@ -1231,7 +1238,6 @@ export class ConnectionWidget extends lifecycle.Disposable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return validInputs;
|
return validInputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user