33const LRU = require ( 'lru-cache' ) . default ;
44
55const parserCache = new LRU ( {
6- max : 15000
6+ max : 15000 ,
77} ) ;
88
99function 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+
2123 for ( let i = 0 ; i < fields . length ; ++ i ) {
2224 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+ ] ) ;
2435 }
25- return res ;
36+
37+ return JSON . stringify ( res , null , 0 ) ;
2638}
2739
2840function getParser ( type , fields , options , config , compiler ) {
@@ -49,5 +61,6 @@ function clearCache() {
4961module . exports = {
5062 getParser : getParser ,
5163 setMaxCache : setMaxCache ,
52- clearCache : clearCache
64+ clearCache : clearCache ,
65+ _keyFromFields : keyFromFields ,
5366} ;
0 commit comments