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

Commit e91686c

Browse files
committed
fix(utils/typeCast): correctly parse null date fields
1 parent 5697326 commit e91686c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/utils/typeCast.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,14 @@ export function typeCast(field: Field, next: TypeCastNext) {
2222
case 'DATETIME2':
2323
case 'TIMESTAMP':
2424
case 'TIMESTAMP2':
25-
case 'NEWDATE':
26-
return new Date(field.string() || '').getTime();
27-
case 'DATE':
28-
return new Date(field.string() + ' 00:00:00').getTime();
25+
case 'NEWDATE': {
26+
const value = field.string();
27+
return value ? new Date(value).getTime() : null;
28+
}
29+
case 'DATE': {
30+
const value = field.string();
31+
return value ? new Date(value + ' 00:00:00').getTime() : null;
32+
}
2933
case 'TINY':
3034
return field.length === 1 ? field.string() === '1' : next();
3135
case 'BIT':

0 commit comments

Comments
 (0)