From f0e80505f0a15a7c4fac44b52e49f10e123fa3f7 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Mon, 17 Apr 2023 22:53:07 +0800 Subject: [PATCH] :art: Content type filtering when inserting reference links via `((`, `[[` https://github.com/siyuan-note/siyuan/issues/8009 --- kernel/sql/block_ref_query.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/sql/block_ref_query.go b/kernel/sql/block_ref_query.go index 348b39def..e0a7bb562 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)