mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🐛 Incorrect results for database rollup field filtering https://github.com/siyuan-note/siyuan/issues/15608
This commit is contained in:
parent
312be8a019
commit
61d0e5a3d6
4 changed files with 10 additions and 12 deletions
|
|
@ -182,8 +182,7 @@ func (value *Value) Filter(filter *ViewFilter, attrView *AttributeView, rowID st
|
|||
return 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:
|
||||
|
|
|
|||
|
|
@ -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 []s
|
|||
destVal.Number.FormatNumber()
|
||||
}
|
||||
|
||||
ret = append(ret, destVal.Clone())
|
||||
}
|
||||
return
|
||||
r.Contents = append(r.Contents, destVal.Clone())
|
||||
}
|
||||
|
||||
func (r *ValueRollup) RenderContents(calc *RollupCalc, destKey *Key) {
|
||||
r.calcContents(calc, destKey)
|
||||
}
|
||||
|
||||
func (r *ValueRollup) calcContents(calc *RollupCalc, destKey *Key) {
|
||||
if nil == calc {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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 = nil
|
||||
relKey, _ := attrView.GetKey(value.KeyID)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue