From 640dd930def662fecec33f3f65afd059e6b2bdad Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 10 Jan 2025 17:45:51 +0000 Subject: [PATCH 1/6] Updating query row to correctly decode the input table Id as it will be encoded. The CTX expects this to be passed in its decoded state as Koa would do to encoded URLs. --- .../server/src/automations/steps/queryRows.ts | 3 +- .../src/automations/tests/queryRows.spec.ts | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/packages/server/src/automations/steps/queryRows.ts b/packages/server/src/automations/steps/queryRows.ts index 93ca8a3f33..4a02e80686 100644 --- a/packages/server/src/automations/steps/queryRows.ts +++ b/packages/server/src/automations/steps/queryRows.ts @@ -122,9 +122,10 @@ export async function run({ sortType = fieldType === FieldType.NUMBER ? FieldType.NUMBER : FieldType.STRING } + // when passing the tableId in the Ctx it needs to be decoded const ctx = buildCtx(appId, null, { params: { - tableId, + tableId: decodeURIComponent(tableId), }, body: { sortType, diff --git a/packages/server/src/automations/tests/queryRows.spec.ts b/packages/server/src/automations/tests/queryRows.spec.ts index 21e28673f3..6ec7b7abfb 100644 --- a/packages/server/src/automations/tests/queryRows.spec.ts +++ b/packages/server/src/automations/tests/queryRows.spec.ts @@ -2,6 +2,7 @@ import { EmptyFilterOption, SortOrder, Table } from "@budibase/types" import * as setup from "./utilities" import { createAutomationBuilder } from "./utilities/AutomationTestBuilder" import * as automation from "../index" +import { basicTable } from "../../tests/utilities/structures" const NAME = "Test" @@ -13,6 +14,7 @@ describe("Test a query step automation", () => { await automation.init() await config.init() table = await config.createTable() + const row = { name: NAME, description: "original description", @@ -153,4 +155,32 @@ describe("Test a query step automation", () => { expect(result.steps[0].outputs.rows).toBeDefined() expect(result.steps[0].outputs.rows.length).toBe(2) }) + + it("return rows when querying a table with a space in the name", async () => { + const tableWithSpaces = await config.createTable({ + ...basicTable(), + name: "table with spaces", + }) + await config.createRow({ + name: NAME, + tableId: tableWithSpaces._id, + }) + const result = await createAutomationBuilder({ + name: "Return All Test", + config, + }) + .appAction({ fields: {} }) + .queryRows( + { + tableId: tableWithSpaces._id!, + onEmptyFilter: EmptyFilterOption.RETURN_ALL, + filters: {}, + }, + { stepName: "Query table with spaces" } + ) + .run() + expect(result.steps[0].outputs.success).toBe(true) + expect(result.steps[0].outputs.rows).toBeDefined() + expect(result.steps[0].outputs.rows.length).toBe(1) + }) }) From d8abff1a7569e31204e173a8e02d66f14a0c892a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 13 Jan 2025 11:26:32 +0100 Subject: [PATCH 2/6] js to ts --- packages/client/src/api/{index.js => index.ts} | 0 packages/client/src/api/{patches.js => patches.ts} | 0 packages/client/src/components/Block.svelte | 2 +- packages/client/src/components/app/blocks/CardsBlock.svelte | 2 +- packages/client/src/components/app/deprecated/TableBlock.svelte | 2 +- packages/client/src/utils/blocks.js | 2 +- 6 files changed, 4 insertions(+), 4 deletions(-) rename packages/client/src/api/{index.js => index.ts} (100%) rename packages/client/src/api/{patches.js => patches.ts} (100%) diff --git a/packages/client/src/api/index.js b/packages/client/src/api/index.ts similarity index 100% rename from packages/client/src/api/index.js rename to packages/client/src/api/index.ts diff --git a/packages/client/src/api/patches.js b/packages/client/src/api/patches.ts similarity index 100% rename from packages/client/src/api/patches.js rename to packages/client/src/api/patches.ts diff --git a/packages/client/src/components/Block.svelte b/packages/client/src/components/Block.svelte index a739065015..48c11f152a 100644 --- a/packages/client/src/components/Block.svelte +++ b/packages/client/src/components/Block.svelte @@ -1,7 +1,7 @@