updated deps; regen ent

This commit is contained in:
2022-08-15 12:10:15 +02:00
parent b8b9f82067
commit 657ca32bb3
66 changed files with 1578 additions and 4744 deletions

View File

@@ -1,10 +1,9 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"math"
@@ -19,16 +18,15 @@ import (
// SprayQuery is the builder for querying Spray entities.
type SprayQuery struct {
config
limit *int
offset *int
unique *bool
order []OrderFunc
fields []string
predicates []predicate.Spray
// eager-loading edges.
limit *int
offset *int
unique *bool
order []OrderFunc
fields []string
predicates []predicate.Spray
withMatchPlayers *MatchPlayerQuery
withFKs bool
modifiers []func(s *sql.Selector)
modifiers []func(*sql.Selector)
// intermediate query (i.e. traversal path).
sql *sql.Selector
path func(context.Context) (*sql.Selector, error)
@@ -301,17 +299,18 @@ func (sq *SprayQuery) WithMatchPlayers(opts ...func(*MatchPlayerQuery)) *SprayQu
// GroupBy(spray.FieldWeapon).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
//
func (sq *SprayQuery) GroupBy(field string, fields ...string) *SprayGroupBy {
group := &SprayGroupBy{config: sq.config}
group.fields = append([]string{field}, fields...)
group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
grbuild := &SprayGroupBy{config: sq.config}
grbuild.fields = append([]string{field}, fields...)
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) {
if err := sq.prepareQuery(ctx); err != nil {
return nil, err
}
return sq.sqlQuery(ctx), nil
}
return group
grbuild.label = spray.Label
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
@@ -326,10 +325,12 @@ func (sq *SprayQuery) GroupBy(field string, fields ...string) *SprayGroupBy {
// client.Spray.Query().
// Select(spray.FieldWeapon).
// Scan(ctx, &v)
//
func (sq *SprayQuery) Select(fields ...string) *SpraySelect {
sq.fields = append(sq.fields, fields...)
return &SpraySelect{SprayQuery: sq}
selbuild := &SpraySelect{SprayQuery: sq}
selbuild.label = spray.Label
selbuild.flds, selbuild.scan = &sq.fields, selbuild.Scan
return selbuild
}
func (sq *SprayQuery) prepareQuery(ctx context.Context) error {
@@ -348,7 +349,7 @@ func (sq *SprayQuery) prepareQuery(ctx context.Context) error {
return nil
}
func (sq *SprayQuery) sqlAll(ctx context.Context) ([]*Spray, error) {
func (sq *SprayQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Spray, error) {
var (
nodes = []*Spray{}
withFKs = sq.withFKs
@@ -364,58 +365,63 @@ func (sq *SprayQuery) sqlAll(ctx context.Context) ([]*Spray, error) {
_spec.Node.Columns = append(_spec.Node.Columns, spray.ForeignKeys...)
}
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
node := &Spray{config: sq.config}
nodes = append(nodes, node)
return node.scanValues(columns)
return (*Spray).scanValues(nil, columns)
}
_spec.Assign = func(columns []string, values []interface{}) error {
if len(nodes) == 0 {
return fmt.Errorf("ent: Assign called without calling ScanValues")
}
node := nodes[len(nodes)-1]
node := &Spray{config: sq.config}
nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
}
if len(sq.modifiers) > 0 {
_spec.Modifiers = sq.modifiers
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, sq.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
if query := sq.withMatchPlayers; query != nil {
ids := make([]int, 0, len(nodes))
nodeids := make(map[int][]*Spray)
for i := range nodes {
if nodes[i].match_player_spray == nil {
continue
}
fk := *nodes[i].match_player_spray
if _, ok := nodeids[fk]; !ok {
ids = append(ids, fk)
}
nodeids[fk] = append(nodeids[fk], nodes[i])
}
query.Where(matchplayer.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
if err := sq.loadMatchPlayers(ctx, query, nodes, nil,
func(n *Spray, e *MatchPlayer) { n.Edges.MatchPlayers = e }); err != nil {
return nil, err
}
for _, n := range neighbors {
nodes, ok := nodeids[n.ID]
if !ok {
return nil, fmt.Errorf(`unexpected foreign-key "match_player_spray" returned %v`, n.ID)
}
for i := range nodes {
nodes[i].Edges.MatchPlayers = n
}
}
return nodes, nil
}
func (sq *SprayQuery) loadMatchPlayers(ctx context.Context, query *MatchPlayerQuery, nodes []*Spray, init func(*Spray), assign func(*Spray, *MatchPlayer)) error {
ids := make([]int, 0, len(nodes))
nodeids := make(map[int][]*Spray)
for i := range nodes {
if nodes[i].match_player_spray == nil {
continue
}
fk := *nodes[i].match_player_spray
if _, ok := nodeids[fk]; !ok {
ids = append(ids, fk)
}
nodeids[fk] = append(nodeids[fk], nodes[i])
}
query.Where(matchplayer.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
nodes, ok := nodeids[n.ID]
if !ok {
return fmt.Errorf(`unexpected foreign-key "match_player_spray" returned %v`, n.ID)
}
for i := range nodes {
assign(nodes[i], n)
}
}
return nodes, nil
return nil
}
func (sq *SprayQuery) sqlCount(ctx context.Context) (int, error) {
@@ -530,6 +536,7 @@ func (sq *SprayQuery) Modify(modifiers ...func(s *sql.Selector)) *SpraySelect {
// SprayGroupBy is the group-by builder for Spray entities.
type SprayGroupBy struct {
config
selector
fields []string
fns []AggregateFunc
// intermediate query (i.e. traversal path).
@@ -553,209 +560,6 @@ func (sgb *SprayGroupBy) Scan(ctx context.Context, v interface{}) error {
return sgb.sqlScan(ctx, v)
}
// ScanX is like Scan, but panics if an error occurs.
func (sgb *SprayGroupBy) ScanX(ctx context.Context, v interface{}) {
if err := sgb.Scan(ctx, v); err != nil {
panic(err)
}
}
// Strings returns list of strings from group-by.
// It is only allowed when executing a group-by query with one field.
func (sgb *SprayGroupBy) Strings(ctx context.Context) ([]string, error) {
if len(sgb.fields) > 1 {
return nil, errors.New("ent: SprayGroupBy.Strings is not achievable when grouping more than 1 field")
}
var v []string
if err := sgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (sgb *SprayGroupBy) StringsX(ctx context.Context) []string {
v, err := sgb.Strings(ctx)
if err != nil {
panic(err)
}
return v
}
// String returns a single string from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (sgb *SprayGroupBy) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = sgb.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{spray.Label}
default:
err = fmt.Errorf("ent: SprayGroupBy.Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (sgb *SprayGroupBy) StringX(ctx context.Context) string {
v, err := sgb.String(ctx)
if err != nil {
panic(err)
}
return v
}
// Ints returns list of ints from group-by.
// It is only allowed when executing a group-by query with one field.
func (sgb *SprayGroupBy) Ints(ctx context.Context) ([]int, error) {
if len(sgb.fields) > 1 {
return nil, errors.New("ent: SprayGroupBy.Ints is not achievable when grouping more than 1 field")
}
var v []int
if err := sgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (sgb *SprayGroupBy) IntsX(ctx context.Context) []int {
v, err := sgb.Ints(ctx)
if err != nil {
panic(err)
}
return v
}
// Int returns a single int from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (sgb *SprayGroupBy) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = sgb.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{spray.Label}
default:
err = fmt.Errorf("ent: SprayGroupBy.Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (sgb *SprayGroupBy) IntX(ctx context.Context) int {
v, err := sgb.Int(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64s returns list of float64s from group-by.
// It is only allowed when executing a group-by query with one field.
func (sgb *SprayGroupBy) Float64s(ctx context.Context) ([]float64, error) {
if len(sgb.fields) > 1 {
return nil, errors.New("ent: SprayGroupBy.Float64s is not achievable when grouping more than 1 field")
}
var v []float64
if err := sgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (sgb *SprayGroupBy) Float64sX(ctx context.Context) []float64 {
v, err := sgb.Float64s(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64 returns a single float64 from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (sgb *SprayGroupBy) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = sgb.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{spray.Label}
default:
err = fmt.Errorf("ent: SprayGroupBy.Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (sgb *SprayGroupBy) Float64X(ctx context.Context) float64 {
v, err := sgb.Float64(ctx)
if err != nil {
panic(err)
}
return v
}
// Bools returns list of bools from group-by.
// It is only allowed when executing a group-by query with one field.
func (sgb *SprayGroupBy) Bools(ctx context.Context) ([]bool, error) {
if len(sgb.fields) > 1 {
return nil, errors.New("ent: SprayGroupBy.Bools is not achievable when grouping more than 1 field")
}
var v []bool
if err := sgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (sgb *SprayGroupBy) BoolsX(ctx context.Context) []bool {
v, err := sgb.Bools(ctx)
if err != nil {
panic(err)
}
return v
}
// Bool returns a single bool from a group-by query.
// It is only allowed when executing a group-by query with one field.
func (sgb *SprayGroupBy) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = sgb.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{spray.Label}
default:
err = fmt.Errorf("ent: SprayGroupBy.Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (sgb *SprayGroupBy) BoolX(ctx context.Context) bool {
v, err := sgb.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
func (sgb *SprayGroupBy) sqlScan(ctx context.Context, v interface{}) error {
for _, f := range sgb.fields {
if !spray.ValidColumn(f) {
@@ -797,6 +601,7 @@ func (sgb *SprayGroupBy) sqlQuery() *sql.Selector {
// SpraySelect is the builder for selecting fields of Spray entities.
type SpraySelect struct {
*SprayQuery
selector
// intermediate query (i.e. traversal path).
sql *sql.Selector
}
@@ -810,201 +615,6 @@ func (ss *SpraySelect) Scan(ctx context.Context, v interface{}) error {
return ss.sqlScan(ctx, v)
}
// ScanX is like Scan, but panics if an error occurs.
func (ss *SpraySelect) ScanX(ctx context.Context, v interface{}) {
if err := ss.Scan(ctx, v); err != nil {
panic(err)
}
}
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
func (ss *SpraySelect) Strings(ctx context.Context) ([]string, error) {
if len(ss.fields) > 1 {
return nil, errors.New("ent: SpraySelect.Strings is not achievable when selecting more than 1 field")
}
var v []string
if err := ss.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (ss *SpraySelect) StringsX(ctx context.Context) []string {
v, err := ss.Strings(ctx)
if err != nil {
panic(err)
}
return v
}
// String returns a single string from a selector. It is only allowed when selecting one field.
func (ss *SpraySelect) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = ss.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{spray.Label}
default:
err = fmt.Errorf("ent: SpraySelect.Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (ss *SpraySelect) StringX(ctx context.Context) string {
v, err := ss.String(ctx)
if err != nil {
panic(err)
}
return v
}
// Ints returns list of ints from a selector. It is only allowed when selecting one field.
func (ss *SpraySelect) Ints(ctx context.Context) ([]int, error) {
if len(ss.fields) > 1 {
return nil, errors.New("ent: SpraySelect.Ints is not achievable when selecting more than 1 field")
}
var v []int
if err := ss.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (ss *SpraySelect) IntsX(ctx context.Context) []int {
v, err := ss.Ints(ctx)
if err != nil {
panic(err)
}
return v
}
// Int returns a single int from a selector. It is only allowed when selecting one field.
func (ss *SpraySelect) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = ss.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{spray.Label}
default:
err = fmt.Errorf("ent: SpraySelect.Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (ss *SpraySelect) IntX(ctx context.Context) int {
v, err := ss.Int(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64s returns list of float64s from a selector. It is only allowed when selecting one field.
func (ss *SpraySelect) Float64s(ctx context.Context) ([]float64, error) {
if len(ss.fields) > 1 {
return nil, errors.New("ent: SpraySelect.Float64s is not achievable when selecting more than 1 field")
}
var v []float64
if err := ss.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (ss *SpraySelect) Float64sX(ctx context.Context) []float64 {
v, err := ss.Float64s(ctx)
if err != nil {
panic(err)
}
return v
}
// Float64 returns a single float64 from a selector. It is only allowed when selecting one field.
func (ss *SpraySelect) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = ss.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{spray.Label}
default:
err = fmt.Errorf("ent: SpraySelect.Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (ss *SpraySelect) Float64X(ctx context.Context) float64 {
v, err := ss.Float64(ctx)
if err != nil {
panic(err)
}
return v
}
// Bools returns list of bools from a selector. It is only allowed when selecting one field.
func (ss *SpraySelect) Bools(ctx context.Context) ([]bool, error) {
if len(ss.fields) > 1 {
return nil, errors.New("ent: SpraySelect.Bools is not achievable when selecting more than 1 field")
}
var v []bool
if err := ss.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (ss *SpraySelect) BoolsX(ctx context.Context) []bool {
v, err := ss.Bools(ctx)
if err != nil {
panic(err)
}
return v
}
// Bool returns a single bool from a selector. It is only allowed when selecting one field.
func (ss *SpraySelect) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = ss.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{spray.Label}
default:
err = fmt.Errorf("ent: SpraySelect.Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (ss *SpraySelect) BoolX(ctx context.Context) bool {
v, err := ss.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
func (ss *SpraySelect) sqlScan(ctx context.Context, v interface{}) error {
rows := &sql.Rows{}
query, args := ss.sql.Query()