An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Incorrect results for database rollup field filtering https://github.com/siyuan-note/siyuan/issues/15608
Daniel61d0e5a3d6a7
diff --git a/kernel/av/filter.go b/kernel/av/filter.goindex 3700da5a78..3519cec3ea 100644--- a/kernel/av/filter.go+++ b/kernel/av/filter.go@@ -182,8 +182,7 @@ func (value *Value) Filter(filter *ViewFilter, attrView *AttributeView, rowID streturn false}- value.Rollup.Contents = GetRollupContents(destAv, destKey, relVal.Relation.BlockIDs, nil)- value.Rollup.RenderContents(key.Rollup.Calc, destKey)+ value.Rollup.BuildContents(destAv, destKey, relVal, key.Rollup.Calc, nil)for _, content := range value.Rollup.Contents {switch filter.Operator {case FilterOperatorContains:diff --git a/kernel/av/value.go b/kernel/av/value.goindex e4af8bd200..e3873556f1 100644--- a/kernel/av/value.go+++ b/kernel/av/value.go@@ -796,9 +796,9 @@ type ValueRollup struct {Contents []*Value `json:"contents"`}-func GetRollupContents(destAv *AttributeView, destKey *Key, relationBlockIDs []string, furtherCollection Collection) (ret []*Value) {- ret = []*Value{}- for _, blockID := range relationBlockIDs {+func (r *ValueRollup) BuildContents(destAv *AttributeView, destKey *Key, relationVal *Value, calc *RollupCalc, furtherCollection Collection) {+ r.Contents = nil+ for _, blockID := range relationVal.Relation.BlockIDs {destVal := destAv.GetValue(destKey.ID, blockID)if nil != furtherCollection && KeyTypeTemplate == destKey.Type {destVal = furtherCollection.GetValue(blockID, destKey.ID)@@ -817,12 +817,13 @@ func GetRollupContents(destAv *AttributeView, destKey *Key, relationBlockIDs []sdestVal.Number.FormatNumber()}- ret = append(ret, destVal.Clone())+ r.Contents = append(r.Contents, destVal.Clone())}- return++ r.calcContents(calc, destKey)}-func (r *ValueRollup) RenderContents(calc *RollupCalc, destKey *Key) {+func (r *ValueRollup) calcContents(calc *RollupCalc, destKey *Key) {if nil == calc {return}diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.goindex b3d71a8197..b4c582a4b9 100644--- a/kernel/model/attribute_view.go+++ b/kernel/model/attribute_view.go@@ -1534,8 +1534,7 @@ func GetBlockAttributeViewKeys(nodeID string) (ret []*BlockAttributeViewKeys) {}}- kv.Values[0].Rollup.Contents = av.GetRollupContents(destAv, destKey, relVal.Relation.BlockIDs, furtherCollection)- kv.Values[0].Rollup.RenderContents(kv.Key.Rollup.Calc, destKey)+ kv.Values[0].Rollup.BuildContents(destAv, destKey, relVal, kv.Key.Rollup.Calc, furtherCollection)}}case av.KeyTypeRelation:diff --git a/kernel/sql/av.go b/kernel/sql/av.goindex 9f3d7c0ec7..fa8265da7d 100644--- a/kernel/sql/av.go+++ b/kernel/sql/av.go@@ -394,8 +394,7 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection}}- value.Rollup.Contents = av.GetRollupContents(destAv, destKey, relVal.Relation.BlockIDs, furtherCollection)- value.Rollup.RenderContents(rollupKey.Rollup.Calc, destKey)+ value.Rollup.BuildContents(destAv, destKey, relVal, rollupKey.Rollup.Calc, furtherCollection)case av.KeyTypeRelation: // 渲染关联value.Relation.Contents = nilrelKey, _ := attrView.GetKey(value.KeyID)