diff --git a/src/sql/parts/commandLine/common/commandLineService.ts b/src/sql/parts/commandLine/common/commandLineService.ts index e9d9c53935..945f88bf08 100644 --- a/src/sql/parts/commandLine/common/commandLineService.ts +++ b/src/sql/parts/commandLine/common/commandLineService.ts @@ -63,7 +63,7 @@ export class CommandLineService implements ICommandLineProcessing { // prompt the user for a new connection on startup if no profiles are registered this._connectionManagementService.showConnectionDialog(); } else if (this._connectionProfile) { - this._connectionManagementService.connectIfNotConnected(this._connectionProfile, 'connection') + this._connectionManagementService.connectIfNotConnected(this._connectionProfile, 'connection', true) .then(result => TaskUtilities.newQuery(this._connectionProfile, this._connectionManagementService, this._queryEditorService, diff --git a/src/sql/parts/connection/common/connectionManagement.ts b/src/sql/parts/connection/common/connectionManagement.ts index 35339f1932..cb0f08f630 100644 --- a/src/sql/parts/connection/common/connectionManagement.ts +++ b/src/sql/parts/connection/common/connectionManagement.ts @@ -121,7 +121,7 @@ export interface IConnectionManagementService { * otherwise tries to make a connection and returns the owner uri when connection is complete * The purpose is connection by default */ - connectIfNotConnected(connection: IConnectionProfile, purpose?: 'dashboard' | 'insights' | 'connection'): Promise; + connectIfNotConnected(connection: IConnectionProfile, purpose?: 'dashboard' | 'insights' | 'connection', saveConnection?: boolean): Promise; /** * Adds the successful connection to MRU and send the connection error back to the connection handler for failed connections diff --git a/src/sql/parts/connection/common/connectionManagementService.ts b/src/sql/parts/connection/common/connectionManagementService.ts index a293d91f23..f2d4e77155 100644 --- a/src/sql/parts/connection/common/connectionManagementService.ts +++ b/src/sql/parts/connection/common/connectionManagementService.ts @@ -380,14 +380,14 @@ export class ConnectionManagementService extends Disposable implements IConnecti * otherwise tries to make a connection and returns the owner uri when connection is complete * The purpose is connection by default */ - public connectIfNotConnected(connection: IConnectionProfile, purpose?: 'dashboard' | 'insights' | 'connection'): Promise { + public connectIfNotConnected(connection: IConnectionProfile, purpose?: 'dashboard' | 'insights' | 'connection', saveConnection: boolean = false): Promise { return new Promise((resolve, reject) => { let ownerUri: string = Utils.generateUri(connection, purpose); if (this._connectionStatusManager.isConnected(ownerUri)) { resolve(this._connectionStatusManager.getOriginalOwnerUri(ownerUri)); } else { const options: IConnectionCompletionOptions = { - saveTheConnection: false, + saveTheConnection: saveConnection, showConnectionDialogOnError: true, showDashboard: purpose === 'dashboard', params: undefined, diff --git a/src/sqltest/parts/commandLine/commandLineService.test.ts b/src/sqltest/parts/commandLine/commandLineService.test.ts index f00d529cc9..c3e9a9780b 100644 --- a/src/sqltest/parts/commandLine/commandLineService.test.ts +++ b/src/sqltest/parts/commandLine/commandLineService.test.ts @@ -164,7 +164,7 @@ suite('commandLineService tests', () => { environmentService.setup(e => e.args).returns(() => args).verifiable(TypeMoq.Times.atLeastOnce()); connectionManagementService.setup((c) => c.showConnectionDialog()).verifiable(TypeMoq.Times.never()); connectionManagementService.setup(c => c.hasRegisteredServers()).returns(() => true).verifiable(TypeMoq.Times.atMostOnce()); - connectionManagementService.setup(c => c.connectIfNotConnected(TypeMoq.It.isAny(), 'connection')) + connectionManagementService.setup(c => c.connectIfNotConnected(TypeMoq.It.isAny(), 'connection', true)) .returns(() => new Promise((resolve, reject) => { reject('unused');})) .verifiable(TypeMoq.Times.once()); let service = getCommandLineService(connectionManagementService.object, environmentService.object, capabilitiesService); diff --git a/src/sqltest/stubs/connectionManagementService.test.ts b/src/sqltest/stubs/connectionManagementService.test.ts index f894b2930e..2e38571b21 100644 --- a/src/sqltest/stubs/connectionManagementService.test.ts +++ b/src/sqltest/stubs/connectionManagementService.test.ts @@ -234,7 +234,7 @@ export class TestConnectionManagementService implements IConnectionManagementSer return []; } - connectIfNotConnected(connection: IConnectionProfile, purpose?: 'dashboard' | 'insights' | 'connection'): Promise { + connectIfNotConnected(connection: IConnectionProfile, purpose?: 'dashboard' | 'insights' | 'connection', saveConnection: boolean = false): Promise { return undefined; }