Ver Fonte

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

Liang Ding há 2 anos atrás
pai
commit
f0e80505f0
1 ficheiros alterados com 3 adições e 3 exclusões
  1. 3 3
      kernel/sql/block_ref_query.go

+ 3 - 3
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)