Skip to content

Commit c8bcf89

Browse files
Changed that usage to self. connection.changeUser now sets inTransaction to false.
1 parent 4d0d555 commit c8bcf89

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

lib/Connection.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ Connection.prototype.connect = function(cb) {
7474
};
7575

7676
Connection.prototype.changeUser = function(options, cb){
77+
cb = cb || function() {};
78+
7779
this._implyConnect();
7880

7981
if (typeof options === 'function') {
@@ -85,13 +87,18 @@ Connection.prototype.changeUser = function(options, cb){
8587
? Config.getCharsetNumber(options.charset)
8688
: this.config.charsetNumber;
8789

90+
var self = this;
91+
8892
return this._protocol.changeUser({
8993
user : options.user || this.config.user,
9094
password : options.password || this.config.password,
9195
database : options.database || this.config.database,
9296
charsetNumber : charsetNumber,
9397
currentConfig : this.config
94-
}, cb);
98+
}, function(err) {
99+
self.inTransaction = false;
100+
return cb(err);
101+
});
95102
};
96103

97104
Connection.prototype.beginTransaction = function(cb) {
@@ -101,9 +108,9 @@ Connection.prototype.beginTransaction = function(cb) {
101108

102109
this._implyConnect();
103110

104-
var that = this;
111+
var self = this;
105112
var query = Connection.createQuery('BEGIN', function(err) {
106-
that.inTransaction = true;
113+
self.inTransaction = true;
107114
return cb(err);
108115
});
109116

@@ -118,9 +125,9 @@ Connection.prototype.commit = function(cb) {
118125

119126
this._implyConnect();
120127

121-
var that = this;
128+
var self = this;
122129
var query = Connection.createQuery('COMMIT', function(err) {
123-
that.inTransaction = false;
130+
self.inTransaction = false;
124131
return cb(err);
125132
});
126133

@@ -135,9 +142,9 @@ Connection.prototype.rollback = function(cb) {
135142

136143
this._implyConnect();
137144

138-
var that = this;
145+
var self = this;
139146
var query = Connection.createQuery('ROLLBACK', function(err) {
140-
that.inTransaction = false;
147+
self.inTransaction = false;
141148
return cb(err);
142149
});
143150

0 commit comments

Comments
 (0)