Browse Source

'fix'

apijson
u 2 years ago
parent
commit
0b0d9f3048
  1. 3
      apijson/query_node.go
  2. 29
      query_node_test.go

3
apijson/query_node.go

@ -5,8 +5,6 @@ import (
"net/http"
"strings"
"time"
"github.com/micro/go-micro/logger"
)
func NewQueryNode(c *QueryContext, path, key string, queryMap map[string]interface{}) *QueryNode {
@ -119,7 +117,6 @@ func (n *QueryNode) parseOne() {
func (n *QueryNode) parseKVs(kvs map[string]interface{}) {
root := n.ctx
for field, value := range kvs {
logger.Debugf("%s -> parse %s %v", n.Key, field, value)
if value == nil {
root.err = fmt.Errorf("field value error, %s is nil", field)
root.code = http.StatusBadRequest

29
query_node_test.go

@ -1,29 +0,0 @@
package vql
import (
"encoding/json"
"log"
"testing"
"git.ouxuan.net/3136352472/vql/apijson"
)
func TestNewQueryNode(t *testing.T) {
apijson.SetQueryAll(func(sql string, args ...interface{}) ([]map[string]interface{}, error) {
log.Println(sql, args)
sqlx, err := Analyze(sql)
if err != nil {
return nil, err
}
log.Println(sqlx.ToSql())
return nil, nil
})
reqStr := `{ "Moment": { "id":12 } }`
req := make(map[string]interface{})
json.Unmarshal([]byte(reqStr), &req)
ctx := apijson.NewQueryContext(req)
log.Println(ctx.Response())
}
Loading…
Cancel
Save