@@ -44,25 +44,34 @@ export class Utility {
44
44
45
45
sql = sql ? sql : vscode . window . activeTextEditor . document . getText ( ) ;
46
46
connectionOptions = connectionOptions ? connectionOptions : Global . activeConnection ;
47
+ connectionOptions . multipleStatements = true ;
47
48
const connection = mysql . createConnection ( connectionOptions ) ;
48
49
49
50
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
+ } ) ;
54
61
} else {
55
- OutputChannel . appendLine ( JSON . stringify ( result ) ) ;
62
+ OutputChannel . appendLine ( asciitable ( rows ) ) ;
56
63
}
57
- AppInsightsClient . sendEvent ( "runQuery.end" , { Result : "Success" } ) ;
58
- } )
59
- . catch ( ( err ) => {
64
+ } else {
65
+ OutputChannel . appendLine ( JSON . stringify ( rows ) ) ;
66
+ }
67
+ if ( err ) {
60
68
OutputChannel . appendLine ( err ) ;
61
69
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
+ } ) ;
66
75
}
67
76
68
77
public static async createSQLTextDocument ( sql : string = "" ) {
0 commit comments