🐛 Database table view sorts abnormally after deleting numeric values Fix https://github.com/siyuan-note/siyuan/issues/10476

This commit is contained in:
Daniel 2024-03-01 10:33:25 +08:00
parent 1635b4b8c2
commit a650764c12
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 29 additions and 1 deletions

View file

@ -101,6 +101,18 @@ func (value *Value) Compare(other *Value) int {
}
case KeyTypeNumber:
if nil != value.Number && nil != other.Number {
if value.Number.IsNotEmpty {
if !other.Number.IsNotEmpty {
return 1
}
return 0
} else {
if other.Number.IsNotEmpty {
return -1
}
return 0
}
if value.Number.Content > other.Number.Content {
return 1
} else if value.Number.Content < other.Number.Content {
@ -111,6 +123,18 @@ func (value *Value) Compare(other *Value) int {
}
case KeyTypeDate:
if nil != value.Date && nil != other.Date {
if value.Date.IsNotEmpty {
if !other.Date.IsNotEmpty {
return 1
}
return 0
} else {
if other.Date.IsNotEmpty {
return -1
}
return 0
}
if value.Date.Content > other.Date.Content {
return 1
} else if value.Date.Content < other.Date.Content {

View file

@ -2534,10 +2534,14 @@ func UpdateAttributeViewCell(tx *Transaction, avID, keyID, rowID, cellID string,
if av.KeyTypeNumber == val.Type {
if nil != val.Number && !val.Number.IsNotEmpty {
// 删除内容为空值
val.Number.Content = 0
val.Number.FormattedContent = ""
}
} else if av.KeyTypeDate == val.Type {
if nil != val.Date && !val.Date.IsNotEmpty {
val.Date.Content = 0
val.Date.FormattedContent = ""
}
}
relationChangeMode := 0 // 0不变仅排序1增加2减少