@@ -25,7 +25,7 @@ import (
25
25
26
26
var (
27
27
x * xorm.Engine
28
- tables []interface {}
28
+ tables []any
29
29
initFuncs []func () error
30
30
31
31
// HasEngine specifies if we have a xorm.Engine
@@ -34,41 +34,41 @@ var (
34
34
35
35
// Engine represents a xorm engine or session.
36
36
type 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
53
53
Asc (colNames ... string ) * xorm.Session
54
54
Desc (colNames ... string ) * xorm.Session
55
55
Limit (limit int , start ... int ) * xorm.Session
56
56
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
59
59
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 )
63
63
Distinct (... string ) * xorm.Session
64
- Query (... interface {} ) ([]map [string ][]byte , error )
64
+ Query (... any ) ([]map [string ][]byte , error )
65
65
Cols (... string ) * xorm.Session
66
66
Context (ctx context.Context ) * xorm.Session
67
67
Ping () error
68
68
}
69
69
70
70
// TableInfo returns table's information via an object
71
- func TableInfo (v interface {} ) (* schemas.Table , error ) {
71
+ func TableInfo (v any ) (* schemas.Table , error ) {
72
72
return x .TableInfo (v )
73
73
}
74
74
@@ -78,7 +78,7 @@ func DumpTables(tables []*schemas.Table, w io.Writer, tp ...schemas.DBType) erro
78
78
}
79
79
80
80
// 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 ) {
82
82
tables = append (tables , bean )
83
83
if len (initFuncs ) > 0 && initFunc [0 ] != nil {
84
84
initFuncs = append (initFuncs , initFunc [0 ])
@@ -209,22 +209,22 @@ func InitEngineWithMigration(ctx context.Context, migrateFunc func(*xorm.Engine)
209
209
}
210
210
211
211
// 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 {}
214
214
if len (names ) == 0 {
215
215
beans = append (beans , tables ... )
216
216
return beans , nil
217
217
}
218
218
// Need to map provided names to beans...
219
- beanMap := make (map [string ]interface {} )
219
+ beanMap := make (map [string ]any )
220
220
for _ , bean := range tables {
221
221
222
222
beanMap [strings .ToLower (reflect .Indirect (reflect .ValueOf (bean )).Type ().Name ())] = bean
223
223
beanMap [strings .ToLower (x .TableName (bean ))] = bean
224
224
beanMap [strings .ToLower (x .TableName (bean , true ))] = bean
225
225
}
226
226
227
- gotBean := make (map [interface {} ]bool )
227
+ gotBean := make (map [any ]bool )
228
228
for _ , name := range names {
229
229
bean , ok := beanMap [strings .ToLower (strings .TrimSpace (name ))]
230
230
if ! ok {
@@ -266,7 +266,7 @@ func DumpDatabase(filePath, dbType string) error {
266
266
}
267
267
268
268
// MaxBatchInsertSize returns the table's max batch insert size
269
- func MaxBatchInsertSize (bean interface {} ) int {
269
+ func MaxBatchInsertSize (bean any ) int {
270
270
t , err := x .TableInfo (bean )
271
271
if err != nil {
272
272
return 50
@@ -286,7 +286,7 @@ func DeleteAllRecords(tableName string) error {
286
286
}
287
287
288
288
// 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 ) {
290
290
_ , err = x .Select ("MAX(id)" ).Table (beanOrTableName ).Get (& maxID )
291
291
return maxID , err
292
292
}
0 commit comments