Skip to content

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

:art: Add Relation and Rollup column to database table view https://github.com/siyuan-note/siyuan/issues/9888

Danieldffcc2865bcc
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index 8df88ef346..1cc37e236b 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -785,17 +785,16 @@ func updateAttributeViewColRelation(operation *Operation) (err error) {
}
destAdded := false
- for _, keyValues := range destAv.KeyValues {
- if keyValues.Key.ID == operation.BackRelationKeyID {
- keyValues.Key.Relation = &av.Relation{
- AvID: operation.AvID,
- IsTwoWay: operation.IsTwoWay,
- BackKeyID: operation.KeyID,
- }
- destAdded = true
- break
+ backRelKey, _ := destAv.GetKey(operation.BackRelationKeyID)
+ if nil != backRelKey {
+ backRelKey.Relation = &av.Relation{
+ AvID: operation.AvID,
+ IsTwoWay: operation.IsTwoWay,
+ BackKeyID: operation.KeyID,
}
+ destAdded = true
}
+
if !destAdded {
destAv.KeyValues = append(destAv.KeyValues, &av.KeyValues{
Key: &av.Key{
@@ -813,6 +812,7 @@ func updateAttributeViewColRelation(operation *Operation) (err error) {
}
if !isSameAv {
err = av.SaveAttributeView(destAv)
+ util.BroadcastByType("protyle", "refreshAttributeView", 0, "", map[string]interface{}{"id": destAv.ID})
}
return
}