MCPcopy
hub / github.com/go-gorm/gorm / ColumnName

Method ColumnName

schema/schema_test.go:249–268  ·  view source on GitHub ↗
(table, column string)

Source from the content-addressed store, hash-verified

247}
248
249func (ns CustomizedNamingStrategy) ColumnName(table, column string) string {
250 baseColumnName := ns.NamingStrategy.ColumnName(table, column)
251
252 if table == "" {
253 return baseColumnName
254 }
255
256 s := strings.Split(table, "_")
257
258 var prefix string
259 switch len(s) {
260 case 1:
261 prefix = s[0][:3]
262 case 2:
263 prefix = s[0][:1] + s[1][:2]
264 default:
265 prefix = s[0][:1] + s[1][:1] + s[2][:1]
266 }
267 return prefix + "_" + baseColumnName
268}
269
270func TestEmbeddedStructForCustomizedNamingStrategy(t *testing.T) {
271 type CorpBase struct {

Callers

nothing calls this directly

Calls 1

ColumnNameMethod · 0.65

Tested by

no test coverage detected