From 421b26b49ec66f5a79f2e19daf72ad9a36fbd9e4 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Mon, 27 May 2024 16:52:13 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20Improve=20copying=20database=20block=20?= =?UTF-8?q?https://github.com/siyuan-note/siyuan/issues/11460=20=E6=96=AD?= =?UTF-8?q?=E5=BC=80=E5=8F=8C=E5=90=91=E5=85=B3=E8=81=94=20https://github.?= =?UTF-8?q?com/siyuan-note/siyuan/issues/11548?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/attribute_view.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go index eff63e729..860bfafcf 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)