File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -2,25 +2,26 @@ var Buffer = require('safe-buffer').Buffer;
2
2
var Packet = require ( '../packets/packet.js' ) ;
3
3
var CommandCode = require ( '../constants/commands.js' ) ;
4
4
var StringParser = require ( '../parsers/string.js' ) ;
5
+ var CharsetToEncoding = require ( '../constants/charset_encodings.js' ) ;
6
+
5
7
6
8
function Query ( sql , charsetNumber )
7
9
{
8
10
this . query = sql ;
9
11
this . charsetNumber = charsetNumber ;
12
+ this . encoding = CharsetToEncoding [ charsetNumber ] ;
10
13
}
11
14
12
15
Query . prototype . toPacket = function ( )
13
16
{
14
- // TODO: use this.charsetNumber and get proper encoding type
15
- var buf = StringParser . encode ( this . query , 'cesu8' ) ;
17
+ var buf = StringParser . encode ( this . query , this . encoding ) ;
16
18
var length = 5 + buf . length ;
17
19
18
20
var buffer = Buffer . allocUnsafe ( length ) ;
19
21
var packet = new Packet ( 0 , buffer , 0 , length ) ;
20
22
packet . offset = 4 ;
21
23
packet . writeInt8 ( CommandCode . QUERY ) ;
22
- // TODO: pass down encoding to this method too
23
- packet . writeString ( this . query , 'cesu8' ) ;
24
+ packet . writeBuffer ( buf ) ;
24
25
return packet ;
25
26
} ;
26
27
You can’t perform that action at this time.
0 commit comments