From e91686c01110040771f835c48089085daf9dd7d2 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Mon, 17 Jun 2024 23:01:42 +1000 Subject: [PATCH] fix(utils/typeCast): correctly parse null date fields --- src/utils/typeCast.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/utils/typeCast.ts b/src/utils/typeCast.ts index fd255a9..9ad8fa9 100644 --- a/src/utils/typeCast.ts +++ b/src/utils/typeCast.ts @@ -22,10 +22,14 @@ export function typeCast(field: Field, next: TypeCastNext) { case 'DATETIME2': case 'TIMESTAMP': case 'TIMESTAMP2': - case 'NEWDATE': - return new Date(field.string() || '').getTime(); - case 'DATE': - return new Date(field.string() + ' 00:00:00').getTime(); + case 'NEWDATE': { + const value = field.string(); + return value ? new Date(value).getTime() : null; + } + case 'DATE': { + const value = field.string(); + return value ? new Date(value + ' 00:00:00').getTime() : null; + } case 'TINY': return field.length === 1 ? field.string() === '1' : next(); case 'BIT':