Skip to content

Commit

Permalink
fix: remove unused function
Browse files Browse the repository at this point in the history
  • Loading branch information
luantranminh committed May 16, 2024
1 parent 73105b1 commit 8a83093
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions gormschema/gorm.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ func WithConfig(cfg *gorm.Config) Option {
// Load loads the models and returns the DDL statements representing the schema.
func (l *Loader) Load(models ...any) (string, error) {
var (
views []viewDefiner
views []ViewDefiner
tables []any
)
for _, obj := range models {
switch view := obj.(type) {
case viewDefiner:
case ViewDefiner:
views = append(views, view)
default:
tables = append(tables, obj)
Expand Down Expand Up @@ -194,7 +194,7 @@ func (m *migrator) CreateConstraints(models []any) error {
}

// CreateViews creates the given "view-based" models
func (m *migrator) CreateViews(views []viewDefiner) error {
func (m *migrator) CreateViews(views []ViewDefiner) error {
for _, view := range views {
viewName := m.DB.Config.NamingStrategy.TableName(indirect(reflect.TypeOf(view)).Name())
if namer, ok := view.(interface {
Expand All @@ -207,7 +207,7 @@ func (m *migrator) CreateViews(views []viewDefiner) error {
viewName: viewName,
}
for _, opt := range view.ViewDef(m.Dialector.Name()) {
opt.apply(viewBuilder)
opt(viewBuilder)
}
if err := m.DB.Exec(viewBuilder.createStmt).Error; err != nil {
return err
Expand Down Expand Up @@ -235,7 +235,7 @@ func indirect(t reflect.Type) reflect.Type {
type (
// ViewOption configures a viewBuilder.
ViewOption func(*viewBuilder)
viewDefiner interface {
ViewDefiner interface {
ViewDef(driver string) []ViewOption
}
viewBuilder struct {
Expand Down Expand Up @@ -269,7 +269,3 @@ func BuildStmt(fn func(db *gorm.DB) *gorm.DB) ViewOption {
b.createStmt = fmt.Sprintf("CREATE VIEW %s AS %s", b.viewName, vd)
}
}

func (vf ViewOption) apply(b *viewBuilder) {
vf(b)
}

0 comments on commit 8a83093

Please sign in to comment.