From fcf67f729743db26647a15bb7900c101afaf2f3c Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 21 Jun 2024 19:29:30 +0100 Subject: [PATCH] Fixing an issue raised by Poirazis around empty relationships coming back as related to themselves. --- .../server/src/api/controllers/row/utils/basic.ts | 2 +- packages/server/src/api/routes/tests/search.spec.ts | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/packages/server/src/api/controllers/row/utils/basic.ts b/packages/server/src/api/controllers/row/utils/basic.ts index afb98d0255..bca2494ac3 100644 --- a/packages/server/src/api/controllers/row/utils/basic.ts +++ b/packages/server/src/api/controllers/row/utils/basic.ts @@ -99,7 +99,7 @@ export function basicProcessing({ row, tableName: table._id!, fieldName: internalColumn, - isLinked: false, + isLinked, }) } } diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index c92738479f..b9c25b98aa 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -1950,10 +1950,7 @@ describe.each([ }) }) - // This will never work for Lucene. !isLucene && - // It also can't work for in-memory searching because the related table name - // isn't available. !isInMemory && describe("relations", () => { let productCategoryTable: Table, productCatRows: Row[] @@ -1996,6 +1993,10 @@ describe.each([ name: "bar", productCat: [productCatRows[1]._id], }), + config.api.row.save(table._id!, { + name: "baz", + productCat: [], + }), ]) }) @@ -2014,6 +2015,12 @@ describe.each([ { name: "foo", productCat: [{ _id: productCatRows[0]._id }] }, ]) }) + + it("shouldn't return any relationship for last row", async () => { + await expectQuery({ + equal: { ["name"]: "baz" }, + }).toContainExactly([{ name: "baz", productCat: undefined }]) + }) }) // lucene can't count the total rows