parseSelectClause parses the SELECT clause of the query.
(q *query.Query)
| 38 | |
| 39 | // parseSelectClause parses the SELECT clause of the query. |
| 40 | func (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. |
| 71 | func (p *parser) parseFromClause(q *query.Query) error { |