🎨 Global search supports pagination to display results https://github.com/siyuan-note/siyuan/issues/7948

This commit is contained in:
Liang Ding 2023-04-21 09:49:13 +08:00
parent 685b7e1383
commit 1eba131624
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
6 changed files with 21 additions and 12 deletions

View file

@ -417,7 +417,7 @@ func SelectBlocksRawStmtNoParse(stmt string, limit int) (ret []*Block) {
return selectBlocksRawStmt(stmt, limit)
}
func SelectBlocksRawStmt(stmt string, limit int) (ret []*Block) {
func SelectBlocksRawStmt(stmt string, page, limit int) (ret []*Block) {
parsedStmt, err := sqlparser.Parse(stmt)
if nil != err {
return selectBlocksRawStmt(stmt, limit)
@ -433,6 +433,15 @@ func SelectBlocksRawStmt(stmt string, limit int) (ret []*Block) {
Val: []byte(strconv.Itoa(limit)),
},
}
} else {
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)),
}
}
stmt = sqlparser.String(slct)