Skip to content

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

:art: Improve copying database block https://github.com/siyuan-note/siyuan/issues/11460 断开双向关联 https://github.com/siyuan-note/siyuan/issues/11548

Daniel421b26b49ec6
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index eff63e7291..860bfafcf3 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -68,6 +68,15 @@ func DuplicateDatabaseBlock(avID string) (newAvID, newBlockID string, err error)
}
newAv.Name = oldAv.Name + " (Duplicated " + time.Now().Format("2006-01-02 15:04:05") + ")"
+
+ for _, keyValues := range newAv.KeyValues {
+ if nil != keyValues.Key.Relation && keyValues.Key.Relation.IsTwoWay {
+ // 断开双向关联
+ keyValues.Key.Relation.IsTwoWay = false
+ keyValues.Key.Relation.BackKeyID = ""
+ }
+ }
+
data, err = gulu.JSON.MarshalJSON(newAv)
if nil != err {
logging.LogErrorf("marshal attribute view [%s] failed: %s", newAvID, err)