Skip to content

Commit

Permalink
Fixes issue where wrong property was checked for deployment type (mic…
Browse files Browse the repository at this point in the history
…rosoft#10933)

* Fixes issue where wrong property was checked for deployment type

* improve error message
  • Loading branch information
Benjin authored Jun 16, 2020
1 parent f02e2a4 commit 0f9f9c8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 31 deletions.
1 change: 1 addition & 0 deletions extensions/sql-database-projects/src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export const databaseNameRequired = localize('databaseNameRequired', "Database n
export const invalidDataSchemaProvider = localize('invalidDataSchemaProvider', "Invalid DSP in .sqlproj file");
export const invalidDatabaseReference = localize('invalidDatabaseReference', "Invalid database reference in .sqlproj file");
export const databaseSelectionRequired = localize('databaseSelectionRequired', "Database selection is required to import a project");
export const unableToCreateDeploymentConnection = localize('unableToCreateDeploymentConnection', "Unable to construct connection");
export function projectAlreadyOpened(path: string) { return localize('projectAlreadyOpened', "Project '{0}' is already opened.", path); }
export function projectAlreadyExists(name: string, path: string) { return localize('projectAlreadyExists', "A project named {0} already exists in {1}.", name, path); }
export function noFileExist(fileName: string) { return localize('noFileExist', "File {0} doesn't exist", fileName); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import * as azdata from 'azdata';
import * as vscode from 'vscode';
import * as constants from '../common/constants';
import * as utils from '../common/utils';

import { Project } from '../models/project';
import { SqlConnectionDataSource } from '../models/dataSources/sqlConnectionStringSource';
Expand Down Expand Up @@ -115,42 +116,47 @@ export class DeployDatabaseDialog {
}

public async getConnectionUri(): Promise<string> {
// if target connection is a data source, have to check if already connected or if connection dialog needs to be opened
let connId: string;

if (this.dataSourcesRadioButton?.checked) {
const dataSource = (this.dataSourcesDropDown!.value! as DataSourceDropdownValue).dataSource;

const connProfile: azdata.IConnectionProfile = {
serverName: dataSource.server,
databaseName: dataSource.database,
connectionName: dataSource.name,
userName: dataSource.username,
password: dataSource.password,
authenticationType: dataSource.integratedSecurity ? 'Integrated' : 'SqlAuth',
savePassword: false,
providerName: 'MSSQL',
saveProfile: true,
id: dataSource.name + '-dataSource',
options: []
};

if (dataSource.integratedSecurity) {
connId = (await this.apiWrapper.connectionConnect(connProfile, false, false)).connectionId;
try {
// if target connection is a data source, have to check if already connected or if connection dialog needs to be opened
let connId: string;

if (this.connectionIsDataSource) {
const dataSource = (this.dataSourcesDropDown!.value! as DataSourceDropdownValue).dataSource;

const connProfile: azdata.IConnectionProfile = {
serverName: dataSource.server,
databaseName: dataSource.database,
connectionName: dataSource.name,
userName: dataSource.username,
password: dataSource.password,
authenticationType: dataSource.integratedSecurity ? 'Integrated' : 'SqlAuth',
savePassword: false,
providerName: 'MSSQL',
saveProfile: true,
id: dataSource.name + '-dataSource',
options: []
};

if (dataSource.integratedSecurity) {
connId = (await this.apiWrapper.connectionConnect(connProfile, false, false)).connectionId;
}
else {
connId = (await this.apiWrapper.openConnectionDialog(undefined, connProfile)).connectionId;
}
}
else {
connId = (await this.apiWrapper.openConnectionDialog(undefined, connProfile)).connectionId;
}
}
else {
if (!this.connection) {
throw new Error('Connection not defined.');
if (!this.connection) {
throw new Error('Connection not defined.');
}

connId = this.connection?.connectionId;
}

connId = this.connection?.connectionId;
return await this.apiWrapper.getUriForConnection(connId);
}
catch (err) {
throw new Error(constants.unableToCreateDeploymentConnection + ': ' + utils.getErrorMessage(err));
}

return await this.apiWrapper.getUriForConnection(connId);
}

public async deployClick(): Promise<void> {
Expand Down

0 comments on commit 0f9f9c8

Please sign in to comment.