updated deps; regen ent
This commit is contained in:
@@ -369,6 +369,11 @@ func (mq *MatchQuery) Select(fields ...string) *MatchSelect {
|
||||
return selbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a MatchSelect configured with the given aggregations.
|
||||
func (mq *MatchQuery) Aggregate(fns ...AggregateFunc) *MatchSelect {
|
||||
return mq.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (mq *MatchQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, f := range mq.fields {
|
||||
if !match.ValidColumn(f) {
|
||||
@@ -394,10 +399,10 @@ func (mq *MatchQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Match,
|
||||
mq.withPlayers != nil,
|
||||
}
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*Match).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []interface{}) error {
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &Match{config: mq.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
@@ -485,18 +490,18 @@ func (mq *MatchQuery) loadPlayers(ctx context.Context, query *PlayerQuery, 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[*Match]struct{}{byID[outValue]: struct{}{}}
|
||||
nids[inValue] = map[*Match]struct{}{byID[outValue]: {}}
|
||||
return assign(columns[1:], values[1:])
|
||||
}
|
||||
nids[inValue][byID[outValue]] = struct{}{}
|
||||
@@ -531,11 +536,14 @@ func (mq *MatchQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
}
|
||||
|
||||
func (mq *MatchQuery) sqlExist(ctx context.Context) (bool, error) {
|
||||
n, err := mq.sqlCount(ctx)
|
||||
if err != nil {
|
||||
switch _, err := mq.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 (mq *MatchQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
@@ -645,7 +653,7 @@ func (mgb *MatchGroupBy) Aggregate(fns ...AggregateFunc) *MatchGroupBy {
|
||||
}
|
||||
|
||||
// Scan applies the group-by query and scans the result into the given value.
|
||||
func (mgb *MatchGroupBy) Scan(ctx context.Context, v interface{}) error {
|
||||
func (mgb *MatchGroupBy) Scan(ctx context.Context, v any) error {
|
||||
query, err := mgb.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -654,7 +662,7 @@ func (mgb *MatchGroupBy) Scan(ctx context.Context, v interface{}) error {
|
||||
return mgb.sqlScan(ctx, v)
|
||||
}
|
||||
|
||||
func (mgb *MatchGroupBy) sqlScan(ctx context.Context, v interface{}) error {
|
||||
func (mgb *MatchGroupBy) sqlScan(ctx context.Context, v any) error {
|
||||
for _, f := range mgb.fields {
|
||||
if !match.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
|
||||
@@ -679,8 +687,6 @@ func (mgb *MatchGroupBy) sqlQuery() *sql.Selector {
|
||||
for _, fn := range mgb.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(mgb.fields)+len(mgb.fns))
|
||||
for _, f := range mgb.fields {
|
||||
@@ -700,8 +706,14 @@ type MatchSelect struct {
|
||||
sql *sql.Selector
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (ms *MatchSelect) Aggregate(fns ...AggregateFunc) *MatchSelect {
|
||||
ms.fns = append(ms.fns, fns...)
|
||||
return ms
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ms *MatchSelect) Scan(ctx context.Context, v interface{}) error {
|
||||
func (ms *MatchSelect) Scan(ctx context.Context, v any) error {
|
||||
if err := ms.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -709,7 +721,17 @@ func (ms *MatchSelect) Scan(ctx context.Context, v interface{}) error {
|
||||
return ms.sqlScan(ctx, v)
|
||||
}
|
||||
|
||||
func (ms *MatchSelect) sqlScan(ctx context.Context, v interface{}) error {
|
||||
func (ms *MatchSelect) sqlScan(ctx context.Context, v any) error {
|
||||
aggregation := make([]string, 0, len(ms.fns))
|
||||
for _, fn := range ms.fns {
|
||||
aggregation = append(aggregation, fn(ms.sql))
|
||||
}
|
||||
switch n := len(*ms.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
ms.sql.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
ms.sql.AppendSelect(aggregation...)
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := ms.sql.Query()
|
||||
if err := ms.driver.Query(ctx, query, args, rows); err != nil {
|
||||
|
Reference in New Issue
Block a user