@@ -74,6 +74,8 @@ Connection.prototype.connect = function(cb) {
74
74
} ;
75
75
76
76
Connection . prototype . changeUser = function ( options , cb ) {
77
+ cb = cb || function ( ) { } ;
78
+
77
79
this . _implyConnect ( ) ;
78
80
79
81
if ( typeof options === 'function' ) {
@@ -85,13 +87,18 @@ Connection.prototype.changeUser = function(options, cb){
85
87
? Config . getCharsetNumber ( options . charset )
86
88
: this . config . charsetNumber ;
87
89
90
+ var self = this ;
91
+
88
92
return this . _protocol . changeUser ( {
89
93
user : options . user || this . config . user ,
90
94
password : options . password || this . config . password ,
91
95
database : options . database || this . config . database ,
92
96
charsetNumber : charsetNumber ,
93
97
currentConfig : this . config
94
- } , cb ) ;
98
+ } , function ( err ) {
99
+ self . inTransaction = false ;
100
+ return cb ( err ) ;
101
+ } ) ;
95
102
} ;
96
103
97
104
Connection . prototype . beginTransaction = function ( cb ) {
@@ -101,9 +108,9 @@ Connection.prototype.beginTransaction = function(cb) {
101
108
102
109
this . _implyConnect ( ) ;
103
110
104
- var that = this ;
111
+ var self = this ;
105
112
var query = Connection . createQuery ( 'BEGIN' , function ( err ) {
106
- that . inTransaction = true ;
113
+ self . inTransaction = true ;
107
114
return cb ( err ) ;
108
115
} ) ;
109
116
@@ -118,9 +125,9 @@ Connection.prototype.commit = function(cb) {
118
125
119
126
this . _implyConnect ( ) ;
120
127
121
- var that = this ;
128
+ var self = this ;
122
129
var query = Connection . createQuery ( 'COMMIT' , function ( err ) {
123
- that . inTransaction = false ;
130
+ self . inTransaction = false ;
124
131
return cb ( err ) ;
125
132
} ) ;
126
133
@@ -135,9 +142,9 @@ Connection.prototype.rollback = function(cb) {
135
142
136
143
this . _implyConnect ( ) ;
137
144
138
- var that = this ;
145
+ var self = this ;
139
146
var query = Connection . createQuery ( 'ROLLBACK' , function ( err ) {
140
- that . inTransaction = false ;
147
+ self . inTransaction = false ;
141
148
return cb ( err ) ;
142
149
} ) ;
143
150
0 commit comments