From 243501575aefbbb36d80418e579eeb8ee2b4cd88 Mon Sep 17 00:00:00 2001 From: Tran Minh Luan Date: Sun, 12 May 2024 23:34:23 +0700 Subject: [PATCH] refactor: lint Co-authored-by: Giau. Tran Minh <12751435+giautm@users.noreply.github.com> --- gormschema/gorm.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gormschema/gorm.go b/gormschema/gorm.go index 451732d..39222e3 100644 --- a/gormschema/gorm.go +++ b/gormschema/gorm.go @@ -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 } @@ -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,