@@ -26,10 +26,10 @@ const (
2626type ExecQuerier interface {
2727 // Exec executes a query that does not return records. For example, in SQL, INSERT or UPDATE.
2828 // It scans the result into the pointer v. For SQL drivers, it is dialect/sql.Result.
29- Exec (ctx context.Context , query string , args , v interface {} ) error
29+ Exec (ctx context.Context , query string , args , v any ) error
3030 // Query executes a query that returns rows, typically a SELECT in SQL.
3131 // It scans the result into the pointer v. For SQL drivers, it is *dialect/sql.Rows.
32- Query (ctx context.Context , query string , args , v interface {} ) error
32+ Query (ctx context.Context , query string , args , v any ) error
3333}
3434
3535// Driver is the interface that wraps all necessary operations for ent clients.
@@ -65,38 +65,38 @@ func NopTx(d Driver) Tx {
6565
6666// DebugDriver is a driver that logs all driver operations.
6767type DebugDriver struct {
68- Driver // underlying driver.
69- log func (context.Context , ... interface {} ) // log function. defaults to log.Println.
68+ Driver // underlying driver.
69+ log func (context.Context , ... any ) // log function. defaults to log.Println.
7070}
7171
7272// Debug gets a driver and an optional logging function, and returns
7373// a new debugged-driver that prints all outgoing operations.
74- func Debug (d Driver , logger ... func (... interface {} )) Driver {
74+ func Debug (d Driver , logger ... func (... any )) Driver {
7575 logf := log .Println
7676 if len (logger ) == 1 {
7777 logf = logger [0 ]
7878 }
79- drv := & DebugDriver {d , func (_ context.Context , v ... interface {} ) { logf (v ... ) }}
79+ drv := & DebugDriver {d , func (_ context.Context , v ... any ) { logf (v ... ) }}
8080 return drv
8181}
8282
8383// DebugWithContext gets a driver and a logging function, and returns
8484// a new debugged-driver that prints all outgoing operations with context.
85- func DebugWithContext (d Driver , logger func (context.Context , ... interface {} )) Driver {
85+ func DebugWithContext (d Driver , logger func (context.Context , ... any )) Driver {
8686 drv := & DebugDriver {d , logger }
8787 return drv
8888}
8989
9090// Exec logs its params and calls the underlying driver Exec method.
91- func (d * DebugDriver ) Exec (ctx context.Context , query string , args , v interface {} ) error {
91+ func (d * DebugDriver ) Exec (ctx context.Context , query string , args , v any ) error {
9292 d .log (ctx , fmt .Sprintf ("driver.Exec: query=%v args=%v" , query , args ))
9393 return d .Driver .Exec (ctx , query , args , v )
9494}
9595
9696// ExecContext logs its params and calls the underlying driver ExecContext method if it is supported.
97- func (d * DebugDriver ) ExecContext (ctx context.Context , query string , args ... interface {} ) (sql.Result , error ) {
97+ func (d * DebugDriver ) ExecContext (ctx context.Context , query string , args ... any ) (sql.Result , error ) {
9898 drv , ok := d .Driver .(interface {
99- ExecContext (context.Context , string , ... interface {} ) (sql.Result , error )
99+ ExecContext (context.Context , string , ... any ) (sql.Result , error )
100100 })
101101 if ! ok {
102102 return nil , fmt .Errorf ("Driver.ExecContext is not supported" )
@@ -106,15 +106,15 @@ func (d *DebugDriver) ExecContext(ctx context.Context, query string, args ...int
106106}
107107
108108// Query logs its params and calls the underlying driver Query method.
109- func (d * DebugDriver ) Query (ctx context.Context , query string , args , v interface {} ) error {
109+ func (d * DebugDriver ) Query (ctx context.Context , query string , args , v any ) error {
110110 d .log (ctx , fmt .Sprintf ("driver.Query: query=%v args=%v" , query , args ))
111111 return d .Driver .Query (ctx , query , args , v )
112112}
113113
114114// QueryContext logs its params and calls the underlying driver QueryContext method if it is supported.
115- func (d * DebugDriver ) QueryContext (ctx context.Context , query string , args ... interface {} ) (* sql.Rows , error ) {
115+ func (d * DebugDriver ) QueryContext (ctx context.Context , query string , args ... any ) (* sql.Rows , error ) {
116116 drv , ok := d .Driver .(interface {
117- QueryContext (context.Context , string , ... interface {} ) (* sql.Rows , error )
117+ QueryContext (context.Context , string , ... any ) (* sql.Rows , error )
118118 })
119119 if ! ok {
120120 return nil , fmt .Errorf ("Driver.QueryContext is not supported" )
@@ -153,22 +153,22 @@ func (d *DebugDriver) BeginTx(ctx context.Context, opts *sql.TxOptions) (Tx, err
153153
154154// DebugTx is a transaction implementation that logs all transaction operations.
155155type DebugTx struct {
156- Tx // underlying transaction.
157- id string // transaction logging id.
158- log func (context.Context , ... interface {} ) // log function. defaults to fmt.Println.
159- ctx context.Context // underlying transaction context.
156+ Tx // underlying transaction.
157+ id string // transaction logging id.
158+ log func (context.Context , ... any ) // log function. defaults to fmt.Println.
159+ ctx context.Context // underlying transaction context.
160160}
161161
162162// Exec logs its params and calls the underlying transaction Exec method.
163- func (d * DebugTx ) Exec (ctx context.Context , query string , args , v interface {} ) error {
163+ func (d * DebugTx ) Exec (ctx context.Context , query string , args , v any ) error {
164164 d .log (ctx , fmt .Sprintf ("Tx(%s).Exec: query=%v args=%v" , d .id , query , args ))
165165 return d .Tx .Exec (ctx , query , args , v )
166166}
167167
168168// ExecContext logs its params and calls the underlying transaction ExecContext method if it is supported.
169- func (d * DebugTx ) ExecContext (ctx context.Context , query string , args ... interface {} ) (sql.Result , error ) {
169+ func (d * DebugTx ) ExecContext (ctx context.Context , query string , args ... any ) (sql.Result , error ) {
170170 drv , ok := d .Tx .(interface {
171- ExecContext (context.Context , string , ... interface {} ) (sql.Result , error )
171+ ExecContext (context.Context , string , ... any ) (sql.Result , error )
172172 })
173173 if ! ok {
174174 return nil , fmt .Errorf ("Tx.ExecContext is not supported" )
@@ -178,15 +178,15 @@ func (d *DebugTx) ExecContext(ctx context.Context, query string, args ...interfa
178178}
179179
180180// Query logs its params and calls the underlying transaction Query method.
181- func (d * DebugTx ) Query (ctx context.Context , query string , args , v interface {} ) error {
181+ func (d * DebugTx ) Query (ctx context.Context , query string , args , v any ) error {
182182 d .log (ctx , fmt .Sprintf ("Tx(%s).Query: query=%v args=%v" , d .id , query , args ))
183183 return d .Tx .Query (ctx , query , args , v )
184184}
185185
186186// QueryContext logs its params and calls the underlying transaction QueryContext method if it is supported.
187- func (d * DebugTx ) QueryContext (ctx context.Context , query string , args ... interface {} ) (* sql.Rows , error ) {
187+ func (d * DebugTx ) QueryContext (ctx context.Context , query string , args ... any ) (* sql.Rows , error ) {
188188 drv , ok := d .Tx .(interface {
189- QueryContext (context.Context , string , ... interface {} ) (* sql.Rows , error )
189+ QueryContext (context.Context , string , ... any ) (* sql.Rows , error )
190190 })
191191 if ! ok {
192192 return nil , fmt .Errorf ("Tx.QueryContext is not supported" )
0 commit comments