MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / parsePivotAlias

Method parsePivotAlias

pkg/sql/parser/pivot.go:52–65  ·  view source on GitHub ↗

parsePivotAlias consumes an optional alias (with or without AS) following a PIVOT/UNPIVOT clause. Extracted to avoid four copies of the same logic in the table-reference and join paths.

(ref *ast.TableReference)

Source from the content-addressed store, hash-verified

50// PIVOT/UNPIVOT clause. Extracted to avoid four copies of the same logic in
51// the table-reference and join paths.
52func (p *Parser) parsePivotAlias(ref *ast.TableReference) {
53 if p.isType(models.TokenTypeAs) {
54 p.advance() // consume AS
55 if p.isIdentifier() {
56 ref.Alias = p.currentToken.Token.Value
57 p.advance()
58 }
59 return
60 }
61 if p.isIdentifier() {
62 ref.Alias = p.currentToken.Token.Value
63 p.advance()
64 }
65}
66
67// pivotDialectAllowed reports whether PIVOT/UNPIVOT is a recognized clause
68// for the parser's current dialect. PIVOT/UNPIVOT are SQL Server, Oracle,

Callers 2

parseJoinedTableRefMethod · 0.95

Calls 3

isTypeMethod · 0.95
advanceMethod · 0.95
isIdentifierMethod · 0.95

Tested by

no test coverage detected