🎨 Add Relation column to database table view https://github.com/siyuan-note/siyuan/issues/9888

This commit is contained in:
Daniel 2023-12-25 15:06:51 +08:00
parent d2a32d2903
commit ddc07027a7
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -203,9 +203,29 @@ func (value *Value) Compare(other *Value) int {
return 0
}
case KeyTypeRelation:
// TODO: relation compare
if nil != value.Relation && nil != other.Relation {
vContent := strings.TrimSpace(strings.Join(value.Relation.Contents, " "))
oContent := strings.TrimSpace(strings.Join(other.Relation.Contents, " "))
return strings.Compare(vContent, oContent)
}
case KeyTypeRollup:
// TODO: rollup compare
if nil != value.Rollup && nil != other.Rollup {
vContent := strings.TrimSpace(strings.Join(value.Relation.Contents, " "))
oContent := strings.TrimSpace(strings.Join(other.Relation.Contents, " "))
if util.IsNumeric(vContent) && util.IsNumeric(oContent) {
v1, _ := strconv.ParseFloat(vContent, 64)
v2, _ := strconv.ParseFloat(oContent, 64)
if v1 > v2 {
return 1
}
if v1 < v2 {
return -1
}
return 0
}
return strings.Compare(vContent, oContent)
}
}
return 0
}