From bab2a294985d822cc433f47a9d0955b192c7498f Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sat, 30 Dec 2023 17:15:50 +0800 Subject: [PATCH] :art: Improve adding rows of the filtered database table view https://github.com/siyuan-note/siyuan/issues/10025 --- kernel/model/attribute_view.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go index f82705c70..0f907a566 100644 --- a/kernel/model/attribute_view.go +++ b/kernel/model/attribute_view.go @@ -901,13 +901,19 @@ func updateAttributeViewColRollup(operation *Operation) (err error) { KeyID: operation.KeyID, } - data := operation.Data.(map[string]interface{}) - calcData, err := gulu.JSON.MarshalJSON(data["calc"]) - if nil != err { - return - } - if err = gulu.JSON.UnmarshalJSON(calcData, &rollUpKey.Rollup.Calc); nil != err { - return + if nil != operation.Data { + data := operation.Data.(map[string]interface{}) + if nil != data["calc"] { + calcData, jsonErr := gulu.JSON.MarshalJSON(data["calc"]) + if nil != jsonErr { + err = jsonErr + return + } + if jsonErr = gulu.JSON.UnmarshalJSON(calcData, &rollUpKey.Rollup.Calc); nil != jsonErr { + err = jsonErr + return + } + } } err = av.SaveAttributeView(attrView)