Skip to content

Commit 5d253c1

Browse files
committed
pass merged option - result of local and global options
1 parent ab51adf commit 5d253c1

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/commands/execute.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function Execute (options, callback)
2222
this._result = [];
2323
this._fieldCount = 0;
2424
this._rowParser = null;
25-
this.options = options;
25+
this._executeOptions = options;
2626
this._resultIndex = 0;
2727
this._localStream = null;
2828
this._streamFactory = options.infileStreamFactory;
@@ -40,6 +40,7 @@ Execute.prototype.buildParserFromFields = function (fields, connection) {
4040
};
4141

4242
Execute.prototype.start = function (packet, connection) {
43+
this.options = Object.assign({}, connection.config, this._executeOptions);
4344
var executePacket = new Packets.Execute(this.statement.id, this.parameters, connection.config.charsetNumber);
4445
connection.writePacket(executePacket.toPacket(1));
4546
return Execute.prototype.resultsetHeader;

lib/commands/query.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var Command = require('./command.js');
88
var Packets = require('../packets/index.js');
99
var compileParser = require('../compile_text_parser.js');
1010
var ServerStatus = require('../constants/server_status.js');
11+
var CharsetToEncoding = require('../constants/charset_encodings.js');
1112

1213
var EmptyPacket = new Packets.Packet(0, Buffer.allocUnsafe(4), 0, 4);
1314

@@ -16,7 +17,7 @@ function Query (options, callback)
1617
Command.call(this);
1718
this.sql = options.sql;
1819
this.values = options.values;
19-
this.options = options;
20+
this._queryOptions = options;
2021
this.onResult = callback;
2122
this._fieldCount = 0;
2223
this._rowParser = null;
@@ -35,6 +36,7 @@ Query.prototype.start = function (packet, connection) {
3536
console.log(' Sending query command: %s', this.sql);
3637
}
3738
this._connection = connection;
39+
this.options = Object.assign({}, connection.config, this._queryOptions);
3840
var cmdPacket = new Packets.Query(this.sql, connection.config.charsetNumber);
3941
connection.writePacket(cmdPacket.toPacket(1));
4042
return Query.prototype.resultsetHeader;
@@ -168,7 +170,7 @@ Query.prototype.readField = function (packet, connection) {
168170
this._rowParser = connection.textProtocolParsers[parserKey];
169171
if (!this._rowParser) {
170172
this._rowParser = compileParser(fields, this.options, connection.config);
171-
connection.textProtocolParsers[parserKey] = this.rowParser;
173+
connection.textProtocolParsers[parserKey] = this._rowParser;
172174
}
173175
return Query.prototype.fieldsEOF;
174176
}
@@ -195,7 +197,8 @@ Query.prototype.row = function (packet)
195197
return this.done();
196198
}
197199

198-
var row = new this._rowParser(packet, this._fields[this._resultIndex], this.options);
200+
debugger;
201+
var row = new this._rowParser(packet, this._fields[this._resultIndex], this.options, CharsetToEncoding);
199202
if (this.onResult) {
200203
this._rows[this._resultIndex].push(row);
201204
} else {

0 commit comments

Comments
 (0)