From c5a25fe88f1497f55d5bb4979093c831c572c0e1 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Tue, 3 Oct 2023 08:52:33 +0800 Subject: [PATCH] :bug: Database render deleted block https://ld246.com/article/1695790906050/comment/1696234209062?r=88250#comments --- kernel/model/attribute_view.go | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go index e29022720..507ca8e21 100644 --- a/kernel/model/attribute_view.go +++ b/kernel/model/attribute_view.go @@ -219,8 +219,19 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a // 过滤掉不存在的行 var notFound []string - for blockID, v := range rows { - if v[0].IsDetached { + for blockID, values := range rows { + blockValue := getBlockValue(values) + if nil == blockValue { + notFound = append(notFound, blockID) + continue + } + + if blockValue.IsDetached { + continue + } + + if nil != blockValue.Block && "" == blockValue.Block.ID { + notFound = append(notFound, blockID) continue } @@ -291,6 +302,16 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a return } +func getBlockValue(values []*av.Value) (ret *av.Value) { + for _, v := range values { + if av.KeyTypeBlock == v.Type { + ret = v + break + } + } + return +} + func (tx *Transaction) doSetAttrViewName(operation *Operation) (ret *TxErr) { err := setAttributeViewName(operation) if nil != err {