3
3
const LRU = require ( 'lru-cache' ) . default ;
4
4
5
5
const parserCache = new LRU ( {
6
- max : 15000
6
+ max : 15000 ,
7
7
} ) ;
8
8
9
9
function keyFromFields ( type , fields , options , config ) {
10
- let res =
11
- `${ type } ` +
12
- `/${ typeof options . nestTables } ` +
13
- `/${ options . nestTables } ` +
14
- `/${ options . rowsAsArray } ` +
15
- `/${ options . supportBigNumbers || config . supportBigNumbers } ` +
16
- `/${ options . bigNumberStrings || config . bigNumberStrings } ` +
17
- `/${ typeof options . typeCast } ` +
18
- `/${ options . timezone || config . timezone } ` +
19
- `/${ options . decimalNumbers } ` +
20
- `/${ options . dateStrings } ` ;
10
+ const res = [
11
+ type ,
12
+ typeof options . nestTables ,
13
+ options . nestTables ,
14
+ Boolean ( options . rowsAsArray ) ,
15
+ Boolean ( options . supportBigNumbers || config . supportBigNumbers ) ,
16
+ Boolean ( options . bigNumberStrings || config . bigNumberStrings ) ,
17
+ typeof options . typeCast ,
18
+ options . timezone || config . timezone ,
19
+ Boolean ( options . decimalNumbers ) ,
20
+ options . dateStrings ,
21
+ ] ;
22
+
21
23
for ( let i = 0 ; i < fields . length ; ++ i ) {
22
24
const field = fields [ i ] ;
23
- res += `/${ field . name } :${ field . columnType } :${ field . length } :${ field . schema } :${ field . table } :${ field . flags } :${ field . characterSet } ` ;
25
+
26
+ res . push ( [
27
+ field . name ,
28
+ field . columnType ,
29
+ field . length ,
30
+ field . schema ,
31
+ field . table ,
32
+ field . flags ,
33
+ field . characterSet ,
34
+ ] ) ;
24
35
}
25
- return res ;
36
+
37
+ return JSON . stringify ( res , null , 0 ) ;
26
38
}
27
39
28
40
function getParser ( type , fields , options , config , compiler ) {
@@ -49,5 +61,6 @@ function clearCache() {
49
61
module . exports = {
50
62
getParser : getParser ,
51
63
setMaxCache : setMaxCache ,
52
- clearCache : clearCache
64
+ clearCache : clearCache ,
65
+ _keyFromFields : keyFromFields ,
53
66
} ;
0 commit comments