Quote quotes the given identifier with the characters based on the configured dialect. It defaults to "`".
(ident string)
| 2962 | // Quote quotes the given identifier with the characters based |
| 2963 | // on the configured dialect. It defaults to "`". |
| 2964 | func (b *Builder) Quote(ident string) string { |
| 2965 | quote := "`" |
| 2966 | switch { |
| 2967 | case b.postgres(): |
| 2968 | // If it was quoted with the wrong |
| 2969 | // identifier character. |
| 2970 | if strings.Contains(ident, "`") { |
| 2971 | return strings.ReplaceAll(ident, "`", `"`) |
| 2972 | } |
| 2973 | quote = `"` |
| 2974 | // An identifier for unknown dialect. |
| 2975 | case b.dialect == "" && strings.ContainsAny(ident, "`\""): |
| 2976 | return ident |
| 2977 | } |
| 2978 | return quote + ident + quote |
| 2979 | } |
| 2980 | |
| 2981 | // Ident appends the given string as an identifier. |
| 2982 | func (b *Builder) Ident(s string) *Builder { |