🎨 Global search ignores LIMIT clause when using SQL method https://github.com/siyuan-note/siyuan/issues/8071

This commit is contained in:
Liang Ding 2023-04-21 10:46:55 +08:00
parent 62d871373b
commit 4cc8e18342
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 33 additions and 3 deletions

View file

@ -433,14 +433,25 @@ func SelectBlocksRawStmt(stmt string, page, limit int) (ret []*Block) {
Val: []byte(strconv.Itoa(limit)),
},
}
slct.Limit.Offset = &sqlparser.SQLVal{
Type: sqlparser.IntVal,
Val: []byte(strconv.Itoa((page - 1) * limit)),
}
} else {
if nil != slct.Limit.Rowcount && 0 < len(slct.Limit.Rowcount.(*sqlparser.SQLVal).Val) {
limit, _ = strconv.Atoi(string(slct.Limit.Rowcount.(*sqlparser.SQLVal).Val))
if 0 >= limit {
limit = 32
}
}
slct.Limit.Rowcount = &sqlparser.SQLVal{
Type: sqlparser.IntVal,
Val: []byte(strconv.Itoa(limit)),
}
slct.Limit.Offset = &sqlparser.SQLVal{
Type: sqlparser.IntVal,
Val: []byte(strconv.Itoa((page - 1) * 32)),
Val: []byte(strconv.Itoa((page - 1) * limit)),
}
}