renderQuotedIdent reproduces the original delimiters of a quoted identifier token so the parsed value round-trips through the formatter. The tokenizer strips delimiters but records the style in Token.Quote (or, for word tokens, Word.QuoteStyle). Embedded delimiters are escaped per dialect: SQL Serve
(tok models.Token)
| 31 | // tokens, Word.QuoteStyle). Embedded delimiters are escaped per dialect: |
| 32 | // SQL Server doubles `]`, ANSI doubles `"`, MySQL doubles “ ` “. |
| 33 | func renderQuotedIdent(tok models.Token) string { |
| 34 | q := tok.Quote |
| 35 | if q == 0 && tok.Word != nil { |
| 36 | q = tok.Word.QuoteStyle |
| 37 | } |
| 38 | switch q { |
| 39 | case '[': |
| 40 | return "[" + strings.ReplaceAll(tok.Value, "]", "]]") + "]" |
| 41 | case '"': |
| 42 | return "\"" + strings.ReplaceAll(tok.Value, "\"", "\"\"") + "\"" |
| 43 | case '`': |
| 44 | return "`" + strings.ReplaceAll(tok.Value, "`", "``") + "`" |
| 45 | } |
| 46 | return tok.Value |
| 47 | } |
| 48 | |
| 49 | // parsePivotAlias consumes an optional alias (with or without AS) following a |
| 50 | // PIVOT/UNPIVOT clause. Extracted to avoid four copies of the same logic in |
no outgoing calls
no test coverage detected