Skip to content

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

:art: Content type filtering when inserting reference links via `((`, `[[` https://github.com/siyuan-note/siyuan/issues/8009

Liang Dingf0e80505f0a1
diff --git a/kernel/sql/block_ref_query.go b/kernel/sql/block_ref_query.go
index 348b39def2..e0a7bb5627 100644
--- a/kernel/sql/block_ref_query.go
+++ b/kernel/sql/block_ref_query.go
@@ -336,11 +336,11 @@ func QueryRefIDsByDefID(defID string, containChildren bool) (refIDs, refTexts []
}
func QueryRefsRecent(onlyDoc bool) (ret []*Ref) {
- stmt := "SELECT * FROM refs"
+ stmt := "SELECT * FROM refs AS r"
if onlyDoc {
- stmt = "SELECT * FROM refs WHERE def_block_type = 'd'"
+ stmt = "SELECT r.* FROM refs AS r, blocks AS b WHERE b.type = 'd' AND b.id = r.def_block_id"
}
- stmt += " GROUP BY def_block_id ORDER BY id DESC LIMIT 32"
+ stmt += " GROUP BY r.def_block_id ORDER BY r.id DESC LIMIT 32"
rows, err := query(stmt)
if nil != err {
logging.LogErrorf("sql query failed: %s", err)