updated deps; regen ent

This commit is contained in:
2022-11-03 02:19:19 +01:00
parent 4b256dd594
commit ff3bbe0037
44 changed files with 938 additions and 2309 deletions

View File

@@ -369,6 +369,11 @@ func (pq *PlayerQuery) Select(fields ...string) *PlayerSelect {
return selbuild
}
// Aggregate returns a PlayerSelect configured with the given aggregations.
func (pq *PlayerQuery) Aggregate(fns ...AggregateFunc) *PlayerSelect {
return pq.Select().Aggregate(fns...)
}
func (pq *PlayerQuery) prepareQuery(ctx context.Context) error {
for _, f := range pq.fields {
if !player.ValidColumn(f) {
@@ -394,10 +399,10 @@ func (pq *PlayerQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Playe
pq.withMatches != nil,
}
)
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*Player).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []interface{}) error {
_spec.Assign = func(columns []string, values []any) error {
node := &Player{config: pq.config}
nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes
@@ -485,18 +490,18 @@ func (pq *PlayerQuery) loadMatches(ctx context.Context, query *MatchQuery, nodes
neighbors, err := query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) {
assign := spec.Assign
values := spec.ScanValues
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(sql.NullInt64)}, values...), nil
return append([]any{new(sql.NullInt64)}, values...), nil
}
spec.Assign = func(columns []string, values []interface{}) error {
spec.Assign = func(columns []string, values []any) error {
outValue := uint64(values[0].(*sql.NullInt64).Int64)
inValue := uint64(values[1].(*sql.NullInt64).Int64)
if nids[inValue] == nil {
nids[inValue] = map[*Player]struct{}{byID[outValue]: struct{}{}}
nids[inValue] = map[*Player]struct{}{byID[outValue]: {}}
return assign(columns[1:], values[1:])
}
nids[inValue][byID[outValue]] = struct{}{}
@@ -531,11 +536,14 @@ func (pq *PlayerQuery) sqlCount(ctx context.Context) (int, error) {
}
func (pq *PlayerQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := pq.sqlCount(ctx)
if err != nil {
switch _, err := pq.FirstID(ctx); {
case IsNotFound(err):
return false, nil
case err != nil:
return false, fmt.Errorf("ent: check existence: %w", err)
default:
return true, nil
}
return n > 0, nil
}
func (pq *PlayerQuery) querySpec() *sqlgraph.QuerySpec {
@@ -645,7 +653,7 @@ func (pgb *PlayerGroupBy) Aggregate(fns ...AggregateFunc) *PlayerGroupBy {
}
// Scan applies the group-by query and scans the result into the given value.
func (pgb *PlayerGroupBy) Scan(ctx context.Context, v interface{}) error {
func (pgb *PlayerGroupBy) Scan(ctx context.Context, v any) error {
query, err := pgb.path(ctx)
if err != nil {
return err
@@ -654,7 +662,7 @@ func (pgb *PlayerGroupBy) Scan(ctx context.Context, v interface{}) error {
return pgb.sqlScan(ctx, v)
}
func (pgb *PlayerGroupBy) sqlScan(ctx context.Context, v interface{}) error {
func (pgb *PlayerGroupBy) sqlScan(ctx context.Context, v any) error {
for _, f := range pgb.fields {
if !player.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
@@ -679,8 +687,6 @@ func (pgb *PlayerGroupBy) sqlQuery() *sql.Selector {
for _, fn := range pgb.fns {
aggregation = append(aggregation, fn(selector))
}
// If no columns were selected in a custom aggregation function, the default
// selection is the fields used for "group-by", and the aggregation functions.
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(pgb.fields)+len(pgb.fns))
for _, f := range pgb.fields {
@@ -700,8 +706,14 @@ type PlayerSelect struct {
sql *sql.Selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (ps *PlayerSelect) Aggregate(fns ...AggregateFunc) *PlayerSelect {
ps.fns = append(ps.fns, fns...)
return ps
}
// Scan applies the selector query and scans the result into the given value.
func (ps *PlayerSelect) Scan(ctx context.Context, v interface{}) error {
func (ps *PlayerSelect) Scan(ctx context.Context, v any) error {
if err := ps.prepareQuery(ctx); err != nil {
return err
}
@@ -709,7 +721,17 @@ func (ps *PlayerSelect) Scan(ctx context.Context, v interface{}) error {
return ps.sqlScan(ctx, v)
}
func (ps *PlayerSelect) sqlScan(ctx context.Context, v interface{}) error {
func (ps *PlayerSelect) sqlScan(ctx context.Context, v any) error {
aggregation := make([]string, 0, len(ps.fns))
for _, fn := range ps.fns {
aggregation = append(aggregation, fn(ps.sql))
}
switch n := len(*ps.selector.flds); {
case n == 0 && len(aggregation) > 0:
ps.sql.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
ps.sql.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := ps.sql.Query()
if err := ps.driver.Query(ctx, query, args, rows); err != nil {