Fixing an issue with the fill in of test data when triggering.

This commit is contained in:
mike12345567 2020-09-22 15:25:26 +01:00
parent b9cc3ac7cc
commit dfe3257993
2 changed files with 8 additions and 5 deletions

View File

@ -10,7 +10,8 @@ const os = require("os")
const fs = require("fs") const fs = require("fs")
const Sentry = require("@sentry/node") const Sentry = require("@sentry/node")
const DEFAULT_BUCKET = "https://prod-budi-automations.s3-eu-west-1.amazonaws.com" const DEFAULT_BUCKET =
"https://prod-budi-automations.s3-eu-west-1.amazonaws.com"
const DEFAULT_DIRECTORY = ".budibase-automations" const DEFAULT_DIRECTORY = ".budibase-automations"
const AUTOMATION_MANIFEST = "manifest.json" const AUTOMATION_MANIFEST = "manifest.json"
const BUILTIN_ACTIONS = { const BUILTIN_ACTIONS = {

View File

@ -124,6 +124,7 @@ async function fillRecordOutput(automation, params) {
const db = new CouchDB(params.instanceId) const db = new CouchDB(params.instanceId)
try { try {
let model = await db.get(modelId) let model = await db.get(modelId)
let record = {}
for (let schemaKey of Object.keys(model.schema)) { for (let schemaKey of Object.keys(model.schema)) {
if (params[schemaKey] != null) { if (params[schemaKey] != null) {
continue continue
@ -131,19 +132,20 @@ async function fillRecordOutput(automation, params) {
let propSchema = model.schema[schemaKey] let propSchema = model.schema[schemaKey]
switch (propSchema.constraints.type) { switch (propSchema.constraints.type) {
case "string": case "string":
params[schemaKey] = FAKE_STRING record[schemaKey] = FAKE_STRING
break break
case "boolean": case "boolean":
params[schemaKey] = FAKE_BOOL record[schemaKey] = FAKE_BOOL
break break
case "number": case "number":
params[schemaKey] = FAKE_NUMBER record[schemaKey] = FAKE_NUMBER
break break
case "datetime": case "datetime":
params[schemaKey] = FAKE_DATETIME record[schemaKey] = FAKE_DATETIME
break break
} }
} }
params.record = record
} catch (err) { } catch (err) {
throw "Failed to find model for trigger" throw "Failed to find model for trigger"
} }