mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 15:40:12 +01:00
🎨 Query embed blocks support UNION queries https://github.com/siyuan-note/siyuan/issues/16594
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
3e9bd1547c
commit
a201aebf59
1 changed files with 32 additions and 0 deletions
|
|
@ -602,6 +602,38 @@ func SelectBlocksRawStmt(stmt string, page, limit int) (ret []*Block) {
|
|||
}
|
||||
|
||||
stmt = sqlparser.String(slct)
|
||||
case *sqlparser.Union:
|
||||
union := parsedStmt.(*sqlparser.Union)
|
||||
if nil == union.Limit {
|
||||
union.Limit = &sqlparser.Limit{
|
||||
Rowcount: &sqlparser.SQLVal{
|
||||
Type: sqlparser.IntVal,
|
||||
Val: []byte(strconv.Itoa(limit)),
|
||||
},
|
||||
}
|
||||
union.Limit.Offset = &sqlparser.SQLVal{
|
||||
Type: sqlparser.IntVal,
|
||||
Val: []byte(strconv.Itoa((page - 1) * limit)),
|
||||
}
|
||||
} else {
|
||||
if nil != union.Limit.Rowcount && 0 < len(union.Limit.Rowcount.(*sqlparser.SQLVal).Val) {
|
||||
limit, _ = strconv.Atoi(string(union.Limit.Rowcount.(*sqlparser.SQLVal).Val))
|
||||
if 0 >= limit {
|
||||
limit = 32
|
||||
}
|
||||
}
|
||||
|
||||
union.Limit.Rowcount = &sqlparser.SQLVal{
|
||||
Type: sqlparser.IntVal,
|
||||
Val: []byte(strconv.Itoa(limit)),
|
||||
}
|
||||
union.Limit.Offset = &sqlparser.SQLVal{
|
||||
Type: sqlparser.IntVal,
|
||||
Val: []byte(strconv.Itoa((page - 1) * limit)),
|
||||
}
|
||||
}
|
||||
|
||||
stmt = sqlparser.String(union)
|
||||
default:
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue