1
0
Fork 0
mirror of synced 2024-06-02 18:44:54 +12:00

Fixing some issues I found with testing automations against external tables.

This commit is contained in:
mike12345567 2021-06-18 18:05:31 +01:00
parent 3475273f80
commit 3f1b95218e
3 changed files with 12 additions and 4 deletions

View file

@ -8,7 +8,7 @@
// and this is the final url (i.e. no selectedTable)
if (
!$leftover &&
$tables.list.length > 0(!$tables.selected || !$tables.selected._id)
$tables.list.length > (!$tables.selected || !$tables.selected._id)
) {
$goto(`./${$tables.list[0]._id}`)
}

View file

@ -17,7 +17,7 @@ function generateSaveValidator() {
return joiValidator.body(Joi.object({
_id: Joi.string(),
_rev: Joi.string(),
type: Joi.string().valid("table"),
type: Joi.string().valid("table", "internal", "external"),
primaryDisplay: Joi.string(),
schema: Joi.object().required(),
name: Joi.string().required(),

View file

@ -8,6 +8,8 @@ const { getAutomationParams } = require("../db/utils")
const { coerce } = require("../utilities/rowProcessor")
const { utils } = require("@budibase/auth/redis")
const { JobQueues } = require("../constants")
const { isExternalTable, breakExternalTableId } = require("../integrations/utils")
const { getExternalTable } = require("../api/controllers/table/utils")
const { opts } = utils.getRedisOptions()
let automationQueue = new Queue(JobQueues.AUTOMATIONS, { redis: opts })
@ -288,9 +290,15 @@ emitter.on("row:delete", async function (event) {
async function fillRowOutput(automation, params) {
let triggerSchema = automation.definition.trigger
let tableId = triggerSchema.inputs.tableId
const db = new CouchDB(params.appId)
try {
let table = await db.get(tableId)
let table
if (!isExternalTable(tableId)) {
const db = new CouchDB(params.appId)
table = await db.get(tableId)
} else {
const { datasourceId, tableName } = breakExternalTableId(tableId)
table = await getExternalTable(params.appId, datasourceId, tableName)
}
let row = {}
for (let schemaKey of Object.keys(table.schema)) {
const paramValue = params[schemaKey]