From 356b6748c926af943e3ee3e8e1f0b9f1fc9ebc1d Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sun, 24 Dec 2023 09:50:42 +0800 Subject: [PATCH] :art: Add Relation column to database table view https://github.com/siyuan-note/siyuan/issues/9888 --- kernel/model/attribute_view.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go index d0d29880d..d8cff2603 100644 --- a/kernel/model/attribute_view.go +++ b/kernel/model/attribute_view.go @@ -852,19 +852,21 @@ func updateAttributeViewColRelation(operation *Operation) (err error) { } if !destAdded { - destAv.KeyValues = append(destAv.KeyValues, &av.KeyValues{ - Key: &av.Key{ - ID: operation.BackRelationKeyID, - Name: operation.Name, - Type: av.KeyTypeRelation, - Relation: &av.Relation{AvID: operation.AvID, IsTwoWay: operation.IsTwoWay, BackKeyID: operation.KeyID}, - }, - }) + if operation.IsTwoWay { + destAv.KeyValues = append(destAv.KeyValues, &av.KeyValues{ + Key: &av.Key{ + ID: operation.BackRelationKeyID, + Name: operation.Name, + Type: av.KeyTypeRelation, + Relation: &av.Relation{AvID: operation.AvID, IsTwoWay: operation.IsTwoWay, BackKeyID: operation.KeyID}, + }, + }) - for _, v := range destAv.Views { - switch v.LayoutType { - case av.LayoutTypeTable: - v.Table.Columns = append(v.Table.Columns, &av.ViewTableColumn{ID: operation.KeyID}) + for _, v := range destAv.Views { + switch v.LayoutType { + case av.LayoutTypeTable: + v.Table.Columns = append(v.Table.Columns, &av.ViewTableColumn{ID: operation.KeyID}) + } } } }