From b160ae733b22084ba89de159ffbb17b72fa19e6d Mon Sep 17 00:00:00 2001 From: Pavlo Savenko <36743320+pavlo-savenko@users.noreply.github.com> Date: Wed, 14 Apr 2021 23:18:39 +0200 Subject: [PATCH] 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) --- api/src/utils/get-schema.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/src/utils/get-schema.ts b/api/src/utils/get-schema.ts index 5d5ce92eec..4ef2e0c70a 100644 --- a/api/src/utils/get-schema.ts +++ b/api/src/utils/get-schema.ts @@ -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) : [],