🐛 Database filtering for specific dates not working Fix https://github.com/siyuan-note/siyuan/issues/10518

This commit is contained in:
Daniel 2024-03-08 00:12:10 +08:00
parent 57293203ee
commit f61a6131fe
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -24,6 +24,7 @@ import (
"path/filepath"
"regexp"
"strconv"
"strings"
"time"
"github.com/88250/gulu"
@ -231,8 +232,17 @@ func ParseAttributeView(avID string) (ret *AttributeView, err error) {
ret = &AttributeView{}
if err = gulu.JSON.UnmarshalJSON(data, ret); nil != err {
logging.LogErrorf("unmarshal attribute view [%s] failed: %s", avID, err)
return
if strings.Contains(err.Error(), "cannot unmarshal string into Go struct field ValueRelation.keyValues.values.relation.contents of type av.Value") {
// v3.0.3 兼容之前旧版本,通过正则将 "relation":{"contents":[".*"],"blockIDs": 替换为 "relation":{"contents":null,"blockIDs":
data = regexp.MustCompile(`"relation":{"contents":\[".*"\],"blockIDs":`).ReplaceAll(data, []byte(`"relation":{"contents":null,"blockIDs":`))
if err = gulu.JSON.UnmarshalJSON(data, ret); nil != err {
logging.LogErrorf("unmarshal attribute view [%s] failed: %s", avID, err)
return
}
} else {
logging.LogErrorf("unmarshal attribute view [%s] failed: %s", avID, err)
return
}
}
return
}
@ -340,7 +350,7 @@ func SaveAttributeView(av *AttributeView) (err error) {
// 补全过滤器 Value
for _, view := range av.Views {
if nil == view.Table {
if nil != view.Table {
for _, f := range view.Table.Filters {
if nil != f.Value {
continue