Skip to content

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

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

Danielddc07027a719
diff --git a/kernel/av/table.go b/kernel/av/table.go
index d2bb326652..3c9d116585 100644
--- a/kernel/av/table.go
+++ b/kernel/av/table.go
@@ -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
}