Sfoglia il codice sorgente

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

Daniel 1 anno fa
parent
commit
421b26b49e
1 ha cambiato i file con 9 aggiunte e 0 eliminazioni
  1. 9 0
      kernel/model/attribute_view.go

+ 9 - 0
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)