mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 00:38:49 +01:00
🐛 Incorrect results for database rollup field filtering https://github.com/siyuan-note/siyuan/issues/15608
This commit is contained in:
parent
fa7ec5ab95
commit
312be8a019
4 changed files with 34 additions and 61 deletions
|
|
@ -796,6 +796,32 @@ 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 {
|
||||
destVal := destAv.GetValue(destKey.ID, blockID)
|
||||
if nil != furtherCollection && KeyTypeTemplate == destKey.Type {
|
||||
destVal = furtherCollection.GetValue(blockID, destKey.ID)
|
||||
}
|
||||
|
||||
if nil == destVal {
|
||||
if destAv.ExistItem(blockID) { // 数据库中存在项目但是字段值不存在是数据未初始化,这里补一个默认值
|
||||
destVal = GetAttributeViewDefaultValue(ast.NewNodeID(), destKey.ID, blockID, destKey.Type)
|
||||
}
|
||||
if nil == destVal {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if KeyTypeNumber == destKey.Type {
|
||||
destVal.Number.Format = destKey.NumberFormat
|
||||
destVal.Number.FormatNumber()
|
||||
}
|
||||
|
||||
ret = append(ret, destVal.Clone())
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (r *ValueRollup) RenderContents(calc *RollupCalc, destKey *Key) {
|
||||
if nil == calc {
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue