MCPcopy Index your code
hub / github.com/donatj/sqlread / parseSelect

Method parseSelect

query.go:142–183  ·  view source on GitHub ↗
(p *Parser)

Source from the content-addressed store, hash-verified

140}
141
142func (q *QueryParser) parseSelect(p *Parser) parseState {
143 qry := &Query{
144 Columns: make([]string, 0),
145 }
146
147 for {
148 i, ok := p.scan()
149 if !ok {
150 p.errorUnexpectedEOF()
151 return nil
152 }
153
154 if isOfAny(i, TIdentifier, TIntpStar) {
155 value := i.Val
156 if i.Type == TIdentifier {
157 value = identValue(i)
158 }
159
160 qry.Columns = append(qry.Columns, value)
161
162 j, ok := p.scan()
163 if !ok {
164 p.errorUnexpectedEOF()
165 return nil
166 }
167
168 if j.Type == TComma {
169 continue
170 }
171
172 if j.Type == TIntpFrom {
173 return q.parseSelectFromBuilder(qry)
174 }
175
176 p.errorUnexpectedLex(i, TComma, TIntpFrom)
177 return nil
178 }
179
180 p.errorUnexpectedLex(i, TIdentifier, TIntpStar)
181 return nil
182 }
183}
184
185func (q *QueryParser) parseSelectFromBuilder(qry *Query) parseState {
186 return func(p *Parser) parseState {

Callers

nothing calls this directly

Calls 6

isOfAnyFunction · 0.85
identValueFunction · 0.85
scanMethod · 0.80
errorUnexpectedEOFMethod · 0.80
errorUnexpectedLexMethod · 0.80

Tested by

no test coverage detected