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:
commit
4ed9e7e530
|
@ -282,9 +282,11 @@ module External {
|
||||||
const linkTablePrimary = linkTable.primary[0]
|
const linkTablePrimary = linkTable.primary[0]
|
||||||
// one to many
|
// one to many
|
||||||
if (isOneSide(field)) {
|
if (isOneSide(field)) {
|
||||||
newRow[field.foreignKey || linkTablePrimary] = breakRowIdField(
|
let id = row[key][0]
|
||||||
row[key][0]
|
if (typeof row[key] === "string") {
|
||||||
)[0]
|
id = decodeURIComponent(row[key]).match(/\[(.*?)\]/)?.[1]
|
||||||
|
}
|
||||||
|
newRow[field.foreignKey || linkTablePrimary] = breakRowIdField(id)[0]
|
||||||
}
|
}
|
||||||
// many to many
|
// many to many
|
||||||
else if (field.through) {
|
else if (field.through) {
|
||||||
|
|
|
@ -30,16 +30,24 @@ export async function patch(ctx: any): Promise<any> {
|
||||||
if (body && !body._id) {
|
if (body && !body._id) {
|
||||||
return save(ctx)
|
return save(ctx)
|
||||||
}
|
}
|
||||||
const { row, table } = await quotas.addQuery(
|
try {
|
||||||
() => pickApi(tableId).patch(ctx),
|
const { row, table } = await quotas.addQuery(
|
||||||
{
|
() => pickApi(tableId).patch(ctx),
|
||||||
datasourceId: tableId,
|
{
|
||||||
|
datasourceId: tableId,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
if (!row) {
|
||||||
|
ctx.throw(404, "Row not found")
|
||||||
}
|
}
|
||||||
)
|
ctx.status = 200
|
||||||
ctx.status = 200
|
ctx.eventEmitter &&
|
||||||
ctx.eventEmitter && ctx.eventEmitter.emitRow(`row:update`, appId, row, table)
|
ctx.eventEmitter.emitRow(`row:update`, appId, row, table)
|
||||||
ctx.message = `${table.name} updated successfully.`
|
ctx.message = `${table.name} updated successfully.`
|
||||||
ctx.body = row
|
ctx.body = row
|
||||||
|
} catch (err) {
|
||||||
|
ctx.throw(400, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const save = async (ctx: any) => {
|
export const save = async (ctx: any) => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
export interface UnpublishAppResponse {
|
export interface UnpublishAppResponse {
|
||||||
data: {
|
data: {
|
||||||
ok: boolean
|
ok: boolean
|
||||||
},
|
}
|
||||||
ok: boolean,
|
ok: boolean
|
||||||
status: number
|
status: number
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue