Skip to content

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

:art: The database rollup field supports using the template field https://github.com/siyuan-note/siyuan/issues/12384

Daniel04351d74bc78
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index 414384a39a..757c1ca7b2 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -1470,8 +1470,21 @@ func GetBlockAttributeViewKeys(nodeID string) (ret []*BlockAttributeViewKeys) {
destKey, _ := destAv.GetKey(kv.Key.Rollup.KeyID)
if nil != destKey {
+ var furtherCollection av.Collection
+ if av.KeyTypeTemplate == destKey.Type {
+ // 渲染目标视图,这样才能汇总渲染后的模板字段值
+ viewable := sql.RenderView(destAv, destAv.Views[0], "")
+ if nil != viewable {
+ furtherCollection = viewable.(av.Collection)
+ }
+ }
+
for _, bID := range relVal.Relation.BlockIDs {
destVal := destAv.GetValue(kv.Key.Rollup.KeyID, bID)
+ if nil != furtherCollection && av.KeyTypeTemplate == destKey.Type {
+ destVal = furtherCollection.GetValue(bID, destKey.ID)
+ }
+
if nil == destVal {
if destAv.ExistItem(bID) { // 数据库中存在项目但是字段值不存在是数据未初始化,这里补一个默认值
destVal = av.GetAttributeViewDefaultValue(ast.NewNodeID(), kv.Key.Rollup.KeyID, bID, destKey.Type)