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