fix: use nullish coalescing operator for setting nullable and defaultValue properties in the getSchema function instead of the ||(or) logical operator which always causes assigning true to the nullable property and ignores 0 and false default values (#5063)

This commit is contained in:
Pavlo Savenko
2021-04-14 23:18:39 +02:00
committed by GitHub
parent 8c214841bd
commit b160ae733b

View File

@@ -89,8 +89,8 @@ export async function getSchema(options?: {
sortField: collectionMeta?.sort_field || null,
fields: mapValues(schemaOverview[collection].columns, (column) => ({
field: column.column_name,
defaultValue: getDefaultValue(column) || null,
nullable: column.is_nullable || true,
defaultValue: getDefaultValue(column) ?? null,
nullable: column.is_nullable ?? true,
type: getLocalType(column) || 'alias',
precision: column.numeric_precision || null,
scale: column.numeric_scale || null,
@@ -121,8 +121,8 @@ export async function getSchema(options?: {
result.collections[field.collection].fields[field.field] = {
field: field.field,
defaultValue: existing?.defaultValue || null,
nullable: existing?.nullable || true,
defaultValue: existing?.defaultValue ?? null,
nullable: existing?.nullable ?? true,
type: existing
? getLocalType(schemaOverview[field.collection].columns[field.field], {
special: field.special ? toArray(field.special) : [],