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

Function validateEmptyBlockItem

dql/parser.go:3079–3101  ·  view source on GitHub ↗
(it *lex.ItemIterator, val string)

Source from the content-addressed store, hash-verified

3077)
3078
3079func validateEmptyBlockItem(it *lex.ItemIterator, val string) error {
3080 savePos := it.Save()
3081 defer func() {
3082 it.Restore(savePos)
3083 }()
3084
3085 fname := val
3086 // Could have alias so peek forward to get actual function name.
3087 skipped := trySkipItemTyp(it, itemColon)
3088 if skipped {
3089 item, ok := tryParseItemType(it, itemName)
3090 if !ok {
3091 return item.Errorf("Expected name. Got: %s", item.Val)
3092 }
3093 fname = item.Val
3094 }
3095 ok := trySkipItemTyp(it, itemLeftRound)
3096 if !ok || (!isMathBlock(fname) && !isAggregator(fname)) {
3097 return it.Errorf("Only aggregation/math functions allowed inside empty blocks."+
3098 " Got: %v", fname)
3099 }
3100 return nil
3101}
3102
3103// godeep constructs the subgraph from the lexed items and a GraphQuery node.
3104func godeep(it *lex.ItemIterator, gq *GraphQuery) error {

Callers 1

godeepFunction · 0.85

Calls 7

trySkipItemTypFunction · 0.85
tryParseItemTypeFunction · 0.85
isMathBlockFunction · 0.85
isAggregatorFunction · 0.85
RestoreMethod · 0.65
SaveMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected