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]
|
||||
// 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) {
|
||||
|
|
|
@ -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) => {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
export interface UnpublishAppResponse {
|
||||
data: {
|
||||
ok: boolean
|
||||
},
|
||||
ok: boolean,
|
||||
status: number
|
||||
data: {
|
||||
ok: boolean
|
||||
}
|
||||
ok: boolean
|
||||
status: number
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue