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)
| 50 | // PIVOT/UNPIVOT clause. Extracted to avoid four copies of the same logic in |
| 51 | // the table-reference and join paths. |
| 52 | func (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, |
no test coverage detected