Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Improve av

Daniel7b3ac79d78bc
diff --git a/kernel/sql/av.go b/kernel/sql/av.go
index 26af3224bd..53bf77ee6b 100644
--- a/kernel/sql/av.go
+++ b/kernel/sql/av.go
@@ -340,7 +340,7 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection
}
}
}
- case av.KeyTypeRollup: // 渲染汇总列
+ case av.KeyTypeRollup: // 渲染汇总字段
rollupKey, _ := attrView.GetKey(value.KeyID)
if nil == rollupKey || nil == rollupKey.Rollup {
break
@@ -402,12 +402,12 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection
value.Rollup.RenderContents(rollupKey.Rollup.Calc, destKey)
- // 将汇总列的值保存到 rowsValues 中,后续渲染模板列的时候会用到,下同
+ // 将汇总字段的值保存到 rowsValues 中,后续渲染模板字段的时候会用到,下同
// Database table view template columns support reading relation, rollup, created and updated columns https://github.com/siyuan-note/siyuan/issues/10442
keyValues := items[itemID]
keyValues = append(keyValues, &av.KeyValues{Key: rollupKey, Values: []*av.Value{{ID: value.ID, KeyID: rollupKey.ID, BlockID: itemID, Type: av.KeyTypeRollup, Rollup: value.Rollup}}})
items[itemID] = keyValues
- case av.KeyTypeRelation: // 渲染关联列
+ case av.KeyTypeRelation: // 渲染关联字段
relKey, _ := attrView.GetKey(value.KeyID)
if nil != relKey && nil != relKey.Relation {
destAv := avCache[relKey.Relation.AvID]
@@ -480,6 +480,17 @@ func fillAttributeViewAutoGeneratedValues(attrView *av.AttributeView, collection
}
func fillAttributeViewTemplateValues(attrView *av.AttributeView, collection av.Collection, ials map[string]map[string]string, items map[string][]*av.KeyValues) (err error) {
+ existTemplateField := false
+ for _, kVals := range attrView.KeyValues {
+ if av.KeyTypeTemplate == kVals.Key.Type {
+ existTemplateField = true
+ break
+ }
+ }
+ if !existTemplateField {
+ return
+ }
+
var renderTemplateErr error
for _, item := range collection.GetItems() {
for _, value := range item.GetValues() {