Skip to content

Commit f2c2f33

Browse files
committed
Support multiple statement queries
1 parent 31523aa commit f2c2f33

File tree

4 files changed

+28
-14
lines changed

4 files changed

+28
-14
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 0.1.0 (2017-11-30)
2+
* Support multiple statement queries
3+
14
## 0.0.3 (2017-11-26)
25
* Activate extension when running MySQL query
36

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
"name": "vscode-mysql",
33
"displayName": "MySQL",
44
"description": "MySQL management tool",
5-
"version": "0.0.3",
5+
"version": "0.1.0",
66
"publisher": "formulahendry",
77
"icon": "logo.png",
88
"engines": {
99
"vscode": "^1.18.0"
1010
},
1111
"categories": [
12-
"Languages"
12+
"Languages",
13+
"Azure"
1314
],
1415
"keywords": [
1516
"SQL",

src/common/utility.ts

+21-12
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,34 @@ export class Utility {
4444

4545
sql = sql ? sql : vscode.window.activeTextEditor.document.getText();
4646
connectionOptions = connectionOptions ? connectionOptions : Global.activeConnection;
47+
connectionOptions.multipleStatements = true;
4748
const connection = mysql.createConnection(connectionOptions);
4849

4950
OutputChannel.appendLine("[Start] Executing MySQL query...");
50-
Utility.queryPromise<any>(connection, sql)
51-
.then((result) => {
52-
if (Array.isArray(result)) {
53-
OutputChannel.appendLine(asciitable(result));
51+
connection.query(sql, (err, rows) => {
52+
if (Array.isArray(rows)) {
53+
if (rows.some(((row) => Array.isArray(row)))) {
54+
rows.forEach((row) => {
55+
if (Array.isArray(row)) {
56+
OutputChannel.appendLine(asciitable(row));
57+
} else {
58+
OutputChannel.appendLine(JSON.stringify(row));
59+
}
60+
});
5461
} else {
55-
OutputChannel.appendLine(JSON.stringify(result));
62+
OutputChannel.appendLine(asciitable(rows));
5663
}
57-
AppInsightsClient.sendEvent("runQuery.end", { Result: "Success" });
58-
})
59-
.catch((err) => {
64+
} else {
65+
OutputChannel.appendLine(JSON.stringify(rows));
66+
}
67+
if (err) {
6068
OutputChannel.appendLine(err);
6169
AppInsightsClient.sendEvent("runQuery.end", { Result: "Fail", ErrorMessage: err });
62-
})
63-
.then(() => {
64-
OutputChannel.appendLine("[Done] Finished MySQL query.");
65-
});
70+
} else {
71+
AppInsightsClient.sendEvent("runQuery.end", { Result: "Success" });
72+
}
73+
OutputChannel.appendLine("[Done] Finished MySQL query.");
74+
});
6675
}
6776

6877
public static async createSQLTextDocument(sql: string = "") {

src/model/connection.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ export interface IConnection {
44
readonly password?: string;
55
readonly port: string;
66
readonly database?: string;
7+
multipleStatements?: boolean;
78
}

0 commit comments

Comments
 (0)