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

@@ -333,6 +333,11 @@ func (rsq *RoundStatsQuery) Select(fields ...string) *RoundStatsSelect {
return selbuild
}
// Aggregate returns a RoundStatsSelect configured with the given aggregations.
func (rsq *RoundStatsQuery) Aggregate(fns ...AggregateFunc) *RoundStatsSelect {
return rsq.Select().Aggregate(fns...)
}
func (rsq *RoundStatsQuery) prepareQuery(ctx context.Context) error {
for _, f := range rsq.fields {
if !roundstats.ValidColumn(f) {
@@ -364,10 +369,10 @@ func (rsq *RoundStatsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*
if withFKs {
_spec.Node.Columns = append(_spec.Node.Columns, roundstats.ForeignKeys...)
}
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
_spec.ScanValues = func(columns []string) ([]any, error) {
return (*RoundStats).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []interface{}) error {
_spec.Assign = func(columns []string, values []any) error {
node := &RoundStats{config: rsq.config}
nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes
@@ -437,11 +442,14 @@ func (rsq *RoundStatsQuery) sqlCount(ctx context.Context) (int, error) {
}
func (rsq *RoundStatsQuery) sqlExist(ctx context.Context) (bool, error) {
n, err := rsq.sqlCount(ctx)
if err != nil {
switch _, err := rsq.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 (rsq *RoundStatsQuery) querySpec() *sqlgraph.QuerySpec {
@@ -551,7 +559,7 @@ func (rsgb *RoundStatsGroupBy) Aggregate(fns ...AggregateFunc) *RoundStatsGroupB
}
// Scan applies the group-by query and scans the result into the given value.
func (rsgb *RoundStatsGroupBy) Scan(ctx context.Context, v interface{}) error {
func (rsgb *RoundStatsGroupBy) Scan(ctx context.Context, v any) error {
query, err := rsgb.path(ctx)
if err != nil {
return err
@@ -560,7 +568,7 @@ func (rsgb *RoundStatsGroupBy) Scan(ctx context.Context, v interface{}) error {
return rsgb.sqlScan(ctx, v)
}
func (rsgb *RoundStatsGroupBy) sqlScan(ctx context.Context, v interface{}) error {
func (rsgb *RoundStatsGroupBy) sqlScan(ctx context.Context, v any) error {
for _, f := range rsgb.fields {
if !roundstats.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)}
@@ -585,8 +593,6 @@ func (rsgb *RoundStatsGroupBy) sqlQuery() *sql.Selector {
for _, fn := range rsgb.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(rsgb.fields)+len(rsgb.fns))
for _, f := range rsgb.fields {
@@ -606,8 +612,14 @@ type RoundStatsSelect struct {
sql *sql.Selector
}
// Aggregate adds the given aggregation functions to the selector query.
func (rss *RoundStatsSelect) Aggregate(fns ...AggregateFunc) *RoundStatsSelect {
rss.fns = append(rss.fns, fns...)
return rss
}
// Scan applies the selector query and scans the result into the given value.
func (rss *RoundStatsSelect) Scan(ctx context.Context, v interface{}) error {
func (rss *RoundStatsSelect) Scan(ctx context.Context, v any) error {
if err := rss.prepareQuery(ctx); err != nil {
return err
}
@@ -615,7 +627,17 @@ func (rss *RoundStatsSelect) Scan(ctx context.Context, v interface{}) error {
return rss.sqlScan(ctx, v)
}
func (rss *RoundStatsSelect) sqlScan(ctx context.Context, v interface{}) error {
func (rss *RoundStatsSelect) sqlScan(ctx context.Context, v any) error {
aggregation := make([]string, 0, len(rss.fns))
for _, fn := range rss.fns {
aggregation = append(aggregation, fn(rss.sql))
}
switch n := len(*rss.selector.flds); {
case n == 0 && len(aggregation) > 0:
rss.sql.Select(aggregation...)
case n != 0 && len(aggregation) > 0:
rss.sql.AppendSelect(aggregation...)
}
rows := &sql.Rows{}
query, args := rss.sql.Query()
if err := rss.driver.Query(ctx, query, args, rows); err != nil {