From cf9664969fddfa6de56d2b7e7854b4e5bae57372 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 21 Feb 2022 15:01:42 +0000 Subject: [PATCH 1/2] Fixing issue with formula column validation breaking row save. --- packages/builder/src/constants/backend/index.js | 5 +---- packages/server/src/api/controllers/row/utils.js | 10 ++++------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/packages/builder/src/constants/backend/index.js b/packages/builder/src/constants/backend/index.js index d07c245b21..4d6a7e3884 100644 --- a/packages/builder/src/constants/backend/index.js +++ b/packages/builder/src/constants/backend/index.js @@ -84,10 +84,7 @@ export const FIELDS = { FORMULA: { name: "Formula", type: "formula", - constraints: { - type: "string", - presence: false, - }, + constraints: {}, }, JSON: { name: "JSON", diff --git a/packages/server/src/api/controllers/row/utils.js b/packages/server/src/api/controllers/row/utils.js index 4235e70127..9ff6b085af 100644 --- a/packages/server/src/api/controllers/row/utils.js +++ b/packages/server/src/api/controllers/row/utils.js @@ -3,7 +3,6 @@ const { cloneDeep } = require("lodash/fp") const { InternalTables } = require("../../../db/utils") const userController = require("../user") const { FieldTypes } = require("../../../constants") -const { processStringSync } = require("@budibase/string-templates") const { makeExternalQuery } = require("../../../integrations/base/utils") const { getAppDB } = require("@budibase/backend-core/context") @@ -52,6 +51,10 @@ exports.validate = async ({ tableId, row, table }) => { for (let fieldName of Object.keys(table.schema)) { const constraints = cloneDeep(table.schema[fieldName].constraints) const type = table.schema[fieldName].type + // formulas shouldn't validated, data will be deleted anyway + if (type === FieldTypes.FORMULA) { + continue + } // special case for options, need to always allow unselected (null) if (type === FieldTypes.OPTIONS && constraints.inclusion) { constraints.inclusion.push(null) @@ -77,11 +80,6 @@ exports.validate = async ({ tableId, row, table }) => { } catch (err) { errors[fieldName] = [`Contains invalid JSON`] } - } else if (type === FieldTypes.FORMULA) { - res = validateJs.single( - processStringSync(table.schema[fieldName].formula, row), - constraints - ) } else { res = validateJs.single(row[fieldName], constraints) } From d673d27563b547b725d2c20a9776334668211ec2 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Mon, 21 Feb 2022 15:27:51 +0000 Subject: [PATCH 2/2] Respect custom tenantIds in run migrations endpoint --- packages/backend-core/src/migrations/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/backend-core/src/migrations/index.js b/packages/backend-core/src/migrations/index.js index 94ce6c78be..4d59f1925d 100644 --- a/packages/backend-core/src/migrations/index.js +++ b/packages/backend-core/src/migrations/index.js @@ -95,6 +95,8 @@ exports.runMigrations = async (CouchDB, migrations, options = {}) => { if (!options.tenantIds || !options.tenantIds.length) { // run for all tenants tenantIds = await getTenantIds() + } else { + tenantIds = options.tenantIds } } else { // single tenancy