MCPcopy
hub / github.com/dgraph-io/dgraph / ParseDQL

Function ParseDQL

dql/dql.go:14–50  ·  view source on GitHub ↗
(dqlQuery string)

Source from the content-addressed store, hash-verified

12)
13
14func ParseDQL(dqlQuery string) (*api.Request, error) {
15 var lexer lex.Lexer
16 lexer.Reset(dqlQuery)
17 lexer.Run(lexTopLevel)
18 if err := lexer.ValidateResult(); err != nil {
19 return nil, err
20 }
21
22 it := lexer.NewIterator()
23 if !it.Next() {
24 return nil, it.Errorf("Invalid mutation")
25 }
26
27 item := it.Item()
28 switch item.Typ {
29 case itemUpsertBlock:
30 it.Prev()
31 return parseUpsertBlock(it)
32
33 default:
34 it.Next()
35 item = it.Item()
36 if item.Typ == itemMutationOp {
37 it.Prev()
38 it.Prev()
39 mu, err := parseMutationBlock(it)
40 if err != nil {
41 return nil, err
42 }
43 return &api.Request{Mutations: []*api.Mutation{mu}}, nil
44 }
45
46 it.Prev()
47 it.Prev()
48 return &api.Request{Query: dqlQuery}, nil
49 }
50}

Callers 15

RunDQLMethod · 0.92
mutationHandlerFunction · 0.92
TestInvalidBlockErrFunction · 0.85
TestExtraRightCurlErrFunction · 0.85
TestNoMutationErrFunction · 0.85
TestMultipleQueryErrFunction · 0.85
TestEmptyUpsertErrFunction · 0.85
TestNoRightCurlErrFunction · 0.85
TestIncompleteBlockErrFunction · 0.85
TestMissingQueryErrFunction · 0.85
TestUpsertWithFragmentFunction · 0.85
TestUpsertEx1Function · 0.85

Calls 10

ResetMethod · 0.95
RunMethod · 0.95
ValidateResultMethod · 0.95
NewIteratorMethod · 0.95
parseUpsertBlockFunction · 0.85
parseMutationBlockFunction · 0.85
ItemMethod · 0.80
PrevMethod · 0.80
NextMethod · 0.45
ErrorfMethod · 0.45

Tested by 15

TestInvalidBlockErrFunction · 0.68
TestExtraRightCurlErrFunction · 0.68
TestNoMutationErrFunction · 0.68
TestMultipleQueryErrFunction · 0.68
TestEmptyUpsertErrFunction · 0.68
TestNoRightCurlErrFunction · 0.68
TestIncompleteBlockErrFunction · 0.68
TestMissingQueryErrFunction · 0.68
TestUpsertWithFragmentFunction · 0.68
TestUpsertEx1Function · 0.68
TestUpsertWithSpacesFunction · 0.68
TestUpsertWithBlankNodeFunction · 0.68