From 38fce3ac3e7c02497485f0d9f9d80e9aa8a2edcb Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Wed, 5 Feb 2025 11:26:33 +0000 Subject: [PATCH] Fix searcing for a date on a string field. --- packages/backend-core/src/sql/sql.ts | 2 +- packages/server/src/api/routes/tests/search.spec.ts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/backend-core/src/sql/sql.ts b/packages/backend-core/src/sql/sql.ts index 334f1efdd4..7791ecb28b 100644 --- a/packages/backend-core/src/sql/sql.ts +++ b/packages/backend-core/src/sql/sql.ts @@ -388,7 +388,7 @@ class InternalBuilder { } } - if (typeof input === "string") { + if (typeof input === "string" && schema.type === FieldType.DATETIME) { if (isInvalidISODateString(input)) { return null } diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index c3b274d5f4..ee372914d7 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -1040,6 +1040,12 @@ if (descriptions.length) { string: { name: "FO" }, }).toContainExactly([{ name: "foo" }]) }) + + it("should not coerce string to date for string columns", async () => { + await expectQuery({ + string: { name: "2020-01-01" }, + }).toFindNothing() + }) }) describe("range", () => {