Ident appends the given string as an identifier.
(s string)
| 2980 | |
| 2981 | // Ident appends the given string as an identifier. |
| 2982 | func (b *Builder) Ident(s string) *Builder { |
| 2983 | switch { |
| 2984 | case len(s) == 0: |
| 2985 | case !strings.HasSuffix(s, "*") && !b.isIdent(s) && !isFunc(s) && !isModifier(s) && !isAlias(s): |
| 2986 | if b.qualifier != "" { |
| 2987 | b.WriteString(b.Quote(b.qualifier)).WriteByte('.') |
| 2988 | } |
| 2989 | b.WriteString(b.Quote(s)) |
| 2990 | case (isFunc(s) || isModifier(s) || isAlias(s)) && b.postgres(): |
| 2991 | // Modifiers and aggregation functions that |
| 2992 | // were called without dialect information. |
| 2993 | b.WriteString(strings.ReplaceAll(s, "`", `"`)) |
| 2994 | default: |
| 2995 | b.WriteString(s) |
| 2996 | } |
| 2997 | return b |
| 2998 | } |
| 2999 | |
| 3000 | // IdentComma calls Ident on all arguments and adds a comma between them. |
| 3001 | func (b *Builder) IdentComma(s ...string) *Builder { |