Skip to content

Commit 2a7425e

Browse files
Using Object.assign now instead of manual copying
1 parent 75cbb8c commit 2a7425e

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

src/views/connectionUI.ts

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,34 +40,24 @@ export class ConnectionUI {
4040
const self = this;
4141
return new Promise<Interfaces.IConnectionCredentials>((resolve, reject) => {
4242
// create a new connection to the master db using the current connection as a base
43-
const masterCredentials = <Interfaces.IConnectionCredentials> {
44-
connectionTimeout: currentCredentials.connectionTimeout,
45-
database: 'master',
46-
options: currentCredentials.options,
47-
password: currentCredentials.password,
48-
requestTimeout: currentCredentials.connectionTimeout,
49-
server: currentCredentials.server,
50-
user: currentCredentials.user
51-
};
43+
let masterCredentials: Interfaces.IConnectionCredentials = <any>{};
44+
Object.assign<Interfaces.IConnectionCredentials, Interfaces.IConnectionCredentials>(masterCredentials, currentCredentials);
45+
masterCredentials.database = 'master';
5246
const masterConnection = new mssql.Connection(masterCredentials);
5347

5448
masterConnection.connect().then( () => {
5549
// query sys.databases for a list of databases on the server
5650
new mssql.Request(masterConnection).query('SELECT name FROM sys.databases').then( recordset => {
5751
const pickListItems = recordset.map(record => {
52+
let newCredentials: Interfaces.IConnectionCredentials = <any>{};
53+
Object.assign<Interfaces.IConnectionCredentials, Interfaces.IConnectionCredentials>(newCredentials, currentCredentials);
54+
newCredentials.database = record.name;
55+
5856
return <Interfaces.IConnectionCredentialsQuickPickItem> {
5957
label: record.name,
6058
description: '',
6159
detail: '',
62-
connectionCreds: <Interfaces.IConnectionCredentials> {
63-
connectionTimeout: currentCredentials.connectionTimeout,
64-
database: record.name,
65-
options: currentCredentials.options,
66-
password: currentCredentials.password,
67-
requestTimeout: currentCredentials.requestTimeout,
68-
server: currentCredentials.server,
69-
user: currentCredentials.user
70-
}
60+
connectionCreds: newCredentials
7161
};
7262
});
7363

0 commit comments

Comments
 (0)