Skip to content
This repository was archived by the owner on Apr 29, 2025. It is now read-only.

Commit 9ef9b0d

Browse files
committed
fix(utils/typeCast): typeerror
BLOB's with a value of null cannot be iterated, resulting in an error while trying to return [...field.buffer()]. Minor change to weird typecasting on date values.
1 parent c9e402c commit 9ef9b0d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/utils/typeCast.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@ export const typeCast = (field: Field, next: () => void) => {
1818
case 'TIMESTAMP':
1919
case 'TIMESTAMP2':
2020
case 'NEWDATE':
21+
return new Date(field.string()).getTime();
2122
case 'DATE':
22-
return field.type === 'DATE'
23-
? new Date(field.string() + ' 00:00:00').getTime()
24-
: new Date(field.string()).getTime();
23+
return new Date(field.string() + ' 00:00:00').getTime();
2524
case 'TINY':
2625
return field.length === 1 ? field.string() === '1' : next();
2726
case 'BIT':
@@ -31,7 +30,9 @@ export const typeCast = (field: Field, next: () => void) => {
3130
case 'LONG_BLOB':
3231
case 'BLOB':
3332
if (field.charset === BINARY_CHARSET) {
34-
return [...field.buffer()];
33+
const value = field.buffer();
34+
if (value === null) return [value]
35+
return [...value];
3536
}
3637
return field.string();
3738
default:

0 commit comments

Comments
 (0)