Fix Panic in test scenerio
I have found that there are times when testing that if I did not create the database through Open() it will not have the parent set and cause a panic when it hits this code path.
This commit is contained in:
parent
742154be9a
commit
6ad5ab2fa6
@ -40,7 +40,7 @@ func (s *ModelStruct) TableName(db *DB) string {
|
||||
s.defaultTableName = tabler.TableName()
|
||||
} else {
|
||||
tableName := ToTableName(s.ModelType.Name())
|
||||
if db == nil || !db.parent.singularTable {
|
||||
if db == nil || (db.parent != nil && !db.parent.singularTable) {
|
||||
tableName = inflection.Plural(tableName)
|
||||
}
|
||||
s.defaultTableName = tableName
|
||||
|
Loading…
x
Reference in New Issue
Block a user