Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve database table view in super block Fix https://github.com/siyuan-note/siyuan/issues/9620

Daniel7be06ed95561
diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go
index 460c23efc2..cc7fada576 100644
--- a/kernel/model/transaction.go
+++ b/kernel/model/transaction.go
@@ -714,13 +714,24 @@ func (tx *Transaction) doDelete(operation *Operation) (ret *TxErr) {
}
syncDelete2AttributeView(node)
- if ast.NodeAttributeView == node.Type {
- avID := node.AttributeViewID
- av.RemoveBlockRel(avID, node.ID)
- }
+ removeAvBlockRel(node)
return
}
+func removeAvBlockRel(node *ast.Node) {
+ ast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus {
+ if !entering {
+ return ast.WalkContinue
+ }
+
+ if ast.NodeAttributeView == n.Type {
+ avID := n.AttributeViewID
+ av.RemoveBlockRel(avID, n.ID)
+ }
+ return ast.WalkContinue
+ })
+}
+
func syncDelete2AttributeView(node *ast.Node) {
avs := node.IALAttr(av.NodeAttrNameAvs)
if "" == avs {
@@ -904,10 +915,7 @@ func (tx *Transaction) doInsert(operation *Operation) (ret *TxErr) {
return &TxErr{code: TxErrCodeWriteTree, msg: err.Error(), id: block.ID}
}
- if ast.NodeAttributeView == insertedNode.Type {
- avID := insertedNode.AttributeViewID
- av.UpsertBlockRel(avID, insertedNode.ID)
- }
+ upsertAvBlockRel(insertedNode)
operation.ID = insertedNode.ID
operation.ParentID = insertedNode.Parent.ID
@@ -998,13 +1006,24 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {
return &TxErr{code: TxErrCodeWriteTree, msg: err.Error(), id: id}
}
- if ast.NodeAttributeView == updatedNode.Type {
- avID := updatedNode.AttributeViewID
- av.UpsertBlockRel(avID, updatedNode.ID)
- }
+ upsertAvBlockRel(updatedNode)
return
}
+func upsertAvBlockRel(node *ast.Node) {
+ ast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus {
+ if !entering {
+ return ast.WalkContinue
+ }
+
+ if ast.NodeAttributeView == n.Type {
+ avID := n.AttributeViewID
+ av.UpsertBlockRel(avID, n.ID)
+ }
+ return ast.WalkContinue
+ })
+}
+
func (tx *Transaction) doUpdateUpdated(operation *Operation) (ret *TxErr) {
id := operation.ID
tree, err := tx.loadTree(id)