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

@@ -27,7 +27,7 @@ import (
type Querier interface {
// Query returns the query representation of the element
// and its arguments (if any).
Query() (string, []interface{})
Query() (string, []any)
}
// querierErr allowed propagate Querier's inner error
@@ -79,7 +79,7 @@ func (c *ColumnBuilder) Check(check func(*Builder)) *ColumnBuilder {
}
// Query returns query representation of a Column.
func (c *ColumnBuilder) Query() (string, []interface{}) {
func (c *ColumnBuilder) Query() (string, []any) {
c.Ident(c.name)
if c.typ != "" {
if c.postgres() && c.modify {
@@ -207,7 +207,7 @@ func (t *TableBuilder) Options(s string) *TableBuilder {
//
// (table definition)
// [charset and collation]
func (t *TableBuilder) Query() (string, []interface{}) {
func (t *TableBuilder) Query() (string, []any) {
t.WriteString("CREATE TABLE ")
if t.exists {
t.WriteString("IF NOT EXISTS ")
@@ -252,7 +252,7 @@ type DescribeBuilder struct {
func Describe(name string) *DescribeBuilder { return &DescribeBuilder{name: name} }
// Query returns query representation of a `DESCRIBE` statement.
func (t *DescribeBuilder) Query() (string, []interface{}) {
func (t *DescribeBuilder) Query() (string, []any) {
t.WriteString("DESCRIBE ")
t.Ident(t.name)
return t.String(), nil
@@ -369,7 +369,7 @@ func (t *TableAlter) DropForeignKey(ident string) *TableAlter {
//
// ALTER TABLE name
// [alter_specification]
func (t *TableAlter) Query() (string, []interface{}) {
func (t *TableAlter) Query() (string, []any) {
t.WriteString("ALTER TABLE ")
t.Ident(t.name)
t.Pad()
@@ -400,7 +400,7 @@ func (i *IndexAlter) Rename(name string) *IndexAlter {
//
// ALTER INDEX name
// [alter_specification]
func (i *IndexAlter) Query() (string, []interface{}) {
func (i *IndexAlter) Query() (string, []any) {
i.WriteString("ALTER INDEX ")
i.Ident(i.name)
i.Pad()
@@ -462,7 +462,7 @@ func (fk *ForeignKeyBuilder) OnUpdate(action string) *ForeignKeyBuilder {
}
// Query returns query representation of a foreign key constraint.
func (fk *ForeignKeyBuilder) Query() (string, []interface{}) {
func (fk *ForeignKeyBuilder) Query() (string, []any) {
if fk.symbol != "" {
fk.Ident(fk.symbol).Pad()
}
@@ -502,7 +502,7 @@ func (r *ReferenceBuilder) Columns(s ...string) *ReferenceBuilder {
}
// Query returns query representation of a reference clause.
func (r *ReferenceBuilder) Query() (string, []interface{}) {
func (r *ReferenceBuilder) Query() (string, []any) {
r.WriteString("REFERENCES ")
r.Ident(r.table)
r.Nested(func(b *Builder) {
@@ -576,7 +576,7 @@ func (i *IndexBuilder) Columns(columns ...string) *IndexBuilder {
}
// Query returns query representation of a reference clause.
func (i *IndexBuilder) Query() (string, []interface{}) {
func (i *IndexBuilder) Query() (string, []any) {
i.WriteString("CREATE ")
if i.unique {
i.WriteString("UNIQUE ")
@@ -641,7 +641,7 @@ func (d *DropIndexBuilder) Table(table string) *DropIndexBuilder {
// Query returns query representation of a reference clause.
//
// DROP INDEX index_name [ON table_name]
func (d *DropIndexBuilder) Query() (string, []interface{}) {
func (d *DropIndexBuilder) Query() (string, []any) {
d.WriteString("DROP INDEX ")
d.Ident(d.name)
if d.table != "" {
@@ -659,7 +659,7 @@ type InsertBuilder struct {
columns []string
defaults bool
returning []string
values [][]interface{}
values [][]any
conflict *conflict
}
@@ -680,10 +680,10 @@ func (i *InsertBuilder) Schema(name string) *InsertBuilder {
}
// Set is a syntactic sugar API for inserting only one row.
func (i *InsertBuilder) Set(column string, v interface{}) *InsertBuilder {
func (i *InsertBuilder) Set(column string, v any) *InsertBuilder {
i.columns = append(i.columns, column)
if len(i.values) == 0 {
i.values = append(i.values, []interface{}{v})
i.values = append(i.values, []any{v})
} else {
i.values[0] = append(i.values[0], v)
}
@@ -697,7 +697,7 @@ func (i *InsertBuilder) Columns(columns ...string) *InsertBuilder {
}
// Values append a value tuple for the insert statement.
func (i *InsertBuilder) Values(values ...interface{}) *InsertBuilder {
func (i *InsertBuilder) Values(values ...any) *InsertBuilder {
i.values = append(i.values, values)
return i
}
@@ -909,13 +909,13 @@ func (u *UpdateSet) UpdateColumns() []string {
}
// Set sets a column to a given value.
func (u *UpdateSet) Set(column string, v interface{}) *UpdateSet {
func (u *UpdateSet) Set(column string, v any) *UpdateSet {
u.update.Set(column, v)
return u
}
// Add adds a numeric value to the given column.
func (u *UpdateSet) Add(column string, v interface{}) *UpdateSet {
func (u *UpdateSet) Add(column string, v any) *UpdateSet {
u.update.Add(column, v)
return u
}
@@ -947,7 +947,7 @@ func (u *UpdateSet) SetExcluded(name string) *UpdateSet {
}
// Query returns query representation of an `INSERT INTO` statement.
func (i *InsertBuilder) Query() (string, []interface{}) {
func (i *InsertBuilder) Query() (string, []any) {
i.WriteString("INSERT INTO ")
i.writeSchema(i.schema)
i.Ident(i.table).Pad()
@@ -1031,8 +1031,8 @@ type UpdateBuilder struct {
where *Predicate
nulls []string
columns []string
values []interface{}
order []interface{}
values []any
order []any
}
// Update creates a builder for the `UPDATE` statement.
@@ -1048,7 +1048,7 @@ func (u *UpdateBuilder) Schema(name string) *UpdateBuilder {
// Set sets a column to a given value. If `Set` was called before with
// the same column name, it overrides the value of the previous call.
func (u *UpdateBuilder) Set(column string, v interface{}) *UpdateBuilder {
func (u *UpdateBuilder) Set(column string, v any) *UpdateBuilder {
for i := range u.columns {
if column == u.columns[i] {
u.values[i] = v
@@ -1062,7 +1062,7 @@ func (u *UpdateBuilder) Set(column string, v interface{}) *UpdateBuilder {
// Add adds a numeric value to the given column. Note that, calling Set(c)
// after Add(c) will erase previous calls with c from the builder.
func (u *UpdateBuilder) Add(column string, v interface{}) *UpdateBuilder {
func (u *UpdateBuilder) Add(column string, v any) *UpdateBuilder {
u.columns = append(u.columns, column)
u.values = append(u.values, ExprFunc(func(b *Builder) {
b.WriteString("COALESCE")
@@ -1119,7 +1119,7 @@ func (u *UpdateBuilder) OrderBy(columns ...string) *UpdateBuilder {
}
// Query returns query representation of an `UPDATE` statement.
func (u *UpdateBuilder) Query() (string, []interface{}) {
func (u *UpdateBuilder) Query() (string, []any) {
b := u.Builder.clone()
b.WriteString("UPDATE ")
b.writeSchema(u.schema)
@@ -1207,7 +1207,7 @@ func (d *DeleteBuilder) FromSelect(s *Selector) *DeleteBuilder {
}
// Query returns query representation of a `DELETE` statement.
func (d *DeleteBuilder) Query() (string, []interface{}) {
func (d *DeleteBuilder) Query() (string, []any) {
d.WriteString("DELETE FROM ")
d.writeSchema(d.schema)
d.Ident(d.table)
@@ -1235,7 +1235,7 @@ func P(fns ...func(*Builder)) *Predicate {
// ExprP creates a new predicate from the given expression.
//
// ExprP("A = ? AND B > ?", args...)
func ExprP(exr string, args ...interface{}) *Predicate {
func ExprP(exr string, args ...any) *Predicate {
return P(func(b *Builder) {
b.Join(Expr(exr, args...))
})
@@ -1330,12 +1330,12 @@ func (p *Predicate) IsFalse(col string) *Predicate {
}
// EQ returns a "=" predicate.
func EQ(col string, value interface{}) *Predicate {
func EQ(col string, value any) *Predicate {
return P().EQ(col, value)
}
// EQ appends a "=" predicate.
func (p *Predicate) EQ(col string, arg interface{}) *Predicate {
func (p *Predicate) EQ(col string, arg any) *Predicate {
// A small optimization to avoid passing
// arguments when it can be avoided.
switch arg := arg.(type) {
@@ -1364,12 +1364,12 @@ func (p *Predicate) ColumnsEQ(col1, col2 string) *Predicate {
}
// NEQ returns a "<>" predicate.
func NEQ(col string, value interface{}) *Predicate {
func NEQ(col string, value any) *Predicate {
return P().NEQ(col, value)
}
// NEQ appends a "<>" predicate.
func (p *Predicate) NEQ(col string, arg interface{}) *Predicate {
func (p *Predicate) NEQ(col string, arg any) *Predicate {
// A small optimization to avoid passing
// arguments when it can be avoided.
switch arg := arg.(type) {
@@ -1398,12 +1398,12 @@ func (p *Predicate) ColumnsNEQ(col1, col2 string) *Predicate {
}
// LT returns a "<" predicate.
func LT(col string, value interface{}) *Predicate {
func LT(col string, value any) *Predicate {
return P().LT(col, value)
}
// LT appends a "<" predicate.
func (p *Predicate) LT(col string, arg interface{}) *Predicate {
func (p *Predicate) LT(col string, arg any) *Predicate {
return p.Append(func(b *Builder) {
b.Ident(col)
p.WriteOp(OpLT)
@@ -1422,12 +1422,12 @@ func (p *Predicate) ColumnsLT(col1, col2 string) *Predicate {
}
// LTE returns a "<=" predicate.
func LTE(col string, value interface{}) *Predicate {
func LTE(col string, value any) *Predicate {
return P().LTE(col, value)
}
// LTE appends a "<=" predicate.
func (p *Predicate) LTE(col string, arg interface{}) *Predicate {
func (p *Predicate) LTE(col string, arg any) *Predicate {
return p.Append(func(b *Builder) {
b.Ident(col)
p.WriteOp(OpLTE)
@@ -1446,12 +1446,12 @@ func (p *Predicate) ColumnsLTE(col1, col2 string) *Predicate {
}
// GT returns a ">" predicate.
func GT(col string, value interface{}) *Predicate {
func GT(col string, value any) *Predicate {
return P().GT(col, value)
}
// GT appends a ">" predicate.
func (p *Predicate) GT(col string, arg interface{}) *Predicate {
func (p *Predicate) GT(col string, arg any) *Predicate {
return p.Append(func(b *Builder) {
b.Ident(col)
p.WriteOp(OpGT)
@@ -1470,12 +1470,12 @@ func (p *Predicate) ColumnsGT(col1, col2 string) *Predicate {
}
// GTE returns a ">=" predicate.
func GTE(col string, value interface{}) *Predicate {
func GTE(col string, value any) *Predicate {
return P().GTE(col, value)
}
// GTE appends a ">=" predicate.
func (p *Predicate) GTE(col string, arg interface{}) *Predicate {
func (p *Predicate) GTE(col string, arg any) *Predicate {
return p.Append(func(b *Builder) {
b.Ident(col)
p.WriteOp(OpGTE)
@@ -1518,12 +1518,12 @@ func (p *Predicate) IsNull(col string) *Predicate {
}
// In returns the `IN` predicate.
func In(col string, args ...interface{}) *Predicate {
func In(col string, args ...any) *Predicate {
return P().In(col, args...)
}
// In appends the `IN` predicate.
func (p *Predicate) In(col string, args ...interface{}) *Predicate {
func (p *Predicate) In(col string, args ...any) *Predicate {
// If no arguments were provided, append the FALSE constant, since
// we cannot apply "IN ()". This will make this predicate falsy.
if len(args) == 0 {
@@ -1553,7 +1553,7 @@ func InValues(col string, args ...driver.Value) *Predicate {
// InInts adds the `IN` predicate for ints.
func (p *Predicate) InInts(col string, args ...int) *Predicate {
iface := make([]interface{}, len(args))
iface := make([]any, len(args))
for i := range args {
iface[i] = args[i]
}
@@ -1562,7 +1562,7 @@ func (p *Predicate) InInts(col string, args ...int) *Predicate {
// InValues adds the `IN` predicate for slice of driver.Value.
func (p *Predicate) InValues(col string, args ...driver.Value) *Predicate {
iface := make([]interface{}, len(args))
iface := make([]any, len(args))
for i := range args {
iface[i] = args[i]
}
@@ -1570,12 +1570,12 @@ func (p *Predicate) InValues(col string, args ...driver.Value) *Predicate {
}
// NotIn returns the `Not IN` predicate.
func NotIn(col string, args ...interface{}) *Predicate {
func NotIn(col string, args ...any) *Predicate {
return P().NotIn(col, args...)
}
// NotIn appends the `Not IN` predicate.
func (p *Predicate) NotIn(col string, args ...interface{}) *Predicate {
func (p *Predicate) NotIn(col string, args ...any) *Predicate {
// If no arguments were provided, append the NOT FALSE constant, since
// we cannot apply "NOT IN ()". This will make this predicate truthy.
if len(args) == 0 {
@@ -1755,16 +1755,16 @@ func (p *Predicate) ContainsFold(col, substr string) *Predicate {
}
// CompositeGT returns a composite ">" predicate
func CompositeGT(columns []string, args ...interface{}) *Predicate {
func CompositeGT(columns []string, args ...any) *Predicate {
return P().CompositeGT(columns, args...)
}
// CompositeLT returns a composite "<" predicate
func CompositeLT(columns []string, args ...interface{}) *Predicate {
func CompositeLT(columns []string, args ...any) *Predicate {
return P().CompositeLT(columns, args...)
}
func (p *Predicate) compositeP(operator string, columns []string, args ...interface{}) *Predicate {
func (p *Predicate) compositeP(operator string, columns []string, args ...any) *Predicate {
return p.Append(func(b *Builder) {
b.Nested(func(nb *Builder) {
nb.IdentComma(columns...)
@@ -1777,13 +1777,13 @@ func (p *Predicate) compositeP(operator string, columns []string, args ...interf
}
// CompositeGT returns a composite ">" predicate.
func (p *Predicate) CompositeGT(columns []string, args ...interface{}) *Predicate {
func (p *Predicate) CompositeGT(columns []string, args ...any) *Predicate {
const operator = " > "
return p.compositeP(operator, columns, args...)
}
// CompositeLT appends a composite "<" predicate.
func (p *Predicate) CompositeLT(columns []string, args ...interface{}) *Predicate {
func (p *Predicate) CompositeLT(columns []string, args ...any) *Predicate {
const operator = " < "
return p.compositeP(operator, columns, args...)
}
@@ -1796,7 +1796,7 @@ func (p *Predicate) Append(f func(*Builder)) *Predicate {
}
// Query returns query representation of a predicate.
func (p *Predicate) Query() (string, []interface{}) {
func (p *Predicate) Query() (string, []any) {
if p.Len() > 0 || len(p.args) > 0 {
p.Reset()
p.args = nil
@@ -1808,7 +1808,7 @@ func (p *Predicate) Query() (string, []interface{}) {
}
// arg calls Builder.Arg, but wraps `a` with parens in case of a Selector.
func (*Predicate) arg(b *Builder, a interface{}) {
func (*Predicate) arg(b *Builder, a any) {
switch a.(type) {
case *Selector:
b.Nested(func(b *Builder) {
@@ -2084,13 +2084,13 @@ type Selector struct {
// generated code such as alternate table schemas.
ctx context.Context
as string
selection []interface{}
selection []any
from TableView
joins []join
where *Predicate
or bool
not bool
order []interface{}
order []any
group []string
having *Predicate
limit *int
@@ -2140,7 +2140,7 @@ func SelectExpr(exprs ...Querier) *Selector {
// Select changes the columns selection of the SELECT statement.
// Empty selection means all columns *.
func (s *Selector) Select(columns ...string) *Selector {
s.selection = make([]interface{}, len(columns))
s.selection = make([]any, len(columns))
for i := range columns {
s.selection[i] = columns[i]
}
@@ -2158,7 +2158,7 @@ func (s *Selector) AppendSelect(columns ...string) *Selector {
// SelectExpr changes the columns selection of the SELECT statement
// with custom list of expressions.
func (s *Selector) SelectExpr(exprs ...Querier) *Selector {
s.selection = make([]interface{}, len(exprs))
s.selection = make([]any, len(exprs))
for i := range exprs {
s.selection[i] = exprs[i]
}
@@ -2576,8 +2576,8 @@ func (s *Selector) Clone() *Selector {
having: s.having.clone(),
joins: append([]join{}, joins...),
group: append([]string{}, s.group...),
order: append([]interface{}{}, s.order...),
selection: append([]interface{}{}, s.selection...),
order: append([]any{}, s.order...),
selection: append([]any{}, s.selection...),
}
}
@@ -2637,7 +2637,7 @@ func (s *Selector) Having(p *Predicate) *Selector {
}
// Query returns query representation of a `SELECT` statement.
func (s *Selector) Query() (string, []interface{}) {
func (s *Selector) Query() (string, []any) {
b := s.Builder.clone()
s.joinPrefix(&b)
b.WriteString("SELECT ")
@@ -2765,7 +2765,7 @@ func (s *Selector) joinUnion(b *Builder) {
}
}
func joinOrder(order []interface{}, b *Builder) {
func joinOrder(order []any, b *Builder) {
if len(order) == 0 {
return
}
@@ -2868,7 +2868,7 @@ func (w *WithBuilder) C(column string) string {
}
// Query returns query representation of a `WITH` clause.
func (w *WithBuilder) Query() (string, []interface{}) {
func (w *WithBuilder) Query() (string, []any) {
w.WriteString("WITH ")
if w.recursive {
w.WriteString("RECURSIVE ")
@@ -2901,7 +2901,7 @@ type WindowBuilder struct {
Builder
fn string // e.g. ROW_NUMBER(), RANK().
partition func(*Builder)
order []interface{}
order []any
}
// RowNumber returns a new window clause with the ROW_NUMBER() as a function.
@@ -2947,7 +2947,7 @@ func (w *WindowBuilder) OrderExpr(exprs ...Querier) *WindowBuilder {
}
// Query returns query representation of the window function.
func (w *WindowBuilder) Query() (string, []interface{}) {
func (w *WindowBuilder) Query() (string, []any) {
w.WriteString(w.fn)
w.WriteString("() OVER ")
w.Nested(func(b *Builder) {
@@ -2968,7 +2968,7 @@ type Wrapper struct {
}
// Query returns query representation of a wrapped Querier.
func (w *Wrapper) Query() (string, []interface{}) {
func (w *Wrapper) Query() (string, []any) {
query, args := w.wrapped.Query()
return fmt.Sprintf(w.format, query), args
}
@@ -3009,17 +3009,17 @@ func Raw(s string) Querier { return &raw{s} }
type raw struct{ s string }
func (r *raw) Query() (string, []interface{}) { return r.s, nil }
func (r *raw) Query() (string, []any) { return r.s, nil }
// Expr returns an SQL expression that implements the Querier interface.
func Expr(exr string, args ...interface{}) Querier { return &expr{s: exr, args: args} }
func Expr(exr string, args ...any) Querier { return &expr{s: exr, args: args} }
type expr struct {
s string
args []interface{}
args []any
}
func (e *expr) Query() (string, []interface{}) { return e.s, e.args }
func (e *expr) Query() (string, []any) { return e.s, e.args }
// ExprFunc returns an expression function that implements the Querier interface.
//
@@ -3038,7 +3038,7 @@ type exprFunc struct {
fn func(*Builder)
}
func (e *exprFunc) Query() (string, []interface{}) {
func (e *exprFunc) Query() (string, []any) {
e.fn(&e.Builder)
return e.Builder.Query()
}
@@ -3047,7 +3047,7 @@ func (e *exprFunc) Query() (string, []interface{}) {
type Queries []Querier
// Query returns query representation of Queriers.
func (n Queries) Query() (string, []interface{}) {
func (n Queries) Query() (string, []any) {
b := &Builder{}
for i := range n {
if i > 0 {
@@ -3064,7 +3064,7 @@ func (n Queries) Query() (string, []interface{}) {
type Builder struct {
sb *strings.Builder // underlying builder.
dialect string // configured dialect.
args []interface{} // query parameters.
args []any // query parameters.
total int // total number of parameters in query tree.
errs []error // errors that added during the query construction.
qualifier string // qualifier to prefix identifiers (e.g. table name).
@@ -3267,7 +3267,7 @@ type (
)
// Arg appends an input argument to the builder.
func (b *Builder) Arg(a interface{}) *Builder {
func (b *Builder) Arg(a any) *Builder {
switch a := a.(type) {
case nil:
b.WriteString("NULL")
@@ -3298,7 +3298,7 @@ func (b *Builder) Arg(a interface{}) *Builder {
}
// Args appends a list of arguments to the builder.
func (b *Builder) Args(a ...interface{}) *Builder {
func (b *Builder) Args(a ...any) *Builder {
for i := range a {
if i > 0 {
b.Comma()
@@ -3386,7 +3386,7 @@ func (b *Builder) SetTotal(total int) {
}
// Query implements the Querier interface.
func (b Builder) Query() (string, []interface{}) {
func (b Builder) Query() (string, []any) {
return b.String(), b.args
}