Skip to content
This repository was archived by the owner on Feb 8, 2025. It is now read-only.

Commit 96db99e

Browse files
committed
FIX AZURE DATA PROVIDER, WHEN DEFAULT DATABASE IS NOT SET USE ALWAYS MASTER IN CONNECTION PROFILE OPTIONS
1 parent c2fd4f6 commit 96db99e

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

extension.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async function handleCommand(context, getScriptFunc, clipboard = false, identity
4949
});
5050
}
5151
} catch (reason) {
52-
vscode.window.showErrorMessage(reason);
52+
vscode.window.showErrorMessage(reason.message);
5353
}
5454
}
5555

scriptInsertAs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async function getSqlScriptAsInsertAsync(connectionProfile, tableCatalog, tableS
1717
{
1818
let queryText = sqlUtils.getColumnInfoQuerySql(tableCatalog, tableSchema, tableName);
1919

20-
let results = await sqlUtils.getResultsFromQuerySql(connectionProfile, "MSSQL", queryText);
20+
let results = await sqlUtils.getResultsFromQuerySql(connectionProfile, "MSSQL", queryText, tableCatalog);
2121

2222
if (!results || results.rowCount === 0) {
2323
throw "No se han obtenido resultados de la consulta";

scriptSelectAs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ async function getSqlScriptAsSelectAsync(connectionProfile, tableCatalog, tableS
88
{
99
let queryText = sqlUtils.getColumnInfoQuerySql(tableCatalog, tableSchema, tableName);
1010

11-
let results = await sqlUtils.getResultsFromQuerySql(connectionProfile, "MSSQL", queryText);
11+
let results = await sqlUtils.getResultsFromQuerySql(connectionProfile, "MSSQL", queryText, tableCatalog);
1212

1313
if (!results || results.rowCount === 0) {
1414
throw "No se han obtenido resultados de la consulta";

scriptSqlUtils.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,14 @@ function getColumnInfoQuerySql(tableCatalog, tableSchema, tableName)
4444
ORDER BY COL.ORDINAL_POSITION`;
4545
}
4646

47-
async function getResultsFromQuerySql(connectionProfile, providerText, queryText)
47+
async function getResultsFromQuerySql(connectionProfile, providerText, queryText, tableCatalog)
4848
{
49+
//FIX AZURE DATA PROVIDER, WHEN DEFAULT DATABASE IS NOT SET USE ALWAYS MASTER IN CONNECTION PROFILE OPTIONS
50+
if(tableCatalog
51+
&& connectionProfile.options.database != tableCatalog){
52+
connectionProfile.options.database = tableCatalog;
53+
}
54+
4955
let connectionResult = await azdata.connection.connect(connectionProfile, false, false);
5056
let connectionUri = await azdata.connection.getUriForConnection(connectionResult.connectionId);
5157

scriptUpdateAs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ async function getSqlScriptAsUpdateAsync(connectionProfile, tableCatalog, tableS
1616
{
1717
let queryText = sqlUtils.getColumnInfoQuerySql(tableCatalog, tableSchema, tableName);
1818

19-
let results = await sqlUtils.getResultsFromQuerySql(connectionProfile, "MSSQL", queryText);
19+
let results = await sqlUtils.getResultsFromQuerySql(connectionProfile, "MSSQL", queryText, tableCatalog);
2020

2121
if (!results || results.rowCount === 0) {
2222
throw "No se han obtenido resultados de la consulta";

0 commit comments

Comments
 (0)