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

Commit 2536dda

Browse files
authored
Merge pull request #22 from pacoweb/refactor_fix
Fix Azure Sql Server connection error
2 parents 347135b + 3c77d37 commit 2536dda

File tree

6 files changed

+12
-6
lines changed

6 files changed

+12
-6
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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Extra Sql Script As",
44
"description": "This extension adds several missing options to the context menu of the object tree: Script Table as INSERT, Script Table as UPDATE...",
55
"publisher": "pacoweb",
6-
"version": "0.6.2",
6+
"version": "0.6.3",
77
"license": "https://raw.githubusercontent.com/pacoweb/extraSqlScriptAs/master/LICENSE",
88
"icon": "images/default_icon.png",
99
"repository": {

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)