Explorar el Código

:art: Kernel API `/api/query/sql` support `||` operator https://github.com/siyuan-note/siyuan/issues/9662

Daniel hace 1 año
padre
commit
422b8fdecd
Se han modificado 2 ficheros con 9 adiciones y 4 borrados
  1. 2 2
      kernel/sql/asset_content_query.go
  2. 7 2
      kernel/sql/block_query.go

+ 2 - 2
kernel/sql/asset_content_query.go

@@ -46,7 +46,7 @@ func queryAssetContentRawStmt(stmt string, limit int) (ret []map[string]interfac
 		return
 	}
 
-	noLimit := !strings.Contains(strings.ToLower(stmt), " limit ")
+	noLimit := !containsLimitClause(stmt)
 	var count, errCount int
 	for rows.Next() {
 		columns := make([]interface{}, len(cols))
@@ -152,7 +152,7 @@ func selectAssetContentsRawStmt(stmt string, limit int) (ret []*AssetContent) {
 	}
 	defer rows.Close()
 
-	noLimit := !strings.Contains(strings.ToLower(stmt), " limit ")
+	noLimit := !containsLimitClause(stmt)
 	var count, errCount int
 	for rows.Next() {
 		count++

+ 7 - 2
kernel/sql/block_query.go

@@ -503,7 +503,7 @@ func queryRawStmt(stmt string, limit int) (ret []map[string]interface{}, err err
 		return
 	}
 
-	noLimit := !strings.Contains(strings.ToLower(stmt), " limit ")
+	noLimit := !containsLimitClause(stmt)
 	var count, errCount int
 	for rows.Next() {
 		columns := make([]interface{}, len(cols))
@@ -609,7 +609,7 @@ func selectBlocksRawStmt(stmt string, limit int) (ret []*Block) {
 	}
 	defer rows.Close()
 
-	noLimit := !strings.Contains(strings.ToLower(stmt), " limit ")
+	noLimit := !containsLimitClause(stmt)
 	var count, errCount int
 	for rows.Next() {
 		count++
@@ -836,3 +836,8 @@ func GetContainerText(container *ast.Node) string {
 	})
 	return buf.String()
 }
+
+func containsLimitClause(stmt string) bool {
+	return strings.Contains(strings.ToLower(stmt), " limit ") ||
+		strings.Contains(strings.ToLower(stmt), "\nlimit ")
+}