Skip to content

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

:bug: https://github.com/siyuan-note/siyuan/issues/11776 https://github.com/siyuan-note/siyuan/issues/11773

Daniel6f370460dc4e
diff --git a/kernel/treenode/blocktree.go b/kernel/treenode/blocktree.go
index 153429c35f..82d1a16939 100644
--- a/kernel/treenode/blocktree.go
+++ b/kernel/treenode/blocktree.go
@@ -220,7 +220,7 @@ func GetBlockTreeRootByPath(boxID, path string) (ret *BlockTree) {
func GetBlockTreeRootByHPath(boxID, hPath string) (ret *BlockTree) {
ret = &BlockTree{}
hPath = gulu.Str.RemoveInvisible(hPath)
- sqlStmt := "SELECT * FROM blocktrees WHERE box_id = ? AND hpath = ?"
+ sqlStmt := "SELECT * FROM blocktrees WHERE box_id = ? AND hpath = ? AND type = 'd'"
err := db.QueryRow(sqlStmt, boxID, hPath).Scan(&ret.ID, &ret.RootID, &ret.ParentID, &ret.BoxID, &ret.Path, &ret.HPath, &ret.Updated, &ret.Type)
if nil != err {
ret = nil
@@ -235,7 +235,7 @@ func GetBlockTreeRootByHPath(boxID, hPath string) (ret *BlockTree) {
func GetBlockTreeRootsByHPath(boxID, hPath string) (ret []*BlockTree) {
hPath = gulu.Str.RemoveInvisible(hPath)
- sqlStmt := "SELECT * FROM blocktrees WHERE box_id = ? AND hpath = ?"
+ sqlStmt := "SELECT * FROM blocktrees WHERE box_id = ? AND hpath = ? AND type = 'd'"
rows, err := db.Query(sqlStmt, boxID, hPath)
if nil != err {
logging.LogErrorf("sql query [%s] failed: %s", sqlStmt, err)
@@ -256,7 +256,7 @@ func GetBlockTreeRootsByHPath(boxID, hPath string) (ret []*BlockTree) {
func GetBlockTreeRootByHPathPreferredParentID(boxID, hPath, preferredParentID string) (ret *BlockTree) {
hPath = gulu.Str.RemoveInvisible(hPath)
var roots []*BlockTree
- sqlStmt := "SELECT * FROM blocktrees WHERE box_id = ? AND hpath = ? AND parent_id = ?"
+ sqlStmt := "SELECT * FROM blocktrees WHERE box_id = ? AND hpath = ? AND parent_id = ? AND type = 'd'"
rows, err := db.Query(sqlStmt, boxID, hPath, preferredParentID)
if nil != err {
logging.LogErrorf("sql query [%s] failed: %s", sqlStmt, err)