MCPcopy
hub / github.com/sqldef/sqldef / escapeSQLNameQuoteAware

Method escapeSQLNameQuoteAware

schema/generator.go:3649–3674  ·  view source on GitHub ↗

escapeSQLNameQuoteAware escapes an identifier name for SQL output, taking into account whether it was originally quoted and the legacy_ignore_quotes setting.

(name string, wasQuoted bool)

Source from the content-addressed store, hash-verified

3647// escapeSQLNameQuoteAware escapes an identifier name for SQL output,
3648// taking into account whether it was originally quoted and the legacy_ignore_quotes setting.
3649func (g *Generator) escapeSQLNameQuoteAware(name string, wasQuoted bool) string {
3650 // Legacy mode: always quote everything (backward compatible behavior)
3651 if g.config.LegacyIgnoreQuotes {
3652 return g.forceEscapeSQLName(name)
3653 }
3654
3655 // Quote-aware mode
3656 switch g.mode {
3657 case GeneratorModePostgres:
3658 if wasQuoted {
3659 // Originally quoted: preserve case and quote in output
3660 return g.forceEscapeSQLName(name)
3661 } else {
3662 // Originally unquoted: normalize to lowercase and don't quote
3663 return strings.ToLower(name)
3664 }
3665 default:
3666 if wasQuoted {
3667 // Originally quoted: preserve case and quote in output
3668 return g.forceEscapeSQLName(name)
3669 } else {
3670 // Originally unquoted: do nothing since the RDBMS here is case-insensitive
3671 return name
3672 }
3673 }
3674}
3675
3676// identsEqual compares two Ident values (columns, indexes, constraints) for equality.
3677// This does NOT use MysqlLowerCaseTableNames because that only affects table names.

Callers 2

escapeSQLIdentMethod · 0.95

Calls 1

forceEscapeSQLNameMethod · 0.95

Tested by

no test coverage detected