Skip to content

Commit

Permalink
refactor: lint
Browse files Browse the repository at this point in the history
Co-authored-by: Giau. Tran Minh <[email protected]>
  • Loading branch information
luantranminh and giautm authored May 12, 2024
1 parent 8b0d501 commit 2435015
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions gormschema/gorm.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@ func (l *Loader) Load(objs ...any) (string, error) {
if err = db.AutoMigrate(tables...); err != nil {
return "", err
}
db, err = gorm.Open(dialector{
Dialector: di,
}, l.config)
db, err = gorm.Open(dialector{Dialector: di}, l.config)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -208,13 +206,13 @@ func (m *migrator) CreateConstraints(models []any) error {
// CreateViews creates the given "view-based" models
func (m *migrator) CreateViews(views []viewDefiner) error {
for _, view := range views {
viewDef := view.ViewDef(m.DB)
viewName := m.DB.Config.NamingStrategy.TableName(indirect(reflect.TypeOf(view)).Name())
if namer, ok := view.(interface {
TableName() string
}); ok {
viewName = namer.TableName()
}
viewDef := view.ViewDef(m.DB)
if err := m.DB.Migrator().CreateView(viewName, gorm.ViewOption{
Replace: viewDef.Replace,
CheckOption: viewDef.CheckOption,
Expand Down

0 comments on commit 2435015

Please sign in to comment.