mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
e3d1d2dbf0
commit
4de0be0bc1
1 changed files with 6 additions and 2 deletions
|
|
@ -379,6 +379,7 @@ func QueryNoLimit(stmt string) (ret []map[string]interface{}, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Query(stmt string, limit int) (ret []map[string]interface{}, err error) {
|
func Query(stmt string, limit int) (ret []map[string]interface{}, err error) {
|
||||||
|
originalStmt := stmt
|
||||||
// Kernel API `/api/query/sql` support `||` operator https://github.com/siyuan-note/siyuan/issues/9662
|
// Kernel API `/api/query/sql` support `||` operator https://github.com/siyuan-note/siyuan/issues/9662
|
||||||
// 这里为了支持 || 操作符,使用了另一个 sql 解析器,但是这个解析器无法处理 UNION https://github.com/siyuan-note/siyuan/issues/8226
|
// 这里为了支持 || 操作符,使用了另一个 sql 解析器,但是这个解析器无法处理 UNION https://github.com/siyuan-note/siyuan/issues/8226
|
||||||
// 考虑到 UNION 的使用场景不多,这里还是以支持 || 操作符为主
|
// 考虑到 UNION 的使用场景不多,这里还是以支持 || 操作符为主
|
||||||
|
|
@ -425,10 +426,13 @@ func Query(stmt string, limit int) (ret []map[string]interface{}, err error) {
|
||||||
|
|
||||||
ret = []map[string]interface{}{}
|
ret = []map[string]interface{}{}
|
||||||
rows, err := query(stmt)
|
rows, err := query(stmt)
|
||||||
|
if err != nil {
|
||||||
|
rows, err = query(originalStmt + " LIMIT " + strconv.Itoa(limit))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logging.LogWarnf("sql query [%s] failed: %s", stmt, err)
|
logging.LogWarnf("sql query [%s] failed: %s", stmt, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
|
|
||||||
cols, _ := rows.Columns()
|
cols, _ := rows.Columns()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue