Generate option inclusion constraint (#9647)

* Fix options inclusion constrant not being generated when creating a table from file upload

* Fix 0 being treated as null when specifying min and max constraints for number fields

* Sort newly generated option field inclusion constraints

* Revert previous solution and fix problem by removing incorrect local assignment statement
This commit is contained in:
Andrew Kingston 2023-02-10 11:00:20 +00:00 committed by GitHub
parent 5a8e3298d0
commit cadadca048
2 changed files with 4 additions and 3 deletions

View File

@ -147,8 +147,8 @@
options: setting.options || [],
// Number fields
min: setting.min || null,
max: setting.max || null,
min: setting.min ?? null,
max: setting.max ?? null,
}}
{bindings}
{componentBindings}

View File

@ -104,7 +104,6 @@ export function importToRows(data: any, table: any, user: any = {}) {
const processed: any = inputProcessing(user, table, row, {
noAutoRelationships: true,
})
table = processed.table
row = processed.row
let fieldName: any
@ -113,6 +112,7 @@ export function importToRows(data: any, table: any, user: any = {}) {
// check whether the options need to be updated for inclusion as part of the data import
if (
schema.type === FieldTypes.OPTIONS &&
row[fieldName] &&
(!schema.constraints.inclusion ||
schema.constraints.inclusion.indexOf(row[fieldName]) === -1)
) {
@ -120,6 +120,7 @@ export function importToRows(data: any, table: any, user: any = {}) {
...schema.constraints.inclusion,
row[fieldName],
]
schema.constraints.inclusion.sort()
}
}