mirror of
https://github.com/darksaid98/oxmysql.git
synced 2026-12-04 14:38:50 +00:00
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.
This commit is contained in:
1 parent
c9e402ccdc
commit
9ef9b0d8c9
1 file changed
+5
-4
@@ -18,10 +18,9 @@ export const typeCast = (field: Field, next: () => void) => {
|
|||||||
case 'TIMESTAMP':
|
case 'TIMESTAMP':
|
||||||
case 'TIMESTAMP2':
|
case 'TIMESTAMP2':
|
||||||
case 'NEWDATE':
|
case 'NEWDATE':
|
||||||
|
return new Date(field.string()).getTime();
|
||||||
case 'DATE':
|
case 'DATE':
|
||||||
return field.type === 'DATE'
|
return new Date(field.string() + ' 00:00:00').getTime();
|
||||||
? new Date(field.string() + ' 00:00:00').getTime()
|
|
||||||
: new Date(field.string()).getTime();
|
|
||||||
case 'TINY':
|
case 'TINY':
|
||||||
return field.length === 1 ? field.string() === '1' : next();
|
return field.length === 1 ? field.string() === '1' : next();
|
||||||
case 'BIT':
|
case 'BIT':
|
||||||
@@ -31,7 +30,9 @@ export const typeCast = (field: Field, next: () => void) => {
|
|||||||
case 'LONG_BLOB':
|
case 'LONG_BLOB':
|
||||||
case 'BLOB':
|
case 'BLOB':
|
||||||
if (field.charset === BINARY_CHARSET) {
|
if (field.charset === BINARY_CHARSET) {
|
||||||
return [...field.buffer()];
|
const value = field.buffer();
|
||||||
|
if (value === null) return [value]
|
||||||
|
return [...value];
|
||||||
}
|
}
|
||||||
return field.string();
|
return field.string();
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in new issue
Block a user