MCPcopy
hub / github.com/sqldef/sqldef / normalizeColNameToQualifiedName

Function normalizeColNameToQualifiedName

schema/parser.go:1076–1095  ·  view source on GitHub ↗

normalizeColNameToQualifiedName creates a QualifiedName from a parser.ColName. This is used for trigger names which can be schema-qualified like [dbo].[trigger_name]. Unlike table names, trigger names do not get a default schema if none was specified.

(mode GeneratorMode, colName *parser.ColName, defaultSchema string)

Source from the content-addressed store, hash-verified

1074// This is used for trigger names which can be schema-qualified like [dbo].[trigger_name].
1075// Unlike table names, trigger names do not get a default schema if none was specified.
1076func normalizeColNameToQualifiedName(mode GeneratorMode, colName *parser.ColName, defaultSchema string) QualifiedName {
1077 var schemaIdent Ident
1078 if mode == GeneratorModePostgres || mode == GeneratorModeMssql {
1079 // ColName.Qualifier is a TableName; for trigger schema, the schema is in Qualifier.Schema
1080 // For [dbo].[insert_log], Qualifier.Schema = "dbo", Qualifier.Name = ""
1081 if !colName.Qualifier.Schema.IsEmpty() {
1082 schemaIdent = colName.Qualifier.Schema
1083 } else if !colName.Qualifier.Name.IsEmpty() {
1084 // Fallback: if Schema is empty but Name is set, use Name as schema
1085 schemaIdent = colName.Qualifier.Name
1086 }
1087 // Note: unlike tables, triggers don't get a default schema - if no schema was specified,
1088 // we leave it empty to preserve the original behavior
1089 }
1090
1091 return QualifiedName{
1092 Schema: schemaIdent,
1093 Name: colName.Name,
1094 }
1095}
1096
1097func normalizedTable(mode GeneratorMode, tableName Ident, defaultSchema string) Ident {
1098 switch mode {

Callers 1

parseDDLFunction · 0.85

Calls 1

IsEmptyMethod · 0.45

Tested by

no test coverage detected