Skip to content

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

:art: Improve database field default filling https://github.com/siyuan-note/siyuan/issues/15549

Daniel8ba02f517c4d
diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go
index 46cd6f2fc3..3ea85faa59 100644
--- a/kernel/model/attribute_view.go
+++ b/kernel/model/attribute_view.go
@@ -2961,12 +2961,10 @@ func fillDefaultValue(attrView *av.AttributeView, view, groupView *av.View, prev
continue
}
- if (av.KeyTypeSelect == newValue.Type || av.KeyTypeMSelect == newValue.Type) && 1 > len(newValue.MSelect) {
+ if (av.KeyTypeSelect == newValue.Type || av.KeyTypeMSelect == newValue.Type) && 1 > len(newValue.MSelect) && groupValueDefault != groupView.GetGroupValue() {
// 单选或多选类型的值可能需要从分组条件中获取默认值
- if groupValueDefault != groupView.GetGroupValue() {
- if opt := keyValues.Key.GetOption(groupView.GetGroupValue()); nil != opt {
- newValue.MSelect = append(newValue.MSelect, &av.ValueSelect{Content: opt.Name, Color: opt.Color})
- }
+ if opt := keyValues.Key.GetOption(groupView.GetGroupValue()); nil != opt {
+ newValue.MSelect = append(newValue.MSelect, &av.ValueSelect{Content: opt.Name, Color: opt.Color})
}
}
@@ -3486,18 +3484,16 @@ func sortAttributeViewRow(operation *Operation) (err error) {
groupView.GroupItemIDs = append(groupView.GroupItemIDs[:idx], groupView.GroupItemIDs[idx+1:]...)
if operation.GroupID != operation.TargetGroupID { // 跨分组排序
- if targetGroupView := view.GetGroupByID(operation.TargetGroupID); nil != targetGroupView {
- if !gulu.Str.Contains(itemID, targetGroupView.GroupItemIDs) {
- fillDefaultValue(attrView, view, targetGroupView, operation.PreviousID, itemID)
-
- for i, r := range targetGroupView.GroupItemIDs {
- if r == operation.PreviousID {
- previousIndex = i + 1
- break
- }
+ if targetGroupView := view.GetGroupByID(operation.TargetGroupID); nil != targetGroupView && !gulu.Str.Contains(itemID, targetGroupView.GroupItemIDs) {
+ fillDefaultValue(attrView, view, targetGroupView, operation.PreviousID, itemID)
+
+ for i, r := range targetGroupView.GroupItemIDs {
+ if r == operation.PreviousID {
+ previousIndex = i + 1
+ break
}
- targetGroupView.GroupItemIDs = util.InsertElem(targetGroupView.GroupItemIDs, previousIndex, itemID)
}
+ targetGroupView.GroupItemIDs = util.InsertElem(targetGroupView.GroupItemIDs, previousIndex, itemID)
}
} else { // 同分组内排序
for i, r := range groupView.GroupItemIDs {