From 3247e13a32c4ca3b4d09928630074231a4f35211 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 22 Jul 2024 15:17:42 +0100 Subject: [PATCH] Test case. --- .../src/api/routes/tests/search.spec.ts | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index 68f61ba28d..ee804c9914 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -6,9 +6,11 @@ import { } from "../../../integrations/tests/utils" import { db as dbCore, + context, MAX_VALID_DATE, MIN_VALID_DATE, utils, + SQLITE_DESIGN_DOC_ID, } from "@budibase/backend-core" import * as setup from "./utilities" @@ -2524,4 +2526,38 @@ describe.each([ }).toContainExactly([{ [" name"]: "foo" }]) }) }) + + isSqs && + describe("duplicate columns", () => { + beforeAll(async () => { + table = await createTable({ + name: { + name: "name", + type: FieldType.STRING, + }, + }) + await context.doInAppContext(config.appId!, async () => { + const db = context.getAppDB() + const tableDoc = await db.get(table._id!) + tableDoc.schema.Name = { + name: "Name", + type: FieldType.STRING, + } + try { + // remove the SQLite definitions so that they can be rebuilt as part of the search + const sqliteDoc = await db.get(SQLITE_DESIGN_DOC_ID) + await db.remove(sqliteDoc) + } catch (err) { + // no-op + } + }) + await createRows([{ name: "foo", Name: "bar" }]) + }) + + it("should handle invalid duplicate column names", async () => { + await expectSearch({ + query: {}, + }).toContainExactly([{ name: "foo" }]) + }) + }) })