🎨 Automatically check and eliminate duplicate reference relationships Fix https://github.com/siyuan-note/siyuan/issues/9618

This commit is contained in:
Daniel 2023-11-10 11:01:06 +08:00
parent 62e27ba24c
commit 368091bd53
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 50 additions and 10 deletions

View file

@ -28,6 +28,21 @@ import (
"github.com/siyuan-note/siyuan/kernel/search"
)
func GetRefDuplicatedDefRootIDs() (ret []string) {
rows, err := query("SELECT DISTINCT def_block_root_id FROM `refs` GROUP BY def_block_id, def_block_root_id HAVING COUNT(*) > 1 LIMIT 1")
if nil != err {
logging.LogErrorf("sql query failed: %s", err)
return
}
defer rows.Close()
for rows.Next() {
var id string
rows.Scan(&id)
ret = append(ret, id)
}
return
}
func QueryVirtualRefKeywords(name, alias, anchor, doc bool) (ret []string) {
if name {
ret = append(ret, queryNames()...)