all: gofmt -w -r 'interface{} -> any' (#2874)

This commit is contained in:
Ariel Mashraki
2022-08-19 18:23:04 +03:00
committed by GitHub
parent b6c185a660
commit 2c63d1d70e
619 changed files with 3449 additions and 3449 deletions

View File

@@ -24,8 +24,8 @@ in the LICENSE file in the root directory of this source tree.
{{ end }}
// scanValues returns the types for scanning values from sql.Rows.
func (*{{ $.Name }}) scanValues(columns []string) ([]interface{}, error) {
values := make([]interface{}, len(columns))
func (*{{ $.Name }}) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
{{- range $type, $columns := $ctypes }}
@@ -46,7 +46,7 @@ func (*{{ $.Name }}) scanValues(columns []string) ([]interface{}, error) {
// assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the {{ $.Name }} fields.
func ({{ $receiver }} *{{ $.Name }}) assignValues(columns []string, values []interface{}) error {
func ({{ $receiver }} *{{ $.Name }}) assignValues(columns []string, values []any) error {
if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
}

View File

@@ -17,9 +17,9 @@ in the LICENSE file in the root directory of this source tree.
{{- if $.FeatureEnabled "sql/execquery" }}
// ExecContext allows calling the underlying ExecContext method of the driver if it is supported by it.
// See, database/sql#DB.ExecContext for more information.
func (c *config) ExecContext(ctx context.Context, query string, args ...interface{}) (stdsql.Result, error) {
func (c *config) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error) {
ex, ok := c.driver.(interface {
ExecContext(context.Context, string, ...interface{}) (stdsql.Result, error)
ExecContext(context.Context, string, ...any) (stdsql.Result, error)
})
if !ok {
return nil, fmt.Errorf("Driver.ExecContext is not supported")
@@ -29,9 +29,9 @@ in the LICENSE file in the root directory of this source tree.
// QueryContext allows calling the underlying QueryContext method of the driver if it is supported by it.
// See, database/sql#DB.QueryContext for more information.
func (c *config) QueryContext(ctx context.Context, query string, args ...interface{}) (*stdsql.Rows, error) {
func (c *config) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error) {
q, ok := c.driver.(interface {
QueryContext(context.Context, string, ...interface{}) (*stdsql.Rows, error)
QueryContext(context.Context, string, ...any) (*stdsql.Rows, error)
})
if !ok {
return nil, fmt.Errorf("Driver.QueryContext is not supported")
@@ -46,9 +46,9 @@ in the LICENSE file in the root directory of this source tree.
{{- if $.FeatureEnabled "sql/execquery" }}
// ExecContext allows calling the underlying ExecContext method of the transaction if it is supported by it.
// See, database/sql#Tx.ExecContext for more information.
func (tx *txDriver) ExecContext(ctx context.Context, query string, args ...interface{}) (stdsql.Result, error) {
func (tx *txDriver) ExecContext(ctx context.Context, query string, args ...any) (stdsql.Result, error) {
ex, ok := tx.tx.(interface {
ExecContext(context.Context, string, ...interface{}) (stdsql.Result, error)
ExecContext(context.Context, string, ...any) (stdsql.Result, error)
})
if !ok {
return nil, fmt.Errorf("Tx.ExecContext is not supported")
@@ -58,9 +58,9 @@ in the LICENSE file in the root directory of this source tree.
// QueryContext allows calling the underlying QueryContext method of the transaction if it is supported by it.
// See, database/sql#Tx.QueryContext for more information.
func (tx *txDriver) QueryContext(ctx context.Context, query string, args ...interface{}) (*stdsql.Rows, error) {
func (tx *txDriver) QueryContext(ctx context.Context, query string, args ...any) (*stdsql.Rows, error) {
q, ok := tx.tx.(interface {
QueryContext(context.Context, string, ...interface{}) (*stdsql.Rows, error)
QueryContext(context.Context, string, ...any) (*stdsql.Rows, error)
})
if !ok {
return nil, fmt.Errorf("Tx.QueryContext is not supported")

View File

@@ -10,7 +10,7 @@ in the LICENSE file in the root directory of this source tree.
{{ $builder := pascal $.Scope.Builder }}
{{ $receiver := receiver $builder }}
func ({{ $receiver }} *{{ $builder }}) sqlScan(ctx context.Context, v interface{}) error {
func ({{ $receiver }} *{{ $builder }}) sqlScan(ctx context.Context, v any) error {
for _, f := range {{ $receiver }}.fields {
if !{{ $.Package }}.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}

View File

@@ -18,7 +18,7 @@ in the LICENSE file in the root directory of this source tree.
{{- $storage := $.Scope.Storage -}}
func(s *sql.Selector) {
{{- if $op.Variadic }}
v := make([]interface{}, len({{ $arg }}))
v := make([]any, len({{ $arg }}))
for i := range v {
v[i] = {{ $arg }}[i]
}

View File

@@ -48,10 +48,10 @@ func ({{ $receiver }} *{{ $builder }}) sqlAll(ctx context.Context, hooks ...quer
_spec.Node.Columns = append(_spec.Node.Columns, {{ $.Package }}.ForeignKeys...)
}
{{- end }}
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*{{ $.Name }}).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []interface{}) error {
_spec.Assign = func(columns []string, values []any) error {
node := &{{ $.Name }}{config: {{ $receiver }}.config}
nodes = append(nodes, node)
{{- with $.Edges }}
@@ -125,14 +125,14 @@ func ({{ $receiver }} *{{ $builder }}) sqlAll(ctx context.Context, hooks ...quer
values := spec.ScanValues
{{- $out := "sql.NullInt64" }}{{ if $.ID.UserDefined }}{{ $out = $.ID.ScanType }}{{ end }}
{{- $in := "sql.NullInt64" }}{{ if $e.Type.ID.UserDefined }}{{ $in = $e.Type.ID.ScanType }}{{ end }}
spec.ScanValues = func(columns []string) ([]interface{}, error) {
spec.ScanValues = func(columns []string) ([]any, error) {
values, err := values(columns[1:])
if err != nil {
return nil, err
}
return append([]interface{}{new({{ $out }})}, values...), nil
return append([]any{new({{ $out }})}, values...), nil
}
spec.Assign = func(columns []string, values []interface{}) error {
spec.Assign = func(columns []string, values []any) error {
outValue := {{ with extend $ "Arg" "values[0]" "Field" $.ID "ScanType" $out }}{{ template "dialect/sql/query/eagerloading/m2massign" . }}{{ end }}
inValue := {{ with extend $ "Arg" "values[1]" "Field" $e.Type.ID "ScanType" $in }}{{ template "dialect/sql/query/eagerloading/m2massign" . }}{{ end }}
if nids[inValue] == nil {

View File

@@ -10,7 +10,7 @@ in the LICENSE file in the root directory of this source tree.
{{ $builder := pascal $.Scope.Builder }}
{{ $receiver := receiver $builder }}
func ({{ $receiver }} *{{ $builder }}) sqlScan(ctx context.Context, v interface{}) error {
func ({{ $receiver }} *{{ $builder }}) sqlScan(ctx context.Context, v any) error {
rows := &sql.Rows{}
query, args := {{ $receiver }}.sql.Query()
if err := {{ $receiver }}.driver.Query(ctx, query, args, rows); err != nil {