MCPcopy
hub / github.com/kashav/fsql / parseSelectClause

Method parseSelectClause

parser/parser.go:40–68  ·  view source on GitHub ↗

parseSelectClause parses the SELECT clause of the query.

(q *query.Query)

Source from the content-addressed store, hash-verified

38
39// parseSelectClause parses the SELECT clause of the query.
40func (p *parser) parseSelectClause(q *query.Query) error {
41 // Determine if we should show all attributes. This is only true when
42 // no attributes are provided (regardless of if the SELECT keyword is
43 // provided or not).
44 var showAll = true
45 if p.expect(tokenizer.Select) == nil {
46 if p.current == nil || p.current.Type == tokenizer.Identifier {
47 showAll = false
48 } else if p.current.Type == tokenizer.From || p.current.Type == tokenizer.Where {
49 // No SELECT and next token is FROM/WHERE, show all!
50 showAll = true
51 } else {
52 // No SELECT and next token is not Identifier nor FROM/WHERE -> malformed
53 // input.
54 return p.currentError()
55 }
56 } else if current := p.expect(tokenizer.Identifier); current != nil {
57 p.current = current
58 showAll = false
59 }
60
61 if showAll {
62 q.Attributes = allAttributes
63 } else if err := p.parseAttrs(&q.Attributes, &q.Modifiers); err != nil {
64 return err
65 }
66
67 return nil
68}
69
70// parseFromClause parses the FROM clause of the query.
71func (p *parser) parseFromClause(q *query.Query) error {

Callers 2

parseMethod · 0.95
TestParser_ParseSelectFunction · 0.80

Calls 3

expectMethod · 0.95
currentErrorMethod · 0.95
parseAttrsMethod · 0.95

Tested by 1

TestParser_ParseSelectFunction · 0.64