mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-27 17:34:06 +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
|
|
@ -182,29 +182,21 @@ func (value *Value) Filter(filter *ViewFilter, attrView *AttributeView, rowID st
|
|||
return false
|
||||
}
|
||||
|
||||
for _, blockID := range relVal.Relation.BlockIDs {
|
||||
destVal := destAv.GetValue(key.Rollup.KeyID, blockID)
|
||||
if nil == destVal {
|
||||
if destAv.ExistItem(blockID) { // 数据库中存在项目但是字段值不存在是数据未初始化,这里补一个默认值
|
||||
destVal = GetAttributeViewDefaultValue(ast.NewNodeID(), key.Rollup.KeyID, blockID, destKey.Type)
|
||||
}
|
||||
if nil == destVal {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
value.Rollup.Contents = GetRollupContents(destAv, destKey, relVal.Relation.BlockIDs, nil)
|
||||
value.Rollup.RenderContents(key.Rollup.Calc, destKey)
|
||||
for _, content := range value.Rollup.Contents {
|
||||
switch filter.Operator {
|
||||
case FilterOperatorContains:
|
||||
if destVal.filter(filter.Value.Rollup.Contents[0], filter.RelativeDate, filter.RelativeDate2, filter.Operator) {
|
||||
if content.filter(filter.Value.Rollup.Contents[0], filter.RelativeDate, filter.RelativeDate2, filter.Operator) {
|
||||
return true
|
||||
}
|
||||
case FilterOperatorDoesNotContain:
|
||||
ret := destVal.filter(filter.Value.Rollup.Contents[0], filter.RelativeDate, filter.RelativeDate2, filter.Operator)
|
||||
ret := content.filter(filter.Value.Rollup.Contents[0], filter.RelativeDate, filter.RelativeDate2, filter.Operator)
|
||||
if !ret {
|
||||
return false
|
||||
}
|
||||
default:
|
||||
if destVal.filter(filter.Value.Rollup.Contents[0], filter.RelativeDate, filter.RelativeDate2, filter.Operator) {
|
||||
if content.filter(filter.Value.Rollup.Contents[0], filter.RelativeDate, filter.RelativeDate2, filter.Operator) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue