@@ -25,7 +25,7 @@ import (
2525
2626var (
2727 x * xorm.Engine
28- tables []interface {}
28+ tables []any
2929 initFuncs []func () error
3030
3131 // HasEngine specifies if we have a xorm.Engine
@@ -34,41 +34,41 @@ var (
3434
3535// Engine represents a xorm engine or session.
3636type Engine interface {
37- Table (tableNameOrBean interface {} ) * xorm.Session
38- Count (... interface {} ) (int64 , error )
39- Decr (column string , arg ... interface {} ) * xorm.Session
40- Delete (... interface {} ) (int64 , error )
41- Truncate (... interface {} ) (int64 , error )
42- Exec (... interface {} ) (sql.Result , error )
43- Find (interface {} , ... interface {} ) error
44- Get (beans ... interface {} ) (bool , error )
45- ID (interface {} ) * xorm.Session
46- In (string , ... interface {} ) * xorm.Session
47- Incr (column string , arg ... interface {} ) * xorm.Session
48- Insert (... interface {} ) (int64 , error )
49- Iterate (interface {} , xorm.IterFunc ) error
50- Join (joinOperator string , tablename , condition interface {} , args ... interface {} ) * xorm.Session
51- SQL (interface {} , ... interface {} ) * xorm.Session
52- Where (interface {} , ... interface {} ) * xorm.Session
37+ Table (tableNameOrBean any ) * xorm.Session
38+ Count (... any ) (int64 , error )
39+ Decr (column string , arg ... any ) * xorm.Session
40+ Delete (... any ) (int64 , error )
41+ Truncate (... any ) (int64 , error )
42+ Exec (... any ) (sql.Result , error )
43+ Find (any , ... any ) error
44+ Get (beans ... any ) (bool , error )
45+ ID (any ) * xorm.Session
46+ In (string , ... any ) * xorm.Session
47+ Incr (column string , arg ... any ) * xorm.Session
48+ Insert (... any ) (int64 , error )
49+ Iterate (any , xorm.IterFunc ) error
50+ Join (joinOperator string , tablename , condition any , args ... any ) * xorm.Session
51+ SQL (any , ... any ) * xorm.Session
52+ Where (any , ... any ) * xorm.Session
5353 Asc (colNames ... string ) * xorm.Session
5454 Desc (colNames ... string ) * xorm.Session
5555 Limit (limit int , start ... int ) * xorm.Session
5656 NoAutoTime () * xorm.Session
57- SumInt (bean interface {} , columnName string ) (res int64 , err error )
58- Sync2 (... interface {} ) error
57+ SumInt (bean any , columnName string ) (res int64 , err error )
58+ Sync2 (... any ) error
5959 Select (string ) * xorm.Session
60- NotIn (string , ... interface {} ) * xorm.Session
61- OrderBy (interface {} , ... interface {} ) * xorm.Session
62- Exist (... interface {} ) (bool , error )
60+ NotIn (string , ... any ) * xorm.Session
61+ OrderBy (any , ... any ) * xorm.Session
62+ Exist (... any ) (bool , error )
6363 Distinct (... string ) * xorm.Session
64- Query (... interface {} ) ([]map [string ][]byte , error )
64+ Query (... any ) ([]map [string ][]byte , error )
6565 Cols (... string ) * xorm.Session
6666 Context (ctx context.Context ) * xorm.Session
6767 Ping () error
6868}
6969
7070// TableInfo returns table's information via an object
71- func TableInfo (v interface {} ) (* schemas.Table , error ) {
71+ func TableInfo (v any ) (* schemas.Table , error ) {
7272 return x .TableInfo (v )
7373}
7474
@@ -78,7 +78,7 @@ func DumpTables(tables []*schemas.Table, w io.Writer, tp ...schemas.DBType) erro
7878}
7979
8080// RegisterModel registers model, if initfunc provided, it will be invoked after data model sync
81- func RegisterModel (bean interface {} , initFunc ... func () error ) {
81+ func RegisterModel (bean any , initFunc ... func () error ) {
8282 tables = append (tables , bean )
8383 if len (initFuncs ) > 0 && initFunc [0 ] != nil {
8484 initFuncs = append (initFuncs , initFunc [0 ])
@@ -209,22 +209,22 @@ func InitEngineWithMigration(ctx context.Context, migrateFunc func(*xorm.Engine)
209209}
210210
211211// NamesToBean return a list of beans or an error
212- func NamesToBean (names ... string ) ([]interface {} , error ) {
213- beans := []interface {} {}
212+ func NamesToBean (names ... string ) ([]any , error ) {
213+ beans := []any {}
214214 if len (names ) == 0 {
215215 beans = append (beans , tables ... )
216216 return beans , nil
217217 }
218218 // Need to map provided names to beans...
219- beanMap := make (map [string ]interface {} )
219+ beanMap := make (map [string ]any )
220220 for _ , bean := range tables {
221221
222222 beanMap [strings .ToLower (reflect .Indirect (reflect .ValueOf (bean )).Type ().Name ())] = bean
223223 beanMap [strings .ToLower (x .TableName (bean ))] = bean
224224 beanMap [strings .ToLower (x .TableName (bean , true ))] = bean
225225 }
226226
227- gotBean := make (map [interface {} ]bool )
227+ gotBean := make (map [any ]bool )
228228 for _ , name := range names {
229229 bean , ok := beanMap [strings .ToLower (strings .TrimSpace (name ))]
230230 if ! ok {
@@ -266,7 +266,7 @@ func DumpDatabase(filePath, dbType string) error {
266266}
267267
268268// MaxBatchInsertSize returns the table's max batch insert size
269- func MaxBatchInsertSize (bean interface {} ) int {
269+ func MaxBatchInsertSize (bean any ) int {
270270 t , err := x .TableInfo (bean )
271271 if err != nil {
272272 return 50
@@ -286,7 +286,7 @@ func DeleteAllRecords(tableName string) error {
286286}
287287
288288// GetMaxID will return max id of the table
289- func GetMaxID (beanOrTableName interface {} ) (maxID int64 , err error ) {
289+ func GetMaxID (beanOrTableName any ) (maxID int64 , err error ) {
290290 _ , err = x .Select ("MAX(id)" ).Table (beanOrTableName ).Get (& maxID )
291291 return maxID , err
292292}
0 commit comments