[xorm] Change interface to become an interface (#60838)

[xorm] change interface to become an interface
This commit is contained in:
ying-jeanne 2022-12-30 21:58:10 +08:00 committed by GitHub
parent dcb106aec0
commit ce8512ace7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,64 +14,64 @@ import (
// Interface defines the interface which Engine and Session will implementate. // Interface defines the interface which Engine and Session will implementate.
type Interface interface { type Interface interface {
AllCols() *Session AllCols() Interface
Alias(alias string) *Session Alias(alias string) Interface
Asc(colNames ...string) *Session Asc(colNames ...string) Interface
BufferSize(size int) *Session BufferSize(size int) Interface
Cols(columns ...string) *Session Cols(columns ...string) Interface
Count(...interface{}) (int64, error) Count(...interface{}) (int64, error)
CreateIndexes(bean interface{}) error CreateIndexes(bean interface{}) error
CreateUniques(bean interface{}) error CreateUniques(bean interface{}) error
Decr(column string, arg ...interface{}) *Session Decr(column string, arg ...interface{}) Interface
Desc(...string) *Session Desc(...string) Interface
Delete(interface{}) (int64, error) Delete(interface{}) (int64, error)
Distinct(columns ...string) *Session Distinct(columns ...string) Interface
DropIndexes(bean interface{}) error DropIndexes(bean interface{}) error
Exec(sqlOrArgs ...interface{}) (sql.Result, error) Exec(sqlOrArgs ...interface{}) (sql.Result, error)
Exist(bean ...interface{}) (bool, error) Exist(bean ...interface{}) (bool, error)
Find(interface{}, ...interface{}) error Find(interface{}, ...interface{}) error
FindAndCount(interface{}, ...interface{}) (int64, error) FindAndCount(interface{}, ...interface{}) (int64, error)
Get(interface{}) (bool, error) Get(interface{}) (bool, error)
GroupBy(keys string) *Session GroupBy(keys string) Interface
ID(interface{}) *Session ID(interface{}) Interface
In(string, ...interface{}) *Session In(string, ...interface{}) Interface
Incr(column string, arg ...interface{}) *Session Incr(column string, arg ...interface{}) Interface
Insert(...interface{}) (int64, error) Insert(...interface{}) (int64, error)
InsertOne(interface{}) (int64, error) InsertOne(interface{}) (int64, error)
IsTableEmpty(bean interface{}) (bool, error) IsTableEmpty(bean interface{}) (bool, error)
IsTableExist(beanOrTableName interface{}) (bool, error) IsTableExist(beanOrTableName interface{}) (bool, error)
Iterate(interface{}, IterFunc) error Iterate(interface{}, IterFunc) error
Limit(int, ...int) *Session Limit(int, ...int) Interface
MustCols(columns ...string) *Session MustCols(columns ...string) Interface
NoAutoCondition(...bool) *Session NoAutoCondition(...bool) Interface
NotIn(string, ...interface{}) *Session NotIn(string, ...interface{}) Interface
Join(joinOperator string, tablename interface{}, condition string, args ...interface{}) *Session Join(joinOperator string, tablename interface{}, condition string, args ...interface{}) *Session
Omit(columns ...string) *Session Omit(columns ...string) Interface
OrderBy(order string) *Session OrderBy(order string) Interface
Ping() error Ping() error
Query(sqlOrArgs ...interface{}) (resultsSlice []map[string][]byte, err error) Query(sqlOrArgs ...interface{}) (resultsSlice []map[string][]byte, err error)
QueryInterface(sqlOrArgs ...interface{}) ([]map[string]interface{}, error) QueryInterface(sqlOrArgs ...interface{}) ([]map[string]interface{}, error)
QueryString(sqlOrArgs ...interface{}) ([]map[string]string, error) QueryString(sqlOrArgs ...interface{}) ([]map[string]string, error)
Rows(bean interface{}) (*Rows, error) Rows(bean interface{}) (*Rows, error)
SetExpr(string, interface{}) *Session SetExpr(string, interface{}) Interface
SQL(interface{}, ...interface{}) *Session SQL(interface{}, ...interface{}) Interface
Sum(bean interface{}, colName string) (float64, error) Sum(bean interface{}, colName string) (float64, error)
SumInt(bean interface{}, colName string) (int64, error) SumInt(bean interface{}, colName string) (int64, error)
Sums(bean interface{}, colNames ...string) ([]float64, error) Sums(bean interface{}, colNames ...string) ([]float64, error)
SumsInt(bean interface{}, colNames ...string) ([]int64, error) SumsInt(bean interface{}, colNames ...string) ([]int64, error)
Table(tableNameOrBean interface{}) *Session Table(tableNameOrBean interface{}) Interface
Unscoped() *Session Unscoped() Interface
Update(bean interface{}, condiBeans ...interface{}) (int64, error) Update(bean interface{}, condiBeans ...interface{}) (int64, error)
UseBool(...string) *Session UseBool(...string) Interface
Where(interface{}, ...interface{}) *Session Where(interface{}, ...interface{}) Interface
} }
// EngineInterface defines the interface which Engine will implementate. // EngineInterface defines the interface which Engine will implementate.
type EngineInterface interface { type EngineInterface interface {
Interface Interface
Before(func(interface{})) *Session Before(func(interface{})) Interface
Charset(charset string) *Session Charset(charset string) Interface
CreateTables(...interface{}) error CreateTables(...interface{}) error
DBMetas() ([]*core.Table, error) DBMetas() ([]*core.Table, error)
Dialect() core.Dialect Dialect() core.Dialect
@ -80,8 +80,8 @@ type EngineInterface interface {
GetTableMapper() core.IMapper GetTableMapper() core.IMapper
GetTZDatabase() *time.Location GetTZDatabase() *time.Location
GetTZLocation() *time.Location GetTZLocation() *time.Location
NewSession() *Session NewSession() Interface
NoAutoTime() *Session NoAutoTime() Interface
Quote(string) string Quote(string) string
SetConnMaxLifetime(time.Duration) SetConnMaxLifetime(time.Duration)
SetColumnMapper(core.IMapper) SetColumnMapper(core.IMapper)
@ -97,12 +97,7 @@ type EngineInterface interface {
ShowSQL(show ...bool) ShowSQL(show ...bool)
Sync(...interface{}) error Sync(...interface{}) error
Sync2(...interface{}) error Sync2(...interface{}) error
StoreEngine(storeEngine string) *Session StoreEngine(storeEngine string) Interface
TableName(interface{}, ...bool) string TableName(interface{}, ...bool) string
UnMapType(reflect.Type) UnMapType(reflect.Type)
} }
var (
_ Interface = &Session{}
_ EngineInterface = &Engine{}
)