Skip to content

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

:art: Add Rollup column to database table view https://github.com/siyuan-note/siyuan/issues/9958

Danield9a0d8966857
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index 805025b718..e985457823 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -245,18 +245,18 @@ func GetBlockAttributeViewKeys(blockID string) (ret []*BlockAttributeViewKeys) {
destAv, _ := av.ParseAttributeView(relKey.Relation.AvID)
if nil != destAv {
for _, bID := range relVal.Relation.BlockIDs {
+ destKey, _ := destAv.GetKey(kv.Key.Rollup.KeyID)
+ if nil == destKey {
+ continue
+ }
+
destVal := destAv.GetValue(kv.Key.Rollup.KeyID, bID)
if nil == destVal {
- destKey, _ := destAv.GetKey(kv.Key.Rollup.KeyID)
- if nil == destKey {
- continue
- }
-
destVal = treenode.GetAttributeViewDefaultValue(ast.NewNodeID(), kv.Key.Rollup.KeyID, blockID, destKey.Type)
}
- if av.KeyTypeNumber == destVal.Type {
- destVal.Number.Format = kv.Key.NumberFormat
+ if av.KeyTypeNumber == destKey.Type {
+ destVal.Number.Format = destKey.NumberFormat
destVal.Number.FormatNumber()
}
@@ -818,17 +818,17 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
}
for _, blockID := range relVal.Relation.BlockIDs {
+ destKey, _ := destAv.GetKey(rollupKey.Rollup.KeyID)
+ if nil == destKey {
+ continue
+ }
+
destVal := destAv.GetValue(rollupKey.Rollup.KeyID, blockID)
if nil == destVal {
- destKey, _ := destAv.GetKey(rollupKey.Rollup.KeyID)
- if nil == destKey {
- continue
- }
-
destVal = treenode.GetAttributeViewDefaultValue(ast.NewNodeID(), rollupKey.Rollup.KeyID, blockID, destKey.Type)
}
- if av.KeyTypeNumber == destVal.Type {
- destVal.Number.Format = rollupKey.NumberFormat
+ if av.KeyTypeNumber == destKey.Type {
+ destVal.Number.Format = destKey.NumberFormat
destVal.Number.FormatNumber()
}
diff --git a/kernel/treenode/node.go b/kernel/treenode/node.go
index 6f335c9f77..d96ec25daa 100644
--- a/kernel/treenode/node.go
+++ b/kernel/treenode/node.go
@@ -775,17 +775,21 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a
}
for _, blockID := range relVal.Relation.BlockIDs {
+ destKey, _ := destAv.GetKey(rollupKey.Rollup.KeyID)
+ if nil == destKey {
+ continue
+ }
+
destVal := destAv.GetValue(rollupKey.Rollup.KeyID, blockID)
if nil == destVal {
- destKey, _ := destAv.GetKey(rollupKey.Rollup.KeyID)
if nil == destKey {
continue
}
destVal = GetAttributeViewDefaultValue(ast.NewNodeID(), rollupKey.Rollup.KeyID, blockID, destKey.Type)
}
- if av.KeyTypeNumber == destVal.Type {
- destVal.Number.Format = rollupKey.NumberFormat
+ if av.KeyTypeNumber == destKey.Type {
+ destVal.Number.Format = destKey.NumberFormat
destVal.Number.FormatNumber()
}