Merge pull request #15346 from Budibase/fix/automation-query-rows-table-with-spaces
Fix query rows step when querying a table containing spaces in the name
This commit is contained in:
commit
27bfa33587
|
@ -97,7 +97,7 @@ export async function run({
|
||||||
const ctx: any = buildCtx(appId, emitter, {
|
const ctx: any = buildCtx(appId, emitter, {
|
||||||
body: inputs.row,
|
body: inputs.row,
|
||||||
params: {
|
params: {
|
||||||
tableId: inputs.row.tableId,
|
tableId: decodeURIComponent(inputs.row.tableId),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -85,7 +85,7 @@ export async function run({
|
||||||
_rev: inputs.revision,
|
_rev: inputs.revision,
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
tableId: inputs.tableId,
|
tableId: decodeURIComponent(inputs.tableId),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -122,9 +122,10 @@ export async function run({
|
||||||
sortType =
|
sortType =
|
||||||
fieldType === FieldType.NUMBER ? FieldType.NUMBER : FieldType.STRING
|
fieldType === FieldType.NUMBER ? FieldType.NUMBER : FieldType.STRING
|
||||||
}
|
}
|
||||||
|
// when passing the tableId in the Ctx it needs to be decoded
|
||||||
const ctx = buildCtx(appId, null, {
|
const ctx = buildCtx(appId, null, {
|
||||||
params: {
|
params: {
|
||||||
tableId,
|
tableId: decodeURIComponent(tableId),
|
||||||
},
|
},
|
||||||
body: {
|
body: {
|
||||||
sortType,
|
sortType,
|
||||||
|
|
|
@ -90,6 +90,8 @@ export async function run({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const tableId = inputs.row.tableId
|
const tableId = inputs.row.tableId
|
||||||
|
? decodeURIComponent(inputs.row.tableId)
|
||||||
|
: inputs.row.tableId
|
||||||
|
|
||||||
// Base update
|
// Base update
|
||||||
let rowUpdate: Record<string, any>
|
let rowUpdate: Record<string, any>
|
||||||
|
@ -157,7 +159,7 @@ export async function run({
|
||||||
},
|
},
|
||||||
params: {
|
params: {
|
||||||
rowId: inputs.rowId,
|
rowId: inputs.rowId,
|
||||||
tableId,
|
tableId: tableId,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
await rowController.patch(ctx)
|
await rowController.patch(ctx)
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { EmptyFilterOption, SortOrder, Table } from "@budibase/types"
|
||||||
import * as setup from "./utilities"
|
import * as setup from "./utilities"
|
||||||
import { createAutomationBuilder } from "./utilities/AutomationTestBuilder"
|
import { createAutomationBuilder } from "./utilities/AutomationTestBuilder"
|
||||||
import * as automation from "../index"
|
import * as automation from "../index"
|
||||||
|
import { basicTable } from "../../tests/utilities/structures"
|
||||||
|
|
||||||
const NAME = "Test"
|
const NAME = "Test"
|
||||||
|
|
||||||
|
@ -13,6 +14,7 @@ describe("Test a query step automation", () => {
|
||||||
await automation.init()
|
await automation.init()
|
||||||
await config.init()
|
await config.init()
|
||||||
table = await config.createTable()
|
table = await config.createTable()
|
||||||
|
|
||||||
const row = {
|
const row = {
|
||||||
name: NAME,
|
name: NAME,
|
||||||
description: "original description",
|
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).toBeDefined()
|
||||||
expect(result.steps[0].outputs.rows.length).toBe(2)
|
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)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue