MCPcopy
hub / github.com/ent/ent / Quote

Method Quote

dialect/sql/builder.go:2964–2979  ·  view source on GitHub ↗

Quote quotes the given identifier with the characters based on the configured dialect. It defaults to "`".

(ident string)

Source from the content-addressed store, hash-verified

2962// Quote quotes the given identifier with the characters based
2963// on the configured dialect. It defaults to "`".
2964func (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.
2982func (b *Builder) Ident(s string) *Builder {

Callers 7

IdentMethod · 0.95
CodeMethod · 0.80
marshalFunction · 0.80
quoteFunction · 0.80
SchemaSnapshotMethod · 0.80
cycleCauseMethod · 0.80
MarshalGQLMethod · 0.80

Calls 2

postgresMethod · 0.95
ContainsMethod · 0.45

Tested by 2

marshalFunction · 0.64
MarshalGQLMethod · 0.64