1
0
Fork 0
mirror of synced 2024-06-02 10:34:40 +12:00

Merge pull request #8428 from Budibase/bug/sev3/automation-mysql-id-relationship-uri-decode

Handle mysql id decoding in relationships for automations
This commit is contained in:
melohagan 2022-11-01 12:52:50 +00:00 committed by GitHub
commit 7bca55bbb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 17 deletions

View file

@ -282,9 +282,11 @@ module External {
const linkTablePrimary = linkTable.primary[0]
// one to many
if (isOneSide(field)) {
newRow[field.foreignKey || linkTablePrimary] = breakRowIdField(
row[key][0]
)[0]
let id = row[key][0]
if (typeof row[key] === "string") {
id = decodeURIComponent(row[key]).match(/\[(.*?)\]/)?.[1]
}
newRow[field.foreignKey || linkTablePrimary] = breakRowIdField(id)[0]
}
// many to many
else if (field.through) {

View file

@ -30,16 +30,24 @@ export async function patch(ctx: any): Promise<any> {
if (body && !body._id) {
return save(ctx)
}
const { row, table } = await quotas.addQuery(
() => pickApi(tableId).patch(ctx),
{
datasourceId: tableId,
try {
const { row, table } = await quotas.addQuery(
() => pickApi(tableId).patch(ctx),
{
datasourceId: tableId,
}
)
if (!row) {
ctx.throw(404, "Row not found")
}
)
ctx.status = 200
ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:update`, appId, row, table)
ctx.message = `${table.name} updated successfully.`
ctx.body = row
ctx.status = 200
ctx.eventEmitter &&
ctx.eventEmitter.emitRow(`row:update`, appId, row, table)
ctx.message = `${table.name} updated successfully.`
ctx.body = row
} catch (err) {
ctx.throw(400, err)
}
}
export const save = async (ctx: any) => {

View file

@ -1,7 +1,7 @@
export interface UnpublishAppResponse {
data: {
ok: boolean
},
ok: boolean,
status: number
data: {
ok: boolean
}
ok: boolean
status: number
}