MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / formatIdentifier

Method formatIdentifier

cmd/gosqlx/cmd/sql_formatter.go:1067–1077  ·  view source on GitHub ↗

formatIdentifier formats an identifier, quoting it if it contains special characters or is a reserved keyword

(ident string)

Source from the content-addressed store, hash-verified

1065// formatIdentifier formats an identifier, quoting it if it contains special characters
1066// or is a reserved keyword
1067func (f *SQLFormatter) formatIdentifier(ident string) {
1068 if f.needsQuoting(ident) {
1069 f.builder.WriteString("\"")
1070 // Escape any existing double quotes by doubling them
1071 escaped := strings.ReplaceAll(ident, "\"", "\"\"")
1072 f.builder.WriteString(escaped)
1073 f.builder.WriteString("\"")
1074 } else {
1075 f.builder.WriteString(ident)
1076 }
1077}
1078
1079// needsQuoting returns true if the identifier needs to be quoted
1080func (f *SQLFormatter) needsQuoting(ident string) bool {

Callers 1

formatExpressionMethod · 0.95

Calls 1

needsQuotingMethod · 0.95

Tested by

no test coverage detected