fix(utils/typeCast): correctly parse null date fields

This commit is contained in:
Linden committed 2024-06-17 23:01:42 +10:00
1 parent 5697326ae9
commit e91686c011
1 file changed
+8 -4
+8 -4
View File
@@ -22,10 +22,14 @@ export function typeCast(field: Field, next: TypeCastNext) {
case 'DATETIME2': case 'DATETIME2':
case 'TIMESTAMP': case 'TIMESTAMP':
case 'TIMESTAMP2': case 'TIMESTAMP2':
case 'NEWDATE': case 'NEWDATE': {
return new Date(field.string() || '').getTime(); const value = field.string();
case 'DATE': return value ? new Date(value).getTime() : null;
return new Date(field.string() + ' 00:00:00').getTime(); }
case 'DATE': {
const value = field.string();
return value ? new Date(value + ' 00:00:00').getTime() : null;
}
case 'TINY': case 'TINY':
return field.length === 1 ? field.string() === '1' : next(); return field.length === 1 ? field.string() === '1' : next();
case 'BIT': case 'BIT':