diff --git a/pkg/client/orm/do_nothing_orm.go b/pkg/client/orm/do_nothing_orm.go index 07c7fd74..e27e7f3a 100644 --- a/pkg/client/orm/do_nothing_orm.go +++ b/pkg/client/orm/do_nothing_orm.go @@ -30,18 +30,6 @@ var _ Ormer = new(DoNothingOrm) type DoNothingOrm struct { } -func (d *DoNothingOrm) RegisterModels(models ...interface{}) (err error) { - return nil -} - -func (d *DoNothingOrm) RegisterModelsWithPrefix(prefix string, models ...interface{}) (err error) { - return nil -} - -func (d *DoNothingOrm) RegisterModelsWithSuffix(suffix string, models ...interface{}) (err error) { - return nil -} - func (d *DoNothingOrm) Read(md interface{}, cols ...string) error { return nil } diff --git a/pkg/client/orm/filter_orm_decorator.go b/pkg/client/orm/filter_orm_decorator.go index 3271c520..d0c5c537 100644 --- a/pkg/client/orm/filter_orm_decorator.go +++ b/pkg/client/orm/filter_orm_decorator.go @@ -17,7 +17,6 @@ package orm import ( "context" "database/sql" - "errors" "reflect" "time" @@ -43,18 +42,6 @@ type filterOrmDecorator struct { txName string } -func (f *filterOrmDecorator) RegisterModels(models ...interface{}) (err error) { - return errors.New(`not callable`) -} - -func (f *filterOrmDecorator) RegisterModelsWithPrefix(prefix string, models ...interface{}) (err error) { - return errors.New(`not callable`) -} - -func (f *filterOrmDecorator) RegisterModelsWithSuffix(suffix string, models ...interface{}) (err error) { - return errors.New(`not callable`) -} - func NewFilterOrmDecorator(delegate Ormer, filterChains ...FilterChain) Ormer { res := &filterOrmDecorator{ ormer: delegate, diff --git a/pkg/client/orm/models.go b/pkg/client/orm/models.go index ea315c2b..19941d2e 100644 --- a/pkg/client/orm/models.go +++ b/pkg/client/orm/models.go @@ -36,15 +36,6 @@ var ( modelCache = NewModelCacheHandler() ) -type modelCacheHandler interface { - //RegisterModels register models without prefix or suffix - RegisterModels(models ...interface{}) (err error) - //RegisterModelsWithPrefix register models with prefix - RegisterModelsWithPrefix(prefix string, models ...interface{}) (err error) - //RegisterModelsWithSuffix register models with suffix - RegisterModelsWithSuffix(suffix string, models ...interface{}) (err error) -} - // model info collection type _modelCache struct { sync.RWMutex // only used outsite for bootStrap @@ -62,20 +53,6 @@ func NewModelCacheHandler() *_modelCache { } } -var _ modelCacheHandler = new(_modelCache) - -func (mc *_modelCache) RegisterModels(models ...interface{}) (err error) { - return mc.register(``, true, models...) -} - -func (mc *_modelCache) RegisterModelsWithPrefix(prefix string, models ...interface{}) (err error) { - return mc.register(prefix, true, models...) -} - -func (mc *_modelCache) RegisterModelsWithSuffix(suffix string, models ...interface{}) (err error) { - return mc.register(suffix, false, models...) -} - // get all model info func (mc *_modelCache) all() map[string]*modelInfo { m := make(map[string]*modelInfo, len(mc.cache)) diff --git a/pkg/client/orm/orm.go b/pkg/client/orm/orm.go index 557c788c..bfb710d1 100644 --- a/pkg/client/orm/orm.go +++ b/pkg/client/orm/orm.go @@ -496,23 +496,10 @@ func (o *ormBase) DBStats() *sql.DBStats { type orm struct { ormBase - modelCacheHandler } var _ Ormer = new(orm) -func (o *orm) RegisterModels(models ...interface{}) (err error) { - return o.modelCacheHandler.RegisterModels(models) -} - -func (o *orm) RegisterModelsWithPrefix(prefix string, models ...interface{}) (err error) { - return o.modelCacheHandler.RegisterModelsWithPrefix(prefix, models...) -} - -func (o *orm) RegisterModelsWithSuffix(suffix string, models ...interface{}) (err error) { - return o.modelCacheHandler.RegisterModelsWithSuffix(suffix, models...) -} - func (o *orm) Begin() (TxOrmer, error) { return o.BeginWithCtx(context.Background()) } @@ -633,8 +620,6 @@ func newDBWithAlias(al *alias) Ormer { o.db = al.DB } - o.modelCacheHandler = NewModelCacheHandler() - if len(globalFilterChains) > 0 { return NewFilterOrmDecorator(o, globalFilterChains...) } diff --git a/pkg/client/orm/types.go b/pkg/client/orm/types.go index b9c444eb..b0c793b7 100644 --- a/pkg/client/orm/types.go +++ b/pkg/client/orm/types.go @@ -219,7 +219,6 @@ type ormer interface { type Ormer interface { ormer - modelCacheHandler TxBeginner }