Merge pull request #13717 from Budibase/fix/13715
Disallowing arrays for single types (attachment and user)
This commit is contained in:
commit
bb8fc45ffb
|
@ -14,7 +14,7 @@ import { makeExternalQuery } from "../../../integrations/base/query"
|
|||
import { Format } from "../../../api/controllers/view/exporters"
|
||||
import sdk from "../.."
|
||||
import { isRelationshipColumn } from "../../../db/utils"
|
||||
import { SqlClient, isSQL } from "../../../integrations/utils"
|
||||
import { isSQL, SqlClient } from "../../../integrations/utils"
|
||||
|
||||
const SQL_CLIENT_SOURCE_MAP: Record<SourceName, SqlClient | undefined> = {
|
||||
[SourceName.POSTGRES]: SqlClient.POSTGRES,
|
||||
|
@ -144,6 +144,10 @@ export async function validate({
|
|||
throw new Error("Unable to fetch table for validation")
|
||||
}
|
||||
const errors: Record<string, any> = {}
|
||||
const disallowArrayTypes = [
|
||||
FieldType.ATTACHMENT_SINGLE,
|
||||
FieldType.BB_REFERENCE_SINGLE,
|
||||
]
|
||||
for (let fieldName of Object.keys(fetchedTable.schema)) {
|
||||
const column = fetchedTable.schema[fieldName]
|
||||
const constraints = cloneDeep(column.constraints)
|
||||
|
@ -160,6 +164,10 @@ export async function validate({
|
|||
if (type === FieldType.OPTIONS && constraints?.inclusion) {
|
||||
constraints.inclusion.push(null as any, "")
|
||||
}
|
||||
|
||||
if (disallowArrayTypes.includes(type) && Array.isArray(row[fieldName])) {
|
||||
errors[fieldName] = `Cannot accept arrays`
|
||||
}
|
||||
let res
|
||||
|
||||
// Validate.js doesn't seem to handle array
|
||||
|
|
Loading…
Reference in New Issue