Skip to content

Commit 08105cf

Browse files
committed
Accept lower-case charset option
1 parent e8c158b commit 08105cf

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

Changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ you spot any mistakes.
1010
* Make callback to `pool.query` optional like `conn.query` #585
1111
* Prevent enqueuing sequences after fatal error #400
1212
* Fix geometry parser for empty fields #742
13+
* Accept lower-case charset option
1314

1415
## v2.1.1 (2014-03-13)
1516

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ When establishing a connection, you can set the following options:
138138
* `user`: The MySQL user to authenticate as.
139139
* `password`: The password of that MySQL user.
140140
* `database`: Name of the database to use for this connection (Optional).
141-
* `charset`: The charset for the connection. (Default: `'UTF8_GENERAL_CI'`. Value needs to be all in upper case letters!)
141+
* `charset`: The charset for the connection. (Default: `'UTF8_GENERAL_CI'`)
142142
* `timezone`: The timezone used to store local dates. (Default: `'local'`)
143143
* `connectTimeout`: The milliseconds before a timeout occurs during the initial connection
144144
to the MySQL server. (Default: no timeout)

lib/ConnectionConfig.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ ConnectionConfig.getDefaultFlags = function(options) {
8484
return defaultFlags;
8585
};
8686

87-
ConnectionConfig.getCharsetNumber = function(charset) {
88-
return Charsets[charset];
87+
ConnectionConfig.getCharsetNumber = function getCharsetNumber(charset) {
88+
return Charsets[charset.toUpperCase()];
8989
};
9090

9191
ConnectionConfig.parseUrl = function(url) {

test/unit/test-ConnectionConfig.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,12 @@ test('ConnectionConfig#Constructor', {
2626
assert.equal(config.debug, true);
2727
assert.equal(config.charsetNumber, Charsets.BIG5_CHINESE_CI);
2828
},
29+
30+
'allows case-insensitive charset name': function() {
31+
var config = new ConnectionConfig({
32+
charset: 'big5_chinese_ci',
33+
});
34+
35+
assert.equal(config.charsetNumber, Charsets.BIG5_CHINESE_CI);
36+
},
2937
});

0 commit comments

Comments
 (0)