Skip to content

Commit e81814c

Browse files
committed
needed to create non latin table
1 parent f8fe05b commit e81814c

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

lib/commands/client_handshake.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ClientHandshake.prototype.start = function () {
1717
};
1818

1919
ClientHandshake.prototype.sendSSLRequest = function (connection) {
20-
var sslRequest = new Packets.SSLRequest(this.clientFlags);
20+
var sslRequest = new Packets.SSLRequest(this.clientFlags, connection.config.charsetNumber);
2121
connection.writePacket(sslRequest.toPacket());
2222
};
2323

lib/connection_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function ConnectionConfig (options) {
5959
this.maxPacketSize = 0;
6060
this.charsetNumber = (options.charset)
6161
? ConnectionConfig.getCharsetNumber(options.charset)
62-
: options.charsetNumber || Charsets.UTF8_GENERAL_CI;
62+
: options.charsetNumber || Charsets.UTF8MB4_UNICODE_CI;
6363

6464
this.compress = options.compress || false;
6565

lib/packets/ssl_request.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ var ClientConstants = require('../constants/client');
22
var Packet = require('../packets/packet');
33
var Charsets = require('../constants/charsets');
44

5-
function SSLRequest (flags)
5+
function SSLRequest (flags, charset)
66
{
77
this.clientFlags = flags | ClientConstants.SSL;
8+
this.charset = charset;
89
}
910

1011
SSLRequest.prototype.toPacket = function ()
@@ -17,7 +18,7 @@ SSLRequest.prototype.toPacket = function ()
1718

1819
packet.writeInt32(this.clientFlags);
1920
packet.writeInt32(0); // max packet size. todo: move to config
20-
packet.writeInt8(Charsets.UTF8_GENERAL_CI);
21+
packet.writeInt8(this.charset);
2122
return packet;
2223
};
2324

test/integration/connection/test-charset-encoding.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ var assert = require('assert');
55
// test data stores
66
var testData = [
77
'ютф восемь',
8+
'Experimental',
89
'परीक्षण',
910
'test тест テスト փորձաsրկում পরীক্ষা kiểm tra',
1011
'ტესტი પરીક્ષણ מבחן פּרובירן اختبار'
1112
];
1213

1314
var resultData = null;
1415

15-
// tests
16+
// test inserting of non latin data if we are able to parse it
1617

1718
var testEncoding = function (err) {
1819
assert.ifError(err);
@@ -35,13 +36,15 @@ var testEncoding = function (err) {
3536

3637
// init test sequence
3738
(function () {
38-
connection.query(
39-
'CREATE TABLE IF NOT EXISTS `test-charset-encoding` ' +
40-
'( `field` VARCHAR(1000) CHARACTER SET latin1 COLLATE latin1_danish_ci)',
41-
function (err) {
42-
assert.ifError(err);
43-
connection.query('DELETE from `test-charset-encoding`', testEncoding);
44-
});
39+
connection.query('DROP TABLE IF EXISTS `test-charset-encoding`', function (err) {
40+
connection.query(
41+
'CREATE TABLE IF NOT EXISTS `test-charset-encoding` ' +
42+
'( `field` VARCHAR(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci)',
43+
function (err) {
44+
assert.ifError(err);
45+
connection.query('DELETE from `test-charset-encoding`', testEncoding);
46+
});
47+
});
4548
})();
4649

4750
process.on('exit', function () {

0 commit comments

Comments
 (0)