Merge pull request #4605 from Budibase/fix/formula-col-validation
Removing formula column validation
This commit is contained in:
commit
1519503985
|
@ -95,6 +95,8 @@ exports.runMigrations = async (CouchDB, migrations, options = {}) => {
|
||||||
if (!options.tenantIds || !options.tenantIds.length) {
|
if (!options.tenantIds || !options.tenantIds.length) {
|
||||||
// run for all tenants
|
// run for all tenants
|
||||||
tenantIds = await getTenantIds()
|
tenantIds = await getTenantIds()
|
||||||
|
} else {
|
||||||
|
tenantIds = options.tenantIds
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// single tenancy
|
// single tenancy
|
||||||
|
|
|
@ -84,10 +84,7 @@ export const FIELDS = {
|
||||||
FORMULA: {
|
FORMULA: {
|
||||||
name: "Formula",
|
name: "Formula",
|
||||||
type: "formula",
|
type: "formula",
|
||||||
constraints: {
|
constraints: {},
|
||||||
type: "string",
|
|
||||||
presence: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
JSON: {
|
JSON: {
|
||||||
name: "JSON",
|
name: "JSON",
|
||||||
|
|
|
@ -3,7 +3,6 @@ const { cloneDeep } = require("lodash/fp")
|
||||||
const { InternalTables } = require("../../../db/utils")
|
const { InternalTables } = require("../../../db/utils")
|
||||||
const userController = require("../user")
|
const userController = require("../user")
|
||||||
const { FieldTypes } = require("../../../constants")
|
const { FieldTypes } = require("../../../constants")
|
||||||
const { processStringSync } = require("@budibase/string-templates")
|
|
||||||
const { makeExternalQuery } = require("../../../integrations/base/utils")
|
const { makeExternalQuery } = require("../../../integrations/base/utils")
|
||||||
const { getAppDB } = require("@budibase/backend-core/context")
|
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)) {
|
for (let fieldName of Object.keys(table.schema)) {
|
||||||
const constraints = cloneDeep(table.schema[fieldName].constraints)
|
const constraints = cloneDeep(table.schema[fieldName].constraints)
|
||||||
const type = table.schema[fieldName].type
|
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)
|
// special case for options, need to always allow unselected (null)
|
||||||
if (type === FieldTypes.OPTIONS && constraints.inclusion) {
|
if (type === FieldTypes.OPTIONS && constraints.inclusion) {
|
||||||
constraints.inclusion.push(null)
|
constraints.inclusion.push(null)
|
||||||
|
@ -77,11 +80,6 @@ exports.validate = async ({ tableId, row, table }) => {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
errors[fieldName] = [`Contains invalid JSON`]
|
errors[fieldName] = [`Contains invalid JSON`]
|
||||||
}
|
}
|
||||||
} else if (type === FieldTypes.FORMULA) {
|
|
||||||
res = validateJs.single(
|
|
||||||
processStringSync(table.schema[fieldName].formula, row),
|
|
||||||
constraints
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
res = validateJs.single(row[fieldName], constraints)
|
res = validateJs.single(row[fieldName], constraints)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue