@@ -12,9 +12,12 @@ for (const t in Types) {
12
12
}
13
13
14
14
function readCodeFor ( type , charset , encodingExpr , config , options ) {
15
- const supportBigNumbers =
16
- options . supportBigNumbers || config . supportBigNumbers ;
17
- const bigNumberStrings = options . bigNumberStrings || config . bigNumberStrings ;
15
+ const supportBigNumbers = Boolean (
16
+ options . supportBigNumbers || config . supportBigNumbers ,
17
+ ) ;
18
+ const bigNumberStrings = Boolean (
19
+ options . bigNumberStrings || config . bigNumberStrings ,
20
+ ) ;
18
21
const timezone = options . timezone || config . timezone ;
19
22
const dateStrings = options . dateStrings || config . dateStrings ;
20
23
@@ -85,22 +88,24 @@ function compile(fields, options, config) {
85
88
db : field . schema ,
86
89
table : field . table ,
87
90
name : field . name ,
88
- string : function ( encoding = field . encoding ) {
91
+ string : function ( encoding = field . encoding ) {
89
92
if ( field . columnType === Types . JSON && encoding === field . encoding ) {
90
93
// Since for JSON columns mysql always returns charset 63 (BINARY),
91
94
// we have to handle it according to JSON specs and use "utf8",
92
95
// see https://github.com/sidorares/node-mysql2/issues/1661
93
- console . warn ( `typeCast: JSON column "${ field . name } " is interpreted as BINARY by default, recommended to manually set utf8 encoding: \`field.string("utf8")\`` ) ;
96
+ console . warn (
97
+ `typeCast: JSON column "${ field . name } " is interpreted as BINARY by default, recommended to manually set utf8 encoding: \`field.string("utf8")\`` ,
98
+ ) ;
94
99
}
95
100
96
101
return _this . packet . readLengthCodedString ( encoding ) ;
97
102
} ,
98
- buffer : function ( ) {
103
+ buffer : function ( ) {
99
104
return _this . packet . readLengthCodedBuffer ( ) ;
100
105
} ,
101
- geometry : function ( ) {
106
+ geometry : function ( ) {
102
107
return _this . packet . parseGeometryValue ( ) ;
103
- }
108
+ } ,
104
109
} ;
105
110
}
106
111
@@ -109,9 +114,7 @@ function compile(fields, options, config) {
109
114
/* eslint-disable no-trailing-spaces */
110
115
/* eslint-disable no-spaced-func */
111
116
/* eslint-disable no-unexpected-multiline */
112
- parserFn ( '(function () {' ) (
113
- 'return class TextRow {'
114
- ) ;
117
+ parserFn ( '(function () {' ) ( 'return class TextRow {' ) ;
115
118
116
119
// constructor method
117
120
parserFn ( 'constructor(fields) {' ) ;
@@ -127,22 +130,22 @@ function compile(fields, options, config) {
127
130
128
131
// next method
129
132
parserFn ( 'next(packet, fields, options) {' ) ;
130
- parserFn ( " this.packet = packet;" ) ;
133
+ parserFn ( ' this.packet = packet;' ) ;
131
134
if ( options . rowsAsArray ) {
132
135
parserFn ( `const result = new Array(${ fields . length } );` ) ;
133
136
} else {
134
- parserFn ( " const result = {};" ) ;
137
+ parserFn ( ' const result = {};' ) ;
135
138
}
136
139
137
140
const resultTables = { } ;
138
141
let resultTablesArray = [ ] ;
139
142
140
143
if ( options . nestTables === true ) {
141
- for ( let i = 0 ; i < fields . length ; i ++ ) {
144
+ for ( let i = 0 ; i < fields . length ; i ++ ) {
142
145
resultTables [ fields [ i ] . table ] = 1 ;
143
146
}
144
147
resultTablesArray = Object . keys ( resultTables ) ;
145
- for ( let i = 0 ; i < resultTablesArray . length ; i ++ ) {
148
+ for ( let i = 0 ; i < resultTablesArray . length ; i ++ ) {
146
149
parserFn ( `result[${ helpers . srcEscape ( resultTablesArray [ i ] ) } ] = {};` ) ;
147
150
}
148
151
}
@@ -154,7 +157,7 @@ function compile(fields, options, config) {
154
157
parserFn ( `// ${ fieldName } : ${ typeNames [ fields [ i ] . columnType ] } ` ) ;
155
158
if ( typeof options . nestTables === 'string' ) {
156
159
lvalue = `result[${ helpers . srcEscape (
157
- fields [ i ] . table + options . nestTables + fields [ i ] . name
160
+ fields [ i ] . table + options . nestTables + fields [ i ] . name ,
Has conversations. Original line has conversations. 158
161
) } ]`;
159
162
} else if ( options . nestTables === true ) {
160
163
lvalue = `result[${ helpers . srcEscape ( fields [ i ] . table ) } ][${ fieldName } ]` ;
@@ -172,11 +175,13 @@ function compile(fields, options, config) {
172
175
fields [ i ] . characterSet ,
173
176
encodingExpr ,
174
177
config ,
175
- options
178
+ options ,
176
179
) ;
177
180
if ( typeof options . typeCast === 'function' ) {
178
- parserFn ( `${ lvalue } = options.typeCast(this.wrap${ i } , function() { return ${ readCode } });` ) ;
179
- } else {
181
+ parserFn (
182
+ `${ lvalue } = options.typeCast(this.wrap${ i } , function() { return ${ readCode } });` ,
183
+ ) ;
184
+ } else {
180
185
parserFn ( `${ lvalue } = ${ readCode } ;` ) ;
181
186
}
182
187
}
@@ -193,11 +198,11 @@ function compile(fields, options, config) {
193
198
if ( config . debug ) {
194
199
helpers . printDebugWithCode (
195
200
'Compiled text protocol row parser' ,
196
- parserFn . toString ( )
201
+ parserFn . toString ( ) ,
197
202
) ;
198
203
}
199
204
if ( typeof options . typeCast === 'function' ) {
200
- return parserFn . toFunction ( { wrap} ) ;
205
+ return parserFn . toFunction ( { wrap } ) ;
201
206
}
202
207
return parserFn . toFunction ( ) ;
203
208
}