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

Function parseMutationBlock

dql/parser_mutation.go:146–169  ·  view source on GitHub ↗

parseMutationBlock parses the mutation block

(it *lex.ItemIterator)

Source from the content-addressed store, hash-verified

144
145// parseMutationBlock parses the mutation block
146func parseMutationBlock(it *lex.ItemIterator) (*api.Mutation, error) {
147 var mu api.Mutation
148
149 item := it.Item()
150 if item.Typ != itemLeftCurl {
151 return nil, it.Errorf("Expected { at the start of block. Got: [%s]", item.Val)
152 }
153
154 for it.Next() {
155 item := it.Item()
156 if item.Typ == itemText {
157 continue
158 }
159 if item.Typ == itemRightCurl {
160 return &mu, nil
161 }
162 if item.Typ == itemMutationOp {
163 if err := parseMutationOp(it, item.Val, &mu); err != nil {
164 return nil, err
165 }
166 }
167 }
168 return nil, it.Errorf("Invalid mutation.")
169}
170
171// parseMutationOp parses and stores set or delete operation string in Mutation.
172func parseMutationOp(it *lex.ItemIterator, op string, mu *api.Mutation) error {

Callers 3

ParseMutationFunction · 0.85
parseUpsertBlockFunction · 0.85
ParseDQLFunction · 0.85

Calls 4

parseMutationOpFunction · 0.85
ItemMethod · 0.80
ErrorfMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected