From 9ff14d9d5c7838b33ff4e486f25759a9f5b765ac Mon Sep 17 00:00:00 2001 From: lyf-coder <58352715+lyf-coder@users.noreply.github.com> Date: Wed, 26 Oct 2022 11:57:36 +0800 Subject: [PATCH] fix(database/formula-field): when formula's field caculate result is 0 it alse will be save (#962) --- packages/core/database/src/fields/formula-field.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/database/src/fields/formula-field.ts b/packages/core/database/src/fields/formula-field.ts index 342392a0b..db56bc7f2 100644 --- a/packages/core/database/src/fields/formula-field.ts +++ b/packages/core/database/src/fields/formula-field.ts @@ -40,7 +40,7 @@ export class FormulaField extends Field { ); } } - } + }; caculateField = async (instance) => { const { expression, name } = this.options; @@ -50,10 +50,10 @@ export class FormulaField extends Field { result = math.evaluate(expression, scope); result = math.round(result, 9); } catch {} - if (result) { + if (result === 0 || result) { instance.set(name, result); } - } + }; updateFieldData = async (instance, { transaction }) => { if (this.collection.name === instance.collectionName && instance.name === this.options.name) { @@ -80,7 +80,7 @@ export class FormulaField extends Field { ); } } - } + }; bind() { super.bind();