mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
all: gofmt -w -r 'interface{} -> any' (#2874)
This commit is contained in:
@@ -26,10 +26,10 @@ const (
|
||||
type ExecQuerier interface {
|
||||
// Exec executes a query that does not return records. For example, in SQL, INSERT or UPDATE.
|
||||
// It scans the result into the pointer v. For SQL drivers, it is dialect/sql.Result.
|
||||
Exec(ctx context.Context, query string, args, v interface{}) error
|
||||
Exec(ctx context.Context, query string, args, v any) error
|
||||
// Query executes a query that returns rows, typically a SELECT in SQL.
|
||||
// It scans the result into the pointer v. For SQL drivers, it is *dialect/sql.Rows.
|
||||
Query(ctx context.Context, query string, args, v interface{}) error
|
||||
Query(ctx context.Context, query string, args, v any) error
|
||||
}
|
||||
|
||||
// Driver is the interface that wraps all necessary operations for ent clients.
|
||||
@@ -65,38 +65,38 @@ func NopTx(d Driver) Tx {
|
||||
|
||||
// DebugDriver is a driver that logs all driver operations.
|
||||
type DebugDriver struct {
|
||||
Driver // underlying driver.
|
||||
log func(context.Context, ...interface{}) // log function. defaults to log.Println.
|
||||
Driver // underlying driver.
|
||||
log func(context.Context, ...any) // log function. defaults to log.Println.
|
||||
}
|
||||
|
||||
// Debug gets a driver and an optional logging function, and returns
|
||||
// a new debugged-driver that prints all outgoing operations.
|
||||
func Debug(d Driver, logger ...func(...interface{})) Driver {
|
||||
func Debug(d Driver, logger ...func(...any)) Driver {
|
||||
logf := log.Println
|
||||
if len(logger) == 1 {
|
||||
logf = logger[0]
|
||||
}
|
||||
drv := &DebugDriver{d, func(_ context.Context, v ...interface{}) { logf(v...) }}
|
||||
drv := &DebugDriver{d, func(_ context.Context, v ...any) { logf(v...) }}
|
||||
return drv
|
||||
}
|
||||
|
||||
// DebugWithContext gets a driver and a logging function, and returns
|
||||
// a new debugged-driver that prints all outgoing operations with context.
|
||||
func DebugWithContext(d Driver, logger func(context.Context, ...interface{})) Driver {
|
||||
func DebugWithContext(d Driver, logger func(context.Context, ...any)) Driver {
|
||||
drv := &DebugDriver{d, logger}
|
||||
return drv
|
||||
}
|
||||
|
||||
// Exec logs its params and calls the underlying driver Exec method.
|
||||
func (d *DebugDriver) Exec(ctx context.Context, query string, args, v interface{}) error {
|
||||
func (d *DebugDriver) Exec(ctx context.Context, query string, args, v any) error {
|
||||
d.log(ctx, fmt.Sprintf("driver.Exec: query=%v args=%v", query, args))
|
||||
return d.Driver.Exec(ctx, query, args, v)
|
||||
}
|
||||
|
||||
// ExecContext logs its params and calls the underlying driver ExecContext method if it is supported.
|
||||
func (d *DebugDriver) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) {
|
||||
func (d *DebugDriver) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) {
|
||||
drv, ok := d.Driver.(interface {
|
||||
ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
|
||||
ExecContext(context.Context, string, ...any) (sql.Result, error)
|
||||
})
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("Driver.ExecContext is not supported")
|
||||
@@ -106,15 +106,15 @@ func (d *DebugDriver) ExecContext(ctx context.Context, query string, args ...int
|
||||
}
|
||||
|
||||
// Query logs its params and calls the underlying driver Query method.
|
||||
func (d *DebugDriver) Query(ctx context.Context, query string, args, v interface{}) error {
|
||||
func (d *DebugDriver) Query(ctx context.Context, query string, args, v any) error {
|
||||
d.log(ctx, fmt.Sprintf("driver.Query: query=%v args=%v", query, args))
|
||||
return d.Driver.Query(ctx, query, args, v)
|
||||
}
|
||||
|
||||
// QueryContext logs its params and calls the underlying driver QueryContext method if it is supported.
|
||||
func (d *DebugDriver) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) {
|
||||
func (d *DebugDriver) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error) {
|
||||
drv, ok := d.Driver.(interface {
|
||||
QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
|
||||
QueryContext(context.Context, string, ...any) (*sql.Rows, error)
|
||||
})
|
||||
if !ok {
|
||||
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
|
||||
|
||||
// DebugTx is a transaction implementation that logs all transaction operations.
|
||||
type DebugTx struct {
|
||||
Tx // underlying transaction.
|
||||
id string // transaction logging id.
|
||||
log func(context.Context, ...interface{}) // log function. defaults to fmt.Println.
|
||||
ctx context.Context // underlying transaction context.
|
||||
Tx // underlying transaction.
|
||||
id string // transaction logging id.
|
||||
log func(context.Context, ...any) // log function. defaults to fmt.Println.
|
||||
ctx context.Context // underlying transaction context.
|
||||
}
|
||||
|
||||
// Exec logs its params and calls the underlying transaction Exec method.
|
||||
func (d *DebugTx) Exec(ctx context.Context, query string, args, v interface{}) error {
|
||||
func (d *DebugTx) Exec(ctx context.Context, query string, args, v any) error {
|
||||
d.log(ctx, fmt.Sprintf("Tx(%s).Exec: query=%v args=%v", d.id, query, args))
|
||||
return d.Tx.Exec(ctx, query, args, v)
|
||||
}
|
||||
|
||||
// ExecContext logs its params and calls the underlying transaction ExecContext method if it is supported.
|
||||
func (d *DebugTx) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) {
|
||||
func (d *DebugTx) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error) {
|
||||
drv, ok := d.Tx.(interface {
|
||||
ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
|
||||
ExecContext(context.Context, string, ...any) (sql.Result, error)
|
||||
})
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("Tx.ExecContext is not supported")
|
||||
@@ -178,15 +178,15 @@ func (d *DebugTx) ExecContext(ctx context.Context, query string, args ...interfa
|
||||
}
|
||||
|
||||
// Query logs its params and calls the underlying transaction Query method.
|
||||
func (d *DebugTx) Query(ctx context.Context, query string, args, v interface{}) error {
|
||||
func (d *DebugTx) Query(ctx context.Context, query string, args, v any) error {
|
||||
d.log(ctx, fmt.Sprintf("Tx(%s).Query: query=%v args=%v", d.id, query, args))
|
||||
return d.Tx.Query(ctx, query, args, v)
|
||||
}
|
||||
|
||||
// QueryContext logs its params and calls the underlying transaction QueryContext method if it is supported.
|
||||
func (d *DebugTx) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error) {
|
||||
func (d *DebugTx) QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error) {
|
||||
drv, ok := d.Tx.(interface {
|
||||
QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
|
||||
QueryContext(context.Context, string, ...any) (*sql.Rows, error)
|
||||
})
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("Tx.QueryContext is not supported")
|
||||
|
||||
Reference in New Issue
Block a user