Your Question
When I implement custom Namer interface for NamingStrategy
type Namer interface {
TableName(table string) string
SchemaName(table string) string
ColumnName(table, column string) string
JoinTableName(table string) string
RelationshipFKName(Relationship) string
CheckerName(table, column string) string
IndexName(table, column string) string
}
table parmater is a type name without the package prefix (e.g. User instead of users.User), so how should I distinguish one table from another?
Also when trying to override table name manually during the query:
db.Table("test").First(&User{})
The table param is User and not the test. Is it an expected behaviour?
The document you expected this should be explained
Expected answer
Comment From: jinzhu
The table param is User and not the test. Is it an expected behaviour?
No, it should be test
table parmater is a type name without the package prefix (e.g. User instead of users.User), so how should I distinguish one table from another?
We don't care which package is it from, if package distinction is important in your case, perhaps you want to refer to https://gorm.io/docs/conventions.html#TableName
Comment From: f3oall
No, it should be test
Should I open a bug report then?