mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-19 02:21:38 +08:00
🎨 Add Relation column to database table view https://github.com/siyuan-note/siyuan/issues/9888
This commit is contained in:
parent
67af0fbe9a
commit
4adff64ddc
@ -806,17 +806,21 @@ func updateAttributeViewColRelation(operation *Operation) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, keyValues := range srcAv.KeyValues {
|
for _, keyValues := range srcAv.KeyValues {
|
||||||
if keyValues.Key.ID == operation.KeyID {
|
if keyValues.Key.ID != operation.KeyID {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
srcRel := keyValues.Key.Relation
|
||||||
// 已经设置过双向关联的话需要先断开双向关联
|
// 已经设置过双向关联的话需要先断开双向关联
|
||||||
if nil != keyValues.Key.Relation && keyValues.Key.Relation.IsTwoWay {
|
if nil != srcRel && srcRel.IsTwoWay {
|
||||||
oldDestAv, parseErr := av.ParseAttributeView(keyValues.Key.Relation.AvID)
|
oldDestAv, _ := av.ParseAttributeView(srcRel.AvID)
|
||||||
if nil == parseErr {
|
if nil != oldDestAv {
|
||||||
isOldSameAv := oldDestAv.ID == destAv.ID
|
isOldSameAv := oldDestAv.ID == destAv.ID
|
||||||
if isOldSameAv {
|
if isOldSameAv {
|
||||||
oldDestAv = destAv
|
oldDestAv = destAv
|
||||||
}
|
}
|
||||||
|
|
||||||
oldDestKey, _ := oldDestAv.GetKey(keyValues.Key.Relation.BackKeyID)
|
oldDestKey, _ := oldDestAv.GetKey(srcRel.BackKeyID)
|
||||||
if nil != oldDestKey && nil != oldDestKey.Relation && oldDestKey.Relation.AvID == srcAv.ID && oldDestKey.Relation.IsTwoWay {
|
if nil != oldDestKey && nil != oldDestKey.Relation && oldDestKey.Relation.AvID == srcAv.ID && oldDestKey.Relation.IsTwoWay {
|
||||||
oldDestKey.Relation.IsTwoWay = false
|
oldDestKey.Relation.IsTwoWay = false
|
||||||
oldDestKey.Relation.BackKeyID = ""
|
oldDestKey.Relation.BackKeyID = ""
|
||||||
@ -831,14 +835,19 @@ func updateAttributeViewColRelation(operation *Operation) (err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
keyValues.Key.Relation = &av.Relation{
|
srcRel = &av.Relation{
|
||||||
AvID: operation.ID,
|
AvID: operation.ID,
|
||||||
IsTwoWay: operation.IsTwoWay,
|
IsTwoWay: operation.IsTwoWay,
|
||||||
BackKeyID: operation.BackRelationKeyID,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if operation.IsTwoWay {
|
||||||
|
srcRel.BackKeyID = operation.BackRelationKeyID
|
||||||
|
} else {
|
||||||
|
srcRel.BackKeyID = ""
|
||||||
|
}
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
destAdded := false
|
destAdded := false
|
||||||
backRelKey, _ := destAv.GetKey(operation.BackRelationKeyID)
|
backRelKey, _ := destAv.GetKey(operation.BackRelationKeyID)
|
||||||
|
Loading…
Reference in New Issue
Block a user