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

Function TestTableWithNamer

tests/table_test.go:163–177  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

161}
162
163func TestTableWithNamer(t *testing.T) {
164 db, _ := gorm.Open(tests.DummyDialector{}, &gorm.Config{
165 NamingStrategy: schema.NamingStrategy{
166 TablePrefix: "t_",
167 },
168 })
169
170 sql := db.ToSQL(func(tx *gorm.DB) *gorm.DB {
171 return tx.Model(&UserWithTableNamer{}).Find(&UserWithTableNamer{})
172 })
173
174 if !regexp.MustCompile("SELECT \\* FROM `t_users`").MatchString(sql) {
175 t.Errorf("Table with namer, got %v", sql)
176 }
177}
178
179func TestPostgresTableWithIdentifierLength(t *testing.T) {
180 if DB.Dialector.Name() != "postgres" {

Callers

nothing calls this directly

Calls 4

OpenFunction · 0.92
ToSQLMethod · 0.80
ModelMethod · 0.80
FindMethod · 0.65

Tested by

no test coverage detected