Skip to content

Commit 7e224fb

Browse files
committed
Pass flag parsing (split) to ConnectionConfig.mergeFlags
This way, tests can also check for correct flag string splitting
1 parent edeed48 commit 7e224fb

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

lib/ConnectionConfig.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ function ConnectionConfig(options) {
3434
: Charsets.UTF8_GENERAL_CI;
3535

3636
this.clientFlags = ConnectionConfig.mergeFlags(ConnectionConfig.getDefaultFlags(options),
37-
(options.flags || '').toUpperCase().split(/\s*,+\s*/));
37+
options.flags || '');
3838
}
3939

4040
ConnectionConfig.mergeFlags = function(default_flags, user_flags) {
4141
var flags = 0x0, i;
4242

43-
user_flags = user_flags || [];
43+
user_flags = (user_flags || '').toUpperCase().split(/\s*,+\s*/);
4444

4545
// add default flags unless "blacklisted"
4646
for (i in default_flags) {

test/integration/connection/test-connection-config-flags.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,41 +4,45 @@ var assert = require('assert');
44

55
var testFlags = [{
66
'default' : [ '' ],
7-
'user' : [ 'LONG_PASSWORD' ],
7+
'user' : 'LONG_PASSWORD',
88
'expected': ClientConstants.CLIENT_LONG_PASSWORD
99
}, {
1010
'default' : [ '' ],
11-
'user' : [ '-LONG_PASSWORD' ],
11+
'user' : '-LONG_PASSWORD',
1212
'expected': 0x0
1313
}, {
1414
'default' : [ 'LONG_PASSWORD', 'FOUND_ROWS' ],
15-
'user' : [ '-LONG_PASSWORD' ],
15+
'user' : '-LONG_PASSWORD',
1616
'expected': ClientConstants.CLIENT_FOUND_ROWS
1717
}, {
1818
'default' : [ 'LONG_PASSWORD', 'FOUND_ROWS' ],
19-
'user' : [ '-FOUND_ROWS' ],
19+
'user' : '-FOUND_ROWS',
2020
'expected': ClientConstants.CLIENT_LONG_PASSWORD
2121
}, {
2222
'default' : [ 'LONG_PASSWORD', 'FOUND_ROWS' ],
23-
'user' : [ '-LONG_FLAG' ],
23+
'user' : '-LONG_FLAG',
2424
'expected': ClientConstants.CLIENT_LONG_PASSWORD |
2525
ClientConstants.CLIENT_FOUND_ROWS
2626
}, {
2727
'default' : [ 'LONG_PASSWORD', 'FOUND_ROWS' ],
28-
'user' : [ 'LONG_FLAG' ],
28+
'user' : 'LONG_FLAG',
2929
'expected': ClientConstants.CLIENT_LONG_PASSWORD |
3030
ClientConstants.CLIENT_FOUND_ROWS |
3131
ClientConstants.CLIENT_LONG_FLAG
3232
}, {
3333
'default' : [ 'LONG_PASSWORD', 'FOUND_ROWS' ],
34-
'user' : [ 'UNDEFINED_CONSTANT' ],
34+
'user' : 'UNDEFINED_CONSTANT',
3535
'expected': ClientConstants.CLIENT_LONG_PASSWORD |
3636
ClientConstants.CLIENT_FOUND_ROWS
3737
}, {
3838
'default' : [ 'LONG_PASSWORD', 'FOUND_ROWS' ],
39-
'user' : [ '-UNDEFINED_CONSTANT' ],
39+
'user' : '-UNDEFINED_CONSTANT',
4040
'expected': ClientConstants.CLIENT_LONG_PASSWORD |
4141
ClientConstants.CLIENT_FOUND_ROWS
42+
}, {
43+
'default' : [ 'LONG_PASSWORD', 'FOUND_ROWS' ],
44+
'user' : '-UNDEFINED_CONSTANT,, -found_ROWS',
45+
'expected': ClientConstants.CLIENT_LONG_PASSWORD
4246
}];
4347

4448
for (var i = 0; i < testFlags.length; i++) {

0 commit comments

Comments
 (0)