@@ -8,6 +8,7 @@ var Command = require('./command.js');
8
8
var Packets = require ( '../packets/index.js' ) ;
9
9
var compileParser = require ( '../compile_text_parser.js' ) ;
10
10
var ServerStatus = require ( '../constants/server_status.js' ) ;
11
+ var CharsetToEncoding = require ( '../constants/charset_encodings.js' ) ;
11
12
12
13
var EmptyPacket = new Packets . Packet ( 0 , Buffer . allocUnsafe ( 4 ) , 0 , 4 ) ;
13
14
@@ -16,7 +17,7 @@ function Query (options, callback)
16
17
Command . call ( this ) ;
17
18
this . sql = options . sql ;
18
19
this . values = options . values ;
19
- this . options = options ;
20
+ this . _queryOptions = options ;
20
21
this . onResult = callback ;
21
22
this . _fieldCount = 0 ;
22
23
this . _rowParser = null ;
@@ -35,6 +36,7 @@ Query.prototype.start = function (packet, connection) {
35
36
console . log ( ' Sending query command: %s' , this . sql ) ;
36
37
}
37
38
this . _connection = connection ;
39
+ this . options = Object . assign ( { } , connection . config , this . _queryOptions ) ;
38
40
var cmdPacket = new Packets . Query ( this . sql , connection . config . charsetNumber ) ;
39
41
connection . writePacket ( cmdPacket . toPacket ( 1 ) ) ;
40
42
return Query . prototype . resultsetHeader ;
@@ -168,7 +170,7 @@ Query.prototype.readField = function (packet, connection) {
168
170
this . _rowParser = connection . textProtocolParsers [ parserKey ] ;
169
171
if ( ! this . _rowParser ) {
170
172
this . _rowParser = compileParser ( fields , this . options , connection . config ) ;
171
- connection . textProtocolParsers [ parserKey ] = this . rowParser ;
173
+ connection . textProtocolParsers [ parserKey ] = this . _rowParser ;
172
174
}
173
175
return Query . prototype . fieldsEOF ;
174
176
}
@@ -195,7 +197,8 @@ Query.prototype.row = function (packet)
195
197
return this . done ( ) ;
196
198
}
197
199
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 ) ;
199
202
if ( this . onResult ) {
200
203
this . _rows [ this . _resultIndex ] . push ( row ) ;
201
204
} else {
0 commit comments