@@ -17,6 +17,7 @@ function ConnectionConfig(options) {
17
17
this . insecureAuth = options . insecureAuth || false ;
18
18
this . debug = options . debug ;
19
19
this . timezone = options . timezone || 'local' ;
20
+ this . flags = options . flags || '' ;
20
21
this . typeCast = ( options . typeCast === undefined )
21
22
? true
22
23
: options . typeCast ;
@@ -32,23 +33,37 @@ function ConnectionConfig(options) {
32
33
? ConnectionConfig . getCharsetNumber ( options . charset )
33
34
: Charsets . UTF8_GENERAL_CI ;
34
35
35
- this . clientFlags =
36
- ClientConstants . CLIENT_LONG_PASSWORD |
37
- ClientConstants . CLIENT_FOUND_ROWS |
38
- ClientConstants . CLIENT_LONG_FLAG |
39
- ClientConstants . CLIENT_CONNECT_WITH_DB |
40
- ClientConstants . CLIENT_ODBC |
41
- ClientConstants . CLIENT_LOCAL_FILES |
42
- ClientConstants . CLIENT_IGNORE_SPACE |
43
- ClientConstants . CLIENT_PROTOCOL_41 |
44
- ClientConstants . CLIENT_IGNORE_SIGPIPE |
45
- ClientConstants . CLIENT_TRANSACTIONS |
46
- ClientConstants . CLIENT_RESERVED |
47
- ClientConstants . CLIENT_SECURE_CONNECTION |
48
- ClientConstants . CLIENT_MULTI_RESULTS ;
49
-
36
+ this . defaultFlags = [ "LONG_PASSWORD" , "FOUND_ROWS" , "LONG_FLAG" ,
37
+ "CONNECT_WITH_DB" , "ODBC" , "LOCAL_FILES" ,
38
+ "IGNORE_SPACE" , "PROTOCOL_41" , "IGNORE_SIGPIPE" ,
39
+ "TRANSACTIONS" , "RESERVED" , "SECURE_CONNECTION" ,
40
+ "MULTI_RESULTS" ] ;
50
41
if ( options . multipleStatements ) {
51
- this . clientFlags |= ClientConstants . CLIENT_MULTI_STATEMENTS ;
42
+ this . defaultFlags . push ( "MULTI_STATEMENTS" ) ;
43
+ }
44
+
45
+ var i ;
46
+
47
+ if ( this . flags . length > 0 ) {
48
+ this . flags = this . flags . toUpperCase ( ) . split ( ',' ) ;
49
+ } else {
50
+ this . flags = [ ] ;
51
+ }
52
+
53
+ this . clientFlags = 0x0 ;
54
+
55
+ // add default flags unless "blacklisted"
56
+ for ( i in this . defaultFlags ) {
57
+ if ( this . flags . indexOf ( "-" + this . defaultFlags [ i ] ) >= 0 ) continue ;
58
+
59
+ this . clientFlags |= ClientConstants [ "CLIENT_" + this . defaultFlags [ i ] ] || 0x0 ;
60
+ }
61
+ // add user flags unless already already added
62
+ for ( i in this . flags ) {
63
+ if ( this . flags [ i ] [ 0 ] == "-" ) continue ;
64
+ if ( this . defaultFlags . indexOf ( this . flags [ i ] ) >= 0 ) continue ;
65
+
66
+ this . clientFlags |= ClientConstants [ "CLIENT_" + this . flags [ i ] ] || 0x0 ;
52
67
}
53
68
}
54
69
0 commit comments