From 3b1c8050e7537c3ed8bed86450c742e434e2fea6 Mon Sep 17 00:00:00 2001 From: Stefan Parker Date: Fri, 27 Dec 2024 00:49:21 -0500 Subject: [PATCH] Handle null/undefined date values (#1866) Fixes #1860 --- ts/src/schema/field.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ts/src/schema/field.ts b/ts/src/schema/field.ts index 646a27c1e..e37b19d1d 100644 --- a/ts/src/schema/field.ts +++ b/ts/src/schema/field.ts @@ -1,9 +1,12 @@ import { DateTime } from "luxon"; import { isPromise } from "util/types"; import { validate } from "uuid"; -import { Ent, WriteOperation } from "../core/base"; import { Builder } from "../action/action"; +import { Ent, WriteOperation } from "../core/base"; import DB, { Dialect } from "../core/db"; +import { __getGlobalSchemaField } from "../core/global_schema"; +import { log } from "../core/logger"; +import { toFieldName } from "../names/names"; import { DBType, Field, @@ -13,9 +16,6 @@ import { PolymorphicOptions, Type, } from "./schema"; -import { __getGlobalSchemaField } from "../core/global_schema"; -import { log } from "../core/logger"; -import { toFieldName } from "../names/names"; export abstract class BaseField { name: string; @@ -584,7 +584,7 @@ export class DateField extends BaseField implements Field { type: Type = { dbType: DBType.Date }; format(val: any): any { - if (typeof val === "string") { + if (typeof val === "string" || val === null || val === undefined) { return val; } val = new Date(val);