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,9 +1,10 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"log"
@@ -83,7 +84,7 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error)
// is used until the transaction is committed or rolled back.
func (c *Client) Tx(ctx context.Context) (*Tx, error) {
if _, ok := c.driver.(*txDriver); ok {
return nil, fmt.Errorf("ent: cannot start a transaction within a transaction")
return nil, errors.New("ent: cannot start a transaction within a transaction")
}
tx, err := newTx(ctx, c.driver)
if err != nil {
@@ -107,7 +108,7 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
// BeginTx returns a transactional client with specified options.
func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) {
if _, ok := c.driver.(*txDriver); ok {
return nil, fmt.Errorf("ent: cannot start a transaction within a transaction")
return nil, errors.New("ent: cannot start a transaction within a transaction")
}
tx, err := c.driver.(interface {
BeginTx(context.Context, *sql.TxOptions) (dialect.Tx, error)
@@ -136,7 +137,6 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
// Match.
// Query().
// Count(ctx)
//
func (c *Client) Debug() *Client {
if c.debug {
return c
@@ -181,7 +181,7 @@ func (c *MatchClient) Use(hooks ...Hook) {
c.hooks.Match = append(c.hooks.Match, hooks...)
}
// Create returns a create builder for Match.
// Create returns a builder for creating a Match entity.
func (c *MatchClient) Create() *MatchCreate {
mutation := newMatchMutation(c.config, OpCreate)
return &MatchCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
@@ -216,12 +216,12 @@ func (c *MatchClient) Delete() *MatchDelete {
return &MatchDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a delete builder for the given entity.
// DeleteOne returns a builder for deleting the given entity.
func (c *MatchClient) DeleteOne(m *Match) *MatchDeleteOne {
return c.DeleteOneID(m.ID)
}
// DeleteOneID returns a delete builder for the given id.
// DeleteOne returns a builder for deleting the given entity by its id.
func (c *MatchClient) DeleteOneID(id uint64) *MatchDeleteOne {
builder := c.Delete().Where(match.ID(id))
builder.mutation.id = &id
@@ -303,7 +303,7 @@ func (c *MatchPlayerClient) Use(hooks ...Hook) {
c.hooks.MatchPlayer = append(c.hooks.MatchPlayer, hooks...)
}
// Create returns a create builder for MatchPlayer.
// Create returns a builder for creating a MatchPlayer entity.
func (c *MatchPlayerClient) Create() *MatchPlayerCreate {
mutation := newMatchPlayerMutation(c.config, OpCreate)
return &MatchPlayerCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
@@ -338,12 +338,12 @@ func (c *MatchPlayerClient) Delete() *MatchPlayerDelete {
return &MatchPlayerDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a delete builder for the given entity.
// DeleteOne returns a builder for deleting the given entity.
func (c *MatchPlayerClient) DeleteOne(mp *MatchPlayer) *MatchPlayerDeleteOne {
return c.DeleteOneID(mp.ID)
}
// DeleteOneID returns a delete builder for the given id.
// DeleteOne returns a builder for deleting the given entity by its id.
func (c *MatchPlayerClient) DeleteOneID(id int) *MatchPlayerDeleteOne {
builder := c.Delete().Where(matchplayer.ID(id))
builder.mutation.id = &id
@@ -489,7 +489,7 @@ func (c *MessagesClient) Use(hooks ...Hook) {
c.hooks.Messages = append(c.hooks.Messages, hooks...)
}
// Create returns a create builder for Messages.
// Create returns a builder for creating a Messages entity.
func (c *MessagesClient) Create() *MessagesCreate {
mutation := newMessagesMutation(c.config, OpCreate)
return &MessagesCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
@@ -524,12 +524,12 @@ func (c *MessagesClient) Delete() *MessagesDelete {
return &MessagesDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a delete builder for the given entity.
// DeleteOne returns a builder for deleting the given entity.
func (c *MessagesClient) DeleteOne(m *Messages) *MessagesDeleteOne {
return c.DeleteOneID(m.ID)
}
// DeleteOneID returns a delete builder for the given id.
// DeleteOne returns a builder for deleting the given entity by its id.
func (c *MessagesClient) DeleteOneID(id int) *MessagesDeleteOne {
builder := c.Delete().Where(messages.ID(id))
builder.mutation.id = &id
@@ -595,7 +595,7 @@ func (c *PlayerClient) Use(hooks ...Hook) {
c.hooks.Player = append(c.hooks.Player, hooks...)
}
// Create returns a create builder for Player.
// Create returns a builder for creating a Player entity.
func (c *PlayerClient) Create() *PlayerCreate {
mutation := newPlayerMutation(c.config, OpCreate)
return &PlayerCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
@@ -630,12 +630,12 @@ func (c *PlayerClient) Delete() *PlayerDelete {
return &PlayerDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a delete builder for the given entity.
// DeleteOne returns a builder for deleting the given entity.
func (c *PlayerClient) DeleteOne(pl *Player) *PlayerDeleteOne {
return c.DeleteOneID(pl.ID)
}
// DeleteOneID returns a delete builder for the given id.
// DeleteOne returns a builder for deleting the given entity by its id.
func (c *PlayerClient) DeleteOneID(id uint64) *PlayerDeleteOne {
builder := c.Delete().Where(player.ID(id))
builder.mutation.id = &id
@@ -717,7 +717,7 @@ func (c *RoundStatsClient) Use(hooks ...Hook) {
c.hooks.RoundStats = append(c.hooks.RoundStats, hooks...)
}
// Create returns a create builder for RoundStats.
// Create returns a builder for creating a RoundStats entity.
func (c *RoundStatsClient) Create() *RoundStatsCreate {
mutation := newRoundStatsMutation(c.config, OpCreate)
return &RoundStatsCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
@@ -752,12 +752,12 @@ func (c *RoundStatsClient) Delete() *RoundStatsDelete {
return &RoundStatsDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a delete builder for the given entity.
// DeleteOne returns a builder for deleting the given entity.
func (c *RoundStatsClient) DeleteOne(rs *RoundStats) *RoundStatsDeleteOne {
return c.DeleteOneID(rs.ID)
}
// DeleteOneID returns a delete builder for the given id.
// DeleteOne returns a builder for deleting the given entity by its id.
func (c *RoundStatsClient) DeleteOneID(id int) *RoundStatsDeleteOne {
builder := c.Delete().Where(roundstats.ID(id))
builder.mutation.id = &id
@@ -823,7 +823,7 @@ func (c *SprayClient) Use(hooks ...Hook) {
c.hooks.Spray = append(c.hooks.Spray, hooks...)
}
// Create returns a create builder for Spray.
// Create returns a builder for creating a Spray entity.
func (c *SprayClient) Create() *SprayCreate {
mutation := newSprayMutation(c.config, OpCreate)
return &SprayCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
@@ -858,12 +858,12 @@ func (c *SprayClient) Delete() *SprayDelete {
return &SprayDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a delete builder for the given entity.
// DeleteOne returns a builder for deleting the given entity.
func (c *SprayClient) DeleteOne(s *Spray) *SprayDeleteOne {
return c.DeleteOneID(s.ID)
}
// DeleteOneID returns a delete builder for the given id.
// DeleteOne returns a builder for deleting the given entity by its id.
func (c *SprayClient) DeleteOneID(id int) *SprayDeleteOne {
builder := c.Delete().Where(spray.ID(id))
builder.mutation.id = &id
@@ -929,7 +929,7 @@ func (c *WeaponClient) Use(hooks ...Hook) {
c.hooks.Weapon = append(c.hooks.Weapon, hooks...)
}
// Create returns a create builder for Weapon.
// Create returns a builder for creating a Weapon entity.
func (c *WeaponClient) Create() *WeaponCreate {
mutation := newWeaponMutation(c.config, OpCreate)
return &WeaponCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
@@ -964,12 +964,12 @@ func (c *WeaponClient) Delete() *WeaponDelete {
return &WeaponDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
}
// DeleteOne returns a delete builder for the given entity.
// DeleteOne returns a builder for deleting the given entity.
func (c *WeaponClient) DeleteOne(w *Weapon) *WeaponDeleteOne {
return c.DeleteOneID(w.ID)
}
// DeleteOneID returns a delete builder for the given id.
// DeleteOne returns a builder for deleting the given entity by its id.
func (c *WeaponClient) DeleteOneID(id int) *WeaponDeleteOne {
builder := c.Delete().Where(weapon.ID(id))
builder.mutation.id = &id

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent

View File

@@ -1,13 +1,15 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"errors"
"fmt"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"git.harting.dev/csgowtf/csgowtfd/ent/match"
"git.harting.dev/csgowtf/csgowtfd/ent/matchplayer"
"git.harting.dev/csgowtf/csgowtfd/ent/messages"
@@ -91,7 +93,6 @@ type AggregateFunc func(*sql.Selector) string
// GroupBy(field1, field2).
// Aggregate(ent.As(ent.Sum(field1), "sum_field1"), (ent.As(ent.Sum(field2), "sum_field2")).
// Scan(ctx, &v)
//
func As(fn AggregateFunc, end string) AggregateFunc {
return func(s *sql.Selector) string {
return sql.As(fn(s), end)
@@ -269,3 +270,208 @@ func IsConstraintError(err error) bool {
var e *ConstraintError
return errors.As(err, &e)
}
// selector embedded by the different Select/GroupBy builders.
type selector struct {
label string
flds *[]string
scan func(context.Context, interface{}) error
}
// ScanX is like Scan, but panics if an error occurs.
func (s *selector) ScanX(ctx context.Context, v interface{}) {
if err := s.scan(ctx, v); err != nil {
panic(err)
}
}
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
func (s *selector) Strings(ctx context.Context) ([]string, error) {
if len(*s.flds) > 1 {
return nil, errors.New("ent: Strings is not achievable when selecting more than 1 field")
}
var v []string
if err := s.scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (s *selector) StringsX(ctx context.Context) []string {
v, err := s.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 (s *selector) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = s.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{s.label}
default:
err = fmt.Errorf("ent: Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (s *selector) StringX(ctx context.Context) string {
v, err := s.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 (s *selector) Ints(ctx context.Context) ([]int, error) {
if len(*s.flds) > 1 {
return nil, errors.New("ent: Ints is not achievable when selecting more than 1 field")
}
var v []int
if err := s.scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (s *selector) IntsX(ctx context.Context) []int {
v, err := s.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 (s *selector) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = s.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{s.label}
default:
err = fmt.Errorf("ent: Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (s *selector) IntX(ctx context.Context) int {
v, err := s.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 (s *selector) Float64s(ctx context.Context) ([]float64, error) {
if len(*s.flds) > 1 {
return nil, errors.New("ent: Float64s is not achievable when selecting more than 1 field")
}
var v []float64
if err := s.scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (s *selector) Float64sX(ctx context.Context) []float64 {
v, err := s.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 (s *selector) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = s.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{s.label}
default:
err = fmt.Errorf("ent: Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (s *selector) Float64X(ctx context.Context) float64 {
v, err := s.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 (s *selector) Bools(ctx context.Context) ([]bool, error) {
if len(*s.flds) > 1 {
return nil, errors.New("ent: Bools is not achievable when selecting more than 1 field")
}
var v []bool
if err := s.scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (s *selector) BoolsX(ctx context.Context) []bool {
v, err := s.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 (s *selector) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = s.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{s.label}
default:
err = fmt.Errorf("ent: Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (s *selector) BoolX(ctx context.Context) bool {
v, err := s.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
// queryHook describes an internal hook for the different sqlAll methods.
type queryHook func(context.Context, *sqlgraph.QuerySpec)

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package enttest
@@ -10,6 +10,7 @@ import (
_ "git.harting.dev/csgowtf/csgowtfd/ent/runtime"
"entgo.io/ent/dialect/sql/schema"
"git.harting.dev/csgowtf/csgowtfd/ent/migrate"
)
type (
@@ -59,10 +60,7 @@ func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Cl
t.Error(err)
t.FailNow()
}
if err := c.Schema.Create(context.Background(), o.migrateOpts...); err != nil {
t.Error(err)
t.FailNow()
}
migrateSchema(t, c, o)
return c
}
@@ -70,9 +68,17 @@ func Open(t TestingT, driverName, dataSourceName string, opts ...Option) *ent.Cl
func NewClient(t TestingT, opts ...Option) *ent.Client {
o := newOptions(opts)
c := ent.NewClient(o.opts...)
if err := c.Schema.Create(context.Background(), o.migrateOpts...); err != nil {
migrateSchema(t, c, o)
return c
}
func migrateSchema(t TestingT, c *ent.Client, o *options) {
tables, err := schema.CopyTables(migrate.Tables)
if err != nil {
t.Error(err)
t.FailNow()
}
if err := migrate.Create(context.Background(), c.Schema, tables, o.migrateOpts...); err != nil {
t.Error(err)
t.FailNow()
}
return c
}

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package hook
@@ -195,7 +195,6 @@ func HasFields(field string, fields ...string) Condition {
// If executes the given hook under condition.
//
// hook.If(ComputeAverage, And(HasFields(...), HasAddedFields(...)))
//
func If(hk ent.Hook, cond Condition) ent.Hook {
return func(next ent.Mutator) ent.Mutator {
return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) {
@@ -210,7 +209,6 @@ func If(hk ent.Hook, cond Condition) ent.Hook {
// On executes the given hook only for the given operation.
//
// hook.On(Log, ent.Delete|ent.Create)
//
func On(hk ent.Hook, op ent.Op) ent.Hook {
return If(hk, HasOp(op))
}
@@ -218,7 +216,6 @@ func On(hk ent.Hook, op ent.Op) ent.Hook {
// Unless skips the given hook only for the given operation.
//
// hook.Unless(Log, ent.Update|ent.UpdateOne)
//
func Unless(hk ent.Hook, op ent.Op) ent.Hook {
return If(hk, Not(HasOp(op)))
}
@@ -239,7 +236,6 @@ func FixedError(err error) ent.Hook {
// Reject(ent.Delete|ent.Update),
// }
// }
//
func Reject(op ent.Op) ent.Hook {
hk := FixedError(fmt.Errorf("%s operation is not allowed", op))
return On(hk, op)

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -225,11 +225,11 @@ func (m *Match) Update() *MatchUpdateOne {
// Unwrap unwraps the Match entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (m *Match) Unwrap() *Match {
tx, ok := m.config.driver.(*txDriver)
_tx, ok := m.config.driver.(*txDriver)
if !ok {
panic("ent: Match is not a transactional entity")
}
m.config.driver = tx.drv
m.config.driver = _tx.drv
return m
}
@@ -237,34 +237,47 @@ func (m *Match) Unwrap() *Match {
func (m *Match) String() string {
var builder strings.Builder
builder.WriteString("Match(")
builder.WriteString(fmt.Sprintf("id=%v", m.ID))
builder.WriteString(", share_code=")
builder.WriteString(fmt.Sprintf("id=%v, ", m.ID))
builder.WriteString("share_code=")
builder.WriteString(m.ShareCode)
builder.WriteString(", map=")
builder.WriteString(", ")
builder.WriteString("map=")
builder.WriteString(m.Map)
builder.WriteString(", date=")
builder.WriteString(", ")
builder.WriteString("date=")
builder.WriteString(m.Date.Format(time.ANSIC))
builder.WriteString(", score_team_a=")
builder.WriteString(", ")
builder.WriteString("score_team_a=")
builder.WriteString(fmt.Sprintf("%v", m.ScoreTeamA))
builder.WriteString(", score_team_b=")
builder.WriteString(", ")
builder.WriteString("score_team_b=")
builder.WriteString(fmt.Sprintf("%v", m.ScoreTeamB))
builder.WriteString(", replay_url=")
builder.WriteString(", ")
builder.WriteString("replay_url=")
builder.WriteString(m.ReplayURL)
builder.WriteString(", duration=")
builder.WriteString(", ")
builder.WriteString("duration=")
builder.WriteString(fmt.Sprintf("%v", m.Duration))
builder.WriteString(", match_result=")
builder.WriteString(", ")
builder.WriteString("match_result=")
builder.WriteString(fmt.Sprintf("%v", m.MatchResult))
builder.WriteString(", max_rounds=")
builder.WriteString(", ")
builder.WriteString("max_rounds=")
builder.WriteString(fmt.Sprintf("%v", m.MaxRounds))
builder.WriteString(", demo_parsed=")
builder.WriteString(", ")
builder.WriteString("demo_parsed=")
builder.WriteString(fmt.Sprintf("%v", m.DemoParsed))
builder.WriteString(", vac_present=")
builder.WriteString(", ")
builder.WriteString("vac_present=")
builder.WriteString(fmt.Sprintf("%v", m.VacPresent))
builder.WriteString(", gameban_present=")
builder.WriteString(", ")
builder.WriteString("gameban_present=")
builder.WriteString(fmt.Sprintf("%v", m.GamebanPresent))
builder.WriteString(", decryption_key=")
builder.WriteString(", ")
builder.WriteString("decryption_key=")
builder.WriteString(fmt.Sprintf("%v", m.DecryptionKey))
builder.WriteString(", tick_rate=")
builder.WriteString(", ")
builder.WriteString("tick_rate=")
builder.WriteString(fmt.Sprintf("%v", m.TickRate))
builder.WriteByte(')')
return builder.String()

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package match

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package match
@@ -34,12 +34,6 @@ func IDNEQ(id uint64) predicate.Match {
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...uint64) predicate.Match {
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(ids) == 0 {
s.Where(sql.False())
return
}
v := make([]interface{}, len(ids))
for i := range v {
v[i] = ids[i]
@@ -51,12 +45,6 @@ func IDIn(ids ...uint64) predicate.Match {
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...uint64) predicate.Match {
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(ids) == 0 {
s.Where(sql.False())
return
}
v := make([]interface{}, len(ids))
for i := range v {
v[i] = ids[i]
@@ -212,12 +200,6 @@ func ShareCodeIn(vs ...string) predicate.Match {
v[i] = vs[i]
}
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldShareCode), v...))
})
}
@@ -229,12 +211,6 @@ func ShareCodeNotIn(vs ...string) predicate.Match {
v[i] = vs[i]
}
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldShareCode), v...))
})
}
@@ -323,12 +299,6 @@ func MapIn(vs ...string) predicate.Match {
v[i] = vs[i]
}
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldMap), v...))
})
}
@@ -340,12 +310,6 @@ func MapNotIn(vs ...string) predicate.Match {
v[i] = vs[i]
}
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldMap), v...))
})
}
@@ -448,12 +412,6 @@ func DateIn(vs ...time.Time) predicate.Match {
v[i] = vs[i]
}
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldDate), v...))
})
}
@@ -465,12 +423,6 @@ func DateNotIn(vs ...time.Time) predicate.Match {
v[i] = vs[i]
}
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldDate), v...))
})
}
@@ -524,12 +476,6 @@ func ScoreTeamAIn(vs ...int) predicate.Match {
v[i] = vs[i]
}
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldScoreTeamA), v...))
})
}
@@ -541,12 +487,6 @@ func ScoreTeamANotIn(vs ...int) predicate.Match {
v[i] = vs[i]
}
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldScoreTeamA), v...))
})
}
@@ -600,12 +540,6 @@ func ScoreTeamBIn(vs ...int) predicate.Match {
v[i] = vs[i]
}
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldScoreTeamB), v...))
})
}
@@ -617,12 +551,6 @@ func ScoreTeamBNotIn(vs ...int) predicate.Match {
v[i] = vs[i]
}
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldScoreTeamB), v...))
})
}
@@ -676,12 +604,6 @@ func ReplayURLIn(vs ...string) predicate.Match {
v[i] = vs[i]
}
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldReplayURL), v...))
})
}
@@ -693,12 +615,6 @@ func ReplayURLNotIn(vs ...string) predicate.Match {
v[i] = vs[i]
}
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldReplayURL), v...))
})
}
@@ -801,12 +717,6 @@ func DurationIn(vs ...int) predicate.Match {
v[i] = vs[i]
}
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldDuration), v...))
})
}
@@ -818,12 +728,6 @@ func DurationNotIn(vs ...int) predicate.Match {
v[i] = vs[i]
}
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldDuration), v...))
})
}
@@ -877,12 +781,6 @@ func MatchResultIn(vs ...int) predicate.Match {
v[i] = vs[i]
}
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldMatchResult), v...))
})
}
@@ -894,12 +792,6 @@ func MatchResultNotIn(vs ...int) predicate.Match {
v[i] = vs[i]
}
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldMatchResult), v...))
})
}
@@ -953,12 +845,6 @@ func MaxRoundsIn(vs ...int) predicate.Match {
v[i] = vs[i]
}
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldMaxRounds), v...))
})
}
@@ -970,12 +856,6 @@ func MaxRoundsNotIn(vs ...int) predicate.Match {
v[i] = vs[i]
}
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldMaxRounds), v...))
})
}
@@ -1071,12 +951,6 @@ func DecryptionKeyIn(vs ...[]byte) predicate.Match {
v[i] = vs[i]
}
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldDecryptionKey), v...))
})
}
@@ -1088,12 +962,6 @@ func DecryptionKeyNotIn(vs ...[]byte) predicate.Match {
v[i] = vs[i]
}
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldDecryptionKey), v...))
})
}
@@ -1161,12 +1029,6 @@ func TickRateIn(vs ...float64) predicate.Match {
v[i] = vs[i]
}
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldTickRate), v...))
})
}
@@ -1178,12 +1040,6 @@ func TickRateNotIn(vs ...float64) predicate.Match {
v[i] = vs[i]
}
return predicate.Match(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldTickRate), v...))
})
}

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -230,9 +230,15 @@ func (mc *MatchCreate) Save(ctx context.Context) (*Match, error) {
}
mut = mc.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, mc.mutation); err != nil {
v, err := mut.Mutate(ctx, mc.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*Match)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from MatchMutation", v)
}
node = nv
}
return node, err
}
@@ -314,7 +320,7 @@ func (mc *MatchCreate) sqlSave(ctx context.Context) (*Match, error) {
_node, _spec := mc.createSpec()
if err := sqlgraph.CreateNode(ctx, mc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
@@ -526,7 +532,7 @@ func (mcb *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) {
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, mcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
@@ -534,11 +540,11 @@ func (mcb *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) {
return nil, err
}
mutation.id = &nodes[i].ID
mutation.done = true
if specs[i].ID.Value != nil && nodes[i].ID == 0 {
id := specs[i].ID.Value.(int64)
nodes[i].ID = uint64(id)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -84,7 +84,11 @@ func (md *MatchDelete) sqlExec(ctx context.Context) (int, error) {
}
}
}
return sqlgraph.DeleteNodes(ctx, md.driver, _spec)
affected, err := sqlgraph.DeleteNodes(ctx, md.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return affected, err
}
// MatchDeleteOne is the builder for deleting a single Match entity.

View File

@@ -1,11 +1,10 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"database/sql/driver"
"errors"
"fmt"
"math"
@@ -21,16 +20,15 @@ import (
// MatchQuery is the builder for querying Match entities.
type MatchQuery struct {
config
limit *int
offset *int
unique *bool
order []OrderFunc
fields []string
predicates []predicate.Match
// eager-loading edges.
limit *int
offset *int
unique *bool
order []OrderFunc
fields []string
predicates []predicate.Match
withStats *MatchPlayerQuery
withPlayers *PlayerQuery
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)
@@ -337,17 +335,18 @@ func (mq *MatchQuery) WithPlayers(opts ...func(*PlayerQuery)) *MatchQuery {
// GroupBy(match.FieldShareCode).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
//
func (mq *MatchQuery) GroupBy(field string, fields ...string) *MatchGroupBy {
group := &MatchGroupBy{config: mq.config}
group.fields = append([]string{field}, fields...)
group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
grbuild := &MatchGroupBy{config: mq.config}
grbuild.fields = append([]string{field}, fields...)
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) {
if err := mq.prepareQuery(ctx); err != nil {
return nil, err
}
return mq.sqlQuery(ctx), nil
}
return group
grbuild.label = match.Label
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
@@ -362,10 +361,12 @@ func (mq *MatchQuery) GroupBy(field string, fields ...string) *MatchGroupBy {
// client.Match.Query().
// Select(match.FieldShareCode).
// Scan(ctx, &v)
//
func (mq *MatchQuery) Select(fields ...string) *MatchSelect {
mq.fields = append(mq.fields, fields...)
return &MatchSelect{MatchQuery: mq}
selbuild := &MatchSelect{MatchQuery: mq}
selbuild.label = match.Label
selbuild.flds, selbuild.scan = &mq.fields, selbuild.Scan
return selbuild
}
func (mq *MatchQuery) prepareQuery(ctx context.Context) error {
@@ -384,7 +385,7 @@ func (mq *MatchQuery) prepareQuery(ctx context.Context) error {
return nil
}
func (mq *MatchQuery) sqlAll(ctx context.Context) ([]*Match, error) {
func (mq *MatchQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Match, error) {
var (
nodes = []*Match{}
_spec = mq.querySpec()
@@ -394,119 +395,127 @@ func (mq *MatchQuery) sqlAll(ctx context.Context) ([]*Match, error) {
}
)
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
node := &Match{config: mq.config}
nodes = append(nodes, node)
return node.scanValues(columns)
return (*Match).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 := &Match{config: mq.config}
nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
}
if len(mq.modifiers) > 0 {
_spec.Modifiers = mq.modifiers
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, mq.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
if query := mq.withStats; query != nil {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[uint64]*Match)
for i := range nodes {
fks = append(fks, nodes[i].ID)
nodeids[nodes[i].ID] = nodes[i]
nodes[i].Edges.Stats = []*MatchPlayer{}
}
query.Where(predicate.MatchPlayer(func(s *sql.Selector) {
s.Where(sql.InValues(match.StatsColumn, fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
if err := mq.loadStats(ctx, query, nodes,
func(n *Match) { n.Edges.Stats = []*MatchPlayer{} },
func(n *Match, e *MatchPlayer) { n.Edges.Stats = append(n.Edges.Stats, e) }); err != nil {
return nil, err
}
for _, n := range neighbors {
fk := n.MatchStats
node, ok := nodeids[fk]
if !ok {
return nil, fmt.Errorf(`unexpected foreign-key "match_stats" returned %v for node %v`, fk, n.ID)
}
node.Edges.Stats = append(node.Edges.Stats, n)
}
}
if query := mq.withPlayers; query != nil {
fks := make([]driver.Value, 0, len(nodes))
ids := make(map[uint64]*Match, len(nodes))
for _, node := range nodes {
ids[node.ID] = node
fks = append(fks, node.ID)
node.Edges.Players = []*Player{}
}
var (
edgeids []uint64
edges = make(map[uint64][]*Match)
)
_spec := &sqlgraph.EdgeQuerySpec{
Edge: &sqlgraph.EdgeSpec{
Inverse: true,
Table: match.PlayersTable,
Columns: match.PlayersPrimaryKey,
},
Predicate: func(s *sql.Selector) {
s.Where(sql.InValues(match.PlayersPrimaryKey[1], fks...))
},
ScanValues: func() [2]interface{} {
return [2]interface{}{new(sql.NullInt64), new(sql.NullInt64)}
},
Assign: func(out, in interface{}) error {
eout, ok := out.(*sql.NullInt64)
if !ok || eout == nil {
return fmt.Errorf("unexpected id value for edge-out")
}
ein, ok := in.(*sql.NullInt64)
if !ok || ein == nil {
return fmt.Errorf("unexpected id value for edge-in")
}
outValue := uint64(eout.Int64)
inValue := uint64(ein.Int64)
node, ok := ids[outValue]
if !ok {
return fmt.Errorf("unexpected node id in edges: %v", outValue)
}
if _, ok := edges[inValue]; !ok {
edgeids = append(edgeids, inValue)
}
edges[inValue] = append(edges[inValue], node)
return nil
},
}
if err := sqlgraph.QueryEdges(ctx, mq.driver, _spec); err != nil {
return nil, fmt.Errorf(`query edges "players": %w`, err)
}
query.Where(player.IDIn(edgeids...))
neighbors, err := query.All(ctx)
if err != nil {
if err := mq.loadPlayers(ctx, query, nodes,
func(n *Match) { n.Edges.Players = []*Player{} },
func(n *Match, e *Player) { n.Edges.Players = append(n.Edges.Players, e) }); err != nil {
return nil, err
}
for _, n := range neighbors {
nodes, ok := edges[n.ID]
if !ok {
return nil, fmt.Errorf(`unexpected "players" node returned %v`, n.ID)
}
for i := range nodes {
nodes[i].Edges.Players = append(nodes[i].Edges.Players, n)
}
}
return nodes, nil
}
func (mq *MatchQuery) loadStats(ctx context.Context, query *MatchPlayerQuery, nodes []*Match, init func(*Match), assign func(*Match, *MatchPlayer)) error {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[uint64]*Match)
for i := range nodes {
fks = append(fks, nodes[i].ID)
nodeids[nodes[i].ID] = nodes[i]
if init != nil {
init(nodes[i])
}
}
return nodes, nil
query.Where(predicate.MatchPlayer(func(s *sql.Selector) {
s.Where(sql.InValues(match.StatsColumn, fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
fk := n.MatchStats
node, ok := nodeids[fk]
if !ok {
return fmt.Errorf(`unexpected foreign-key "match_stats" returned %v for node %v`, fk, n.ID)
}
assign(node, n)
}
return nil
}
func (mq *MatchQuery) loadPlayers(ctx context.Context, query *PlayerQuery, nodes []*Match, init func(*Match), assign func(*Match, *Player)) error {
edgeIDs := make([]driver.Value, len(nodes))
byID := make(map[uint64]*Match)
nids := make(map[uint64]map[*Match]struct{})
for i, node := range nodes {
edgeIDs[i] = node.ID
byID[node.ID] = node
if init != nil {
init(node)
}
}
query.Where(func(s *sql.Selector) {
joinT := sql.Table(match.PlayersTable)
s.Join(joinT).On(s.C(player.FieldID), joinT.C(match.PlayersPrimaryKey[0]))
s.Where(sql.InValues(joinT.C(match.PlayersPrimaryKey[1]), edgeIDs...))
columns := s.SelectedColumns()
s.Select(joinT.C(match.PlayersPrimaryKey[1]))
s.AppendSelect(columns...)
s.SetDistinct(false)
})
if err := query.prepareQuery(ctx); err != nil {
return err
}
neighbors, err := query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) {
assign := spec.Assign
values := spec.ScanValues
spec.ScanValues = func(columns []string) ([]interface{}, error) {
values, err := values(columns[1:])
if err != nil {
return nil, err
}
return append([]interface{}{new(sql.NullInt64)}, values...), nil
}
spec.Assign = func(columns []string, values []interface{}) 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{}{}}
return assign(columns[1:], values[1:])
}
nids[inValue][byID[outValue]] = struct{}{}
return nil
}
})
if err != nil {
return err
}
for _, n := range neighbors {
nodes, ok := nids[n.ID]
if !ok {
return fmt.Errorf(`unexpected "players" node returned %v`, n.ID)
}
for kn := range nodes {
assign(kn, n)
}
}
return nil
}
func (mq *MatchQuery) sqlCount(ctx context.Context) (int, error) {
@@ -621,6 +630,7 @@ func (mq *MatchQuery) Modify(modifiers ...func(s *sql.Selector)) *MatchSelect {
// MatchGroupBy is the group-by builder for Match entities.
type MatchGroupBy struct {
config
selector
fields []string
fns []AggregateFunc
// intermediate query (i.e. traversal path).
@@ -644,209 +654,6 @@ func (mgb *MatchGroupBy) Scan(ctx context.Context, v interface{}) error {
return mgb.sqlScan(ctx, v)
}
// ScanX is like Scan, but panics if an error occurs.
func (mgb *MatchGroupBy) ScanX(ctx context.Context, v interface{}) {
if err := mgb.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 (mgb *MatchGroupBy) Strings(ctx context.Context) ([]string, error) {
if len(mgb.fields) > 1 {
return nil, errors.New("ent: MatchGroupBy.Strings is not achievable when grouping more than 1 field")
}
var v []string
if err := mgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (mgb *MatchGroupBy) StringsX(ctx context.Context) []string {
v, err := mgb.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 (mgb *MatchGroupBy) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = mgb.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{match.Label}
default:
err = fmt.Errorf("ent: MatchGroupBy.Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (mgb *MatchGroupBy) StringX(ctx context.Context) string {
v, err := mgb.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 (mgb *MatchGroupBy) Ints(ctx context.Context) ([]int, error) {
if len(mgb.fields) > 1 {
return nil, errors.New("ent: MatchGroupBy.Ints is not achievable when grouping more than 1 field")
}
var v []int
if err := mgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (mgb *MatchGroupBy) IntsX(ctx context.Context) []int {
v, err := mgb.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 (mgb *MatchGroupBy) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = mgb.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{match.Label}
default:
err = fmt.Errorf("ent: MatchGroupBy.Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (mgb *MatchGroupBy) IntX(ctx context.Context) int {
v, err := mgb.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 (mgb *MatchGroupBy) Float64s(ctx context.Context) ([]float64, error) {
if len(mgb.fields) > 1 {
return nil, errors.New("ent: MatchGroupBy.Float64s is not achievable when grouping more than 1 field")
}
var v []float64
if err := mgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (mgb *MatchGroupBy) Float64sX(ctx context.Context) []float64 {
v, err := mgb.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 (mgb *MatchGroupBy) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = mgb.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{match.Label}
default:
err = fmt.Errorf("ent: MatchGroupBy.Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (mgb *MatchGroupBy) Float64X(ctx context.Context) float64 {
v, err := mgb.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 (mgb *MatchGroupBy) Bools(ctx context.Context) ([]bool, error) {
if len(mgb.fields) > 1 {
return nil, errors.New("ent: MatchGroupBy.Bools is not achievable when grouping more than 1 field")
}
var v []bool
if err := mgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (mgb *MatchGroupBy) BoolsX(ctx context.Context) []bool {
v, err := mgb.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 (mgb *MatchGroupBy) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = mgb.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{match.Label}
default:
err = fmt.Errorf("ent: MatchGroupBy.Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (mgb *MatchGroupBy) BoolX(ctx context.Context) bool {
v, err := mgb.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
func (mgb *MatchGroupBy) sqlScan(ctx context.Context, v interface{}) error {
for _, f := range mgb.fields {
if !match.ValidColumn(f) {
@@ -888,6 +695,7 @@ func (mgb *MatchGroupBy) sqlQuery() *sql.Selector {
// MatchSelect is the builder for selecting fields of Match entities.
type MatchSelect struct {
*MatchQuery
selector
// intermediate query (i.e. traversal path).
sql *sql.Selector
}
@@ -901,201 +709,6 @@ func (ms *MatchSelect) Scan(ctx context.Context, v interface{}) error {
return ms.sqlScan(ctx, v)
}
// ScanX is like Scan, but panics if an error occurs.
func (ms *MatchSelect) ScanX(ctx context.Context, v interface{}) {
if err := ms.Scan(ctx, v); err != nil {
panic(err)
}
}
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
func (ms *MatchSelect) Strings(ctx context.Context) ([]string, error) {
if len(ms.fields) > 1 {
return nil, errors.New("ent: MatchSelect.Strings is not achievable when selecting more than 1 field")
}
var v []string
if err := ms.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (ms *MatchSelect) StringsX(ctx context.Context) []string {
v, err := ms.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 (ms *MatchSelect) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = ms.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{match.Label}
default:
err = fmt.Errorf("ent: MatchSelect.Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (ms *MatchSelect) StringX(ctx context.Context) string {
v, err := ms.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 (ms *MatchSelect) Ints(ctx context.Context) ([]int, error) {
if len(ms.fields) > 1 {
return nil, errors.New("ent: MatchSelect.Ints is not achievable when selecting more than 1 field")
}
var v []int
if err := ms.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (ms *MatchSelect) IntsX(ctx context.Context) []int {
v, err := ms.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 (ms *MatchSelect) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = ms.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{match.Label}
default:
err = fmt.Errorf("ent: MatchSelect.Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (ms *MatchSelect) IntX(ctx context.Context) int {
v, err := ms.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 (ms *MatchSelect) Float64s(ctx context.Context) ([]float64, error) {
if len(ms.fields) > 1 {
return nil, errors.New("ent: MatchSelect.Float64s is not achievable when selecting more than 1 field")
}
var v []float64
if err := ms.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (ms *MatchSelect) Float64sX(ctx context.Context) []float64 {
v, err := ms.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 (ms *MatchSelect) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = ms.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{match.Label}
default:
err = fmt.Errorf("ent: MatchSelect.Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (ms *MatchSelect) Float64X(ctx context.Context) float64 {
v, err := ms.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 (ms *MatchSelect) Bools(ctx context.Context) ([]bool, error) {
if len(ms.fields) > 1 {
return nil, errors.New("ent: MatchSelect.Bools is not achievable when selecting more than 1 field")
}
var v []bool
if err := ms.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (ms *MatchSelect) BoolsX(ctx context.Context) []bool {
v, err := ms.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 (ms *MatchSelect) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = ms.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{match.Label}
default:
err = fmt.Errorf("ent: MatchSelect.Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (ms *MatchSelect) BoolX(ctx context.Context) bool {
v, err := ms.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
func (ms *MatchSelect) sqlScan(ctx context.Context, v interface{}) error {
rows := &sql.Rows{}
query, args := ms.sql.Query()

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -20,8 +20,9 @@ import (
// MatchUpdate is the builder for updating Match entities.
type MatchUpdate struct {
config
hooks []Hook
mutation *MatchMutation
hooks []Hook
mutation *MatchMutation
modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the MatchUpdate builder.
@@ -359,6 +360,12 @@ func (mu *MatchUpdate) ExecX(ctx context.Context) {
}
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (mu *MatchUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MatchUpdate {
mu.modifiers = append(mu.modifiers, modifiers...)
return mu
}
func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
@@ -649,11 +656,12 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.Modifiers = mu.modifiers
if n, err = sqlgraph.UpdateNodes(ctx, mu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{match.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
@@ -663,9 +671,10 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) {
// MatchUpdateOne is the builder for updating a single Match entity.
type MatchUpdateOne struct {
config
fields []string
hooks []Hook
mutation *MatchMutation
fields []string
hooks []Hook
mutation *MatchMutation
modifiers []func(*sql.UpdateBuilder)
}
// SetShareCode sets the "share_code" field.
@@ -975,9 +984,15 @@ func (muo *MatchUpdateOne) Save(ctx context.Context) (*Match, error) {
}
mut = muo.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, muo.mutation); err != nil {
v, err := mut.Mutate(ctx, muo.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*Match)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from MatchMutation", v)
}
node = nv
}
return node, err
}
@@ -1004,6 +1019,12 @@ func (muo *MatchUpdateOne) ExecX(ctx context.Context) {
}
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (muo *MatchUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MatchUpdateOne {
muo.modifiers = append(muo.modifiers, modifiers...)
return muo
}
func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
@@ -1311,6 +1332,7 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.Modifiers = muo.modifiers
_node = &Match{config: muo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
@@ -1318,7 +1340,7 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{match.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -110,8 +110,7 @@ type MatchPlayerEdges struct {
func (e MatchPlayerEdges) MatchesOrErr() (*Match, error) {
if e.loadedTypes[0] {
if e.Matches == nil {
// The edge matches was loaded in eager-loading,
// but was not found.
// Edge was loaded but was not found.
return nil, &NotFoundError{label: match.Label}
}
return e.Matches, nil
@@ -124,8 +123,7 @@ func (e MatchPlayerEdges) MatchesOrErr() (*Match, error) {
func (e MatchPlayerEdges) PlayersOrErr() (*Player, error) {
if e.loadedTypes[1] {
if e.Players == nil {
// The edge players was loaded in eager-loading,
// but was not found.
// Edge was loaded but was not found.
return nil, &NotFoundError{label: player.Label}
}
return e.Players, nil
@@ -438,11 +436,11 @@ func (mp *MatchPlayer) Update() *MatchPlayerUpdateOne {
// Unwrap unwraps the MatchPlayer entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (mp *MatchPlayer) Unwrap() *MatchPlayer {
tx, ok := mp.config.driver.(*txDriver)
_tx, ok := mp.config.driver.(*txDriver)
if !ok {
panic("ent: MatchPlayer is not a transactional entity")
}
mp.config.driver = tx.drv
mp.config.driver = _tx.drv
return mp
}
@@ -450,70 +448,101 @@ func (mp *MatchPlayer) Unwrap() *MatchPlayer {
func (mp *MatchPlayer) String() string {
var builder strings.Builder
builder.WriteString("MatchPlayer(")
builder.WriteString(fmt.Sprintf("id=%v", mp.ID))
builder.WriteString(", team_id=")
builder.WriteString(fmt.Sprintf("id=%v, ", mp.ID))
builder.WriteString("team_id=")
builder.WriteString(fmt.Sprintf("%v", mp.TeamID))
builder.WriteString(", kills=")
builder.WriteString(", ")
builder.WriteString("kills=")
builder.WriteString(fmt.Sprintf("%v", mp.Kills))
builder.WriteString(", deaths=")
builder.WriteString(", ")
builder.WriteString("deaths=")
builder.WriteString(fmt.Sprintf("%v", mp.Deaths))
builder.WriteString(", assists=")
builder.WriteString(", ")
builder.WriteString("assists=")
builder.WriteString(fmt.Sprintf("%v", mp.Assists))
builder.WriteString(", headshot=")
builder.WriteString(", ")
builder.WriteString("headshot=")
builder.WriteString(fmt.Sprintf("%v", mp.Headshot))
builder.WriteString(", mvp=")
builder.WriteString(", ")
builder.WriteString("mvp=")
builder.WriteString(fmt.Sprintf("%v", mp.Mvp))
builder.WriteString(", score=")
builder.WriteString(", ")
builder.WriteString("score=")
builder.WriteString(fmt.Sprintf("%v", mp.Score))
builder.WriteString(", rank_new=")
builder.WriteString(", ")
builder.WriteString("rank_new=")
builder.WriteString(fmt.Sprintf("%v", mp.RankNew))
builder.WriteString(", rank_old=")
builder.WriteString(", ")
builder.WriteString("rank_old=")
builder.WriteString(fmt.Sprintf("%v", mp.RankOld))
builder.WriteString(", mk_2=")
builder.WriteString(", ")
builder.WriteString("mk_2=")
builder.WriteString(fmt.Sprintf("%v", mp.Mk2))
builder.WriteString(", mk_3=")
builder.WriteString(", ")
builder.WriteString("mk_3=")
builder.WriteString(fmt.Sprintf("%v", mp.Mk3))
builder.WriteString(", mk_4=")
builder.WriteString(", ")
builder.WriteString("mk_4=")
builder.WriteString(fmt.Sprintf("%v", mp.Mk4))
builder.WriteString(", mk_5=")
builder.WriteString(", ")
builder.WriteString("mk_5=")
builder.WriteString(fmt.Sprintf("%v", mp.Mk5))
builder.WriteString(", dmg_enemy=")
builder.WriteString(", ")
builder.WriteString("dmg_enemy=")
builder.WriteString(fmt.Sprintf("%v", mp.DmgEnemy))
builder.WriteString(", dmg_team=")
builder.WriteString(", ")
builder.WriteString("dmg_team=")
builder.WriteString(fmt.Sprintf("%v", mp.DmgTeam))
builder.WriteString(", ud_he=")
builder.WriteString(", ")
builder.WriteString("ud_he=")
builder.WriteString(fmt.Sprintf("%v", mp.UdHe))
builder.WriteString(", ud_flames=")
builder.WriteString(", ")
builder.WriteString("ud_flames=")
builder.WriteString(fmt.Sprintf("%v", mp.UdFlames))
builder.WriteString(", ud_flash=")
builder.WriteString(", ")
builder.WriteString("ud_flash=")
builder.WriteString(fmt.Sprintf("%v", mp.UdFlash))
builder.WriteString(", ud_decoy=")
builder.WriteString(", ")
builder.WriteString("ud_decoy=")
builder.WriteString(fmt.Sprintf("%v", mp.UdDecoy))
builder.WriteString(", ud_smoke=")
builder.WriteString(", ")
builder.WriteString("ud_smoke=")
builder.WriteString(fmt.Sprintf("%v", mp.UdSmoke))
builder.WriteString(", crosshair=")
builder.WriteString(", ")
builder.WriteString("crosshair=")
builder.WriteString(mp.Crosshair)
builder.WriteString(", color=")
builder.WriteString(", ")
builder.WriteString("color=")
builder.WriteString(fmt.Sprintf("%v", mp.Color))
builder.WriteString(", kast=")
builder.WriteString(", ")
builder.WriteString("kast=")
builder.WriteString(fmt.Sprintf("%v", mp.Kast))
builder.WriteString(", flash_duration_self=")
builder.WriteString(", ")
builder.WriteString("flash_duration_self=")
builder.WriteString(fmt.Sprintf("%v", mp.FlashDurationSelf))
builder.WriteString(", flash_duration_team=")
builder.WriteString(", ")
builder.WriteString("flash_duration_team=")
builder.WriteString(fmt.Sprintf("%v", mp.FlashDurationTeam))
builder.WriteString(", flash_duration_enemy=")
builder.WriteString(", ")
builder.WriteString("flash_duration_enemy=")
builder.WriteString(fmt.Sprintf("%v", mp.FlashDurationEnemy))
builder.WriteString(", flash_total_self=")
builder.WriteString(", ")
builder.WriteString("flash_total_self=")
builder.WriteString(fmt.Sprintf("%v", mp.FlashTotalSelf))
builder.WriteString(", flash_total_team=")
builder.WriteString(", ")
builder.WriteString("flash_total_team=")
builder.WriteString(fmt.Sprintf("%v", mp.FlashTotalTeam))
builder.WriteString(", flash_total_enemy=")
builder.WriteString(", ")
builder.WriteString("flash_total_enemy=")
builder.WriteString(fmt.Sprintf("%v", mp.FlashTotalEnemy))
builder.WriteString(", match_stats=")
builder.WriteString(", ")
builder.WriteString("match_stats=")
builder.WriteString(fmt.Sprintf("%v", mp.MatchStats))
builder.WriteString(", player_stats=")
builder.WriteString(", ")
builder.WriteString("player_stats=")
builder.WriteString(fmt.Sprintf("%v", mp.PlayerStats))
builder.WriteString(", flash_assists=")
builder.WriteString(", ")
builder.WriteString("flash_assists=")
builder.WriteString(fmt.Sprintf("%v", mp.FlashAssists))
builder.WriteByte(')')
return builder.String()

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package matchplayer

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package matchplayer
@@ -32,12 +32,6 @@ func IDNEQ(id int) predicate.MatchPlayer {
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int) predicate.MatchPlayer {
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(ids) == 0 {
s.Where(sql.False())
return
}
v := make([]interface{}, len(ids))
for i := range v {
v[i] = ids[i]
@@ -49,12 +43,6 @@ func IDIn(ids ...int) predicate.MatchPlayer {
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int) predicate.MatchPlayer {
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(ids) == 0 {
s.Where(sql.False())
return
}
v := make([]interface{}, len(ids))
for i := range v {
v[i] = ids[i]
@@ -329,12 +317,6 @@ func TeamIDIn(vs ...int) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldTeamID), v...))
})
}
@@ -346,12 +328,6 @@ func TeamIDNotIn(vs ...int) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldTeamID), v...))
})
}
@@ -405,12 +381,6 @@ func KillsIn(vs ...int) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldKills), v...))
})
}
@@ -422,12 +392,6 @@ func KillsNotIn(vs ...int) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldKills), v...))
})
}
@@ -481,12 +445,6 @@ func DeathsIn(vs ...int) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldDeaths), v...))
})
}
@@ -498,12 +456,6 @@ func DeathsNotIn(vs ...int) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldDeaths), v...))
})
}
@@ -557,12 +509,6 @@ func AssistsIn(vs ...int) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldAssists), v...))
})
}
@@ -574,12 +520,6 @@ func AssistsNotIn(vs ...int) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldAssists), v...))
})
}
@@ -633,12 +573,6 @@ func HeadshotIn(vs ...int) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldHeadshot), v...))
})
}
@@ -650,12 +584,6 @@ func HeadshotNotIn(vs ...int) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldHeadshot), v...))
})
}
@@ -709,12 +637,6 @@ func MvpIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldMvp), v...))
})
}
@@ -726,12 +648,6 @@ func MvpNotIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldMvp), v...))
})
}
@@ -785,12 +701,6 @@ func ScoreIn(vs ...int) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldScore), v...))
})
}
@@ -802,12 +712,6 @@ func ScoreNotIn(vs ...int) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldScore), v...))
})
}
@@ -861,12 +765,6 @@ func RankNewIn(vs ...int) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldRankNew), v...))
})
}
@@ -878,12 +776,6 @@ func RankNewNotIn(vs ...int) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldRankNew), v...))
})
}
@@ -951,12 +843,6 @@ func RankOldIn(vs ...int) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldRankOld), v...))
})
}
@@ -968,12 +854,6 @@ func RankOldNotIn(vs ...int) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldRankOld), v...))
})
}
@@ -1041,12 +921,6 @@ func Mk2In(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldMk2), v...))
})
}
@@ -1058,12 +932,6 @@ func Mk2NotIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldMk2), v...))
})
}
@@ -1131,12 +999,6 @@ func Mk3In(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldMk3), v...))
})
}
@@ -1148,12 +1010,6 @@ func Mk3NotIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldMk3), v...))
})
}
@@ -1221,12 +1077,6 @@ func Mk4In(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldMk4), v...))
})
}
@@ -1238,12 +1088,6 @@ func Mk4NotIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldMk4), v...))
})
}
@@ -1311,12 +1155,6 @@ func Mk5In(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldMk5), v...))
})
}
@@ -1328,12 +1166,6 @@ func Mk5NotIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldMk5), v...))
})
}
@@ -1401,12 +1233,6 @@ func DmgEnemyIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldDmgEnemy), v...))
})
}
@@ -1418,12 +1244,6 @@ func DmgEnemyNotIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldDmgEnemy), v...))
})
}
@@ -1491,12 +1311,6 @@ func DmgTeamIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldDmgTeam), v...))
})
}
@@ -1508,12 +1322,6 @@ func DmgTeamNotIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldDmgTeam), v...))
})
}
@@ -1581,12 +1389,6 @@ func UdHeIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldUdHe), v...))
})
}
@@ -1598,12 +1400,6 @@ func UdHeNotIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldUdHe), v...))
})
}
@@ -1671,12 +1467,6 @@ func UdFlamesIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldUdFlames), v...))
})
}
@@ -1688,12 +1478,6 @@ func UdFlamesNotIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldUdFlames), v...))
})
}
@@ -1761,12 +1545,6 @@ func UdFlashIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldUdFlash), v...))
})
}
@@ -1778,12 +1556,6 @@ func UdFlashNotIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldUdFlash), v...))
})
}
@@ -1851,12 +1623,6 @@ func UdDecoyIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldUdDecoy), v...))
})
}
@@ -1868,12 +1634,6 @@ func UdDecoyNotIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldUdDecoy), v...))
})
}
@@ -1941,12 +1701,6 @@ func UdSmokeIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldUdSmoke), v...))
})
}
@@ -1958,12 +1712,6 @@ func UdSmokeNotIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldUdSmoke), v...))
})
}
@@ -2031,12 +1779,6 @@ func CrosshairIn(vs ...string) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldCrosshair), v...))
})
}
@@ -2048,12 +1790,6 @@ func CrosshairNotIn(vs ...string) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldCrosshair), v...))
})
}
@@ -2156,12 +1892,6 @@ func ColorIn(vs ...Color) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldColor), v...))
})
}
@@ -2173,12 +1903,6 @@ func ColorNotIn(vs ...Color) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldColor), v...))
})
}
@@ -2218,12 +1942,6 @@ func KastIn(vs ...int) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldKast), v...))
})
}
@@ -2235,12 +1953,6 @@ func KastNotIn(vs ...int) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldKast), v...))
})
}
@@ -2308,12 +2020,6 @@ func FlashDurationSelfIn(vs ...float32) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldFlashDurationSelf), v...))
})
}
@@ -2325,12 +2031,6 @@ func FlashDurationSelfNotIn(vs ...float32) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldFlashDurationSelf), v...))
})
}
@@ -2398,12 +2098,6 @@ func FlashDurationTeamIn(vs ...float32) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldFlashDurationTeam), v...))
})
}
@@ -2415,12 +2109,6 @@ func FlashDurationTeamNotIn(vs ...float32) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldFlashDurationTeam), v...))
})
}
@@ -2488,12 +2176,6 @@ func FlashDurationEnemyIn(vs ...float32) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldFlashDurationEnemy), v...))
})
}
@@ -2505,12 +2187,6 @@ func FlashDurationEnemyNotIn(vs ...float32) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldFlashDurationEnemy), v...))
})
}
@@ -2578,12 +2254,6 @@ func FlashTotalSelfIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldFlashTotalSelf), v...))
})
}
@@ -2595,12 +2265,6 @@ func FlashTotalSelfNotIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldFlashTotalSelf), v...))
})
}
@@ -2668,12 +2332,6 @@ func FlashTotalTeamIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldFlashTotalTeam), v...))
})
}
@@ -2685,12 +2343,6 @@ func FlashTotalTeamNotIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldFlashTotalTeam), v...))
})
}
@@ -2758,12 +2410,6 @@ func FlashTotalEnemyIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldFlashTotalEnemy), v...))
})
}
@@ -2775,12 +2421,6 @@ func FlashTotalEnemyNotIn(vs ...uint) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldFlashTotalEnemy), v...))
})
}
@@ -2848,12 +2488,6 @@ func MatchStatsIn(vs ...uint64) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldMatchStats), v...))
})
}
@@ -2865,12 +2499,6 @@ func MatchStatsNotIn(vs ...uint64) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldMatchStats), v...))
})
}
@@ -2910,12 +2538,6 @@ func PlayerStatsIn(vs ...uint64) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldPlayerStats), v...))
})
}
@@ -2927,12 +2549,6 @@ func PlayerStatsNotIn(vs ...uint64) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldPlayerStats), v...))
})
}
@@ -2972,12 +2588,6 @@ func FlashAssistsIn(vs ...int) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldFlashAssists), v...))
})
}
@@ -2989,12 +2599,6 @@ func FlashAssistsNotIn(vs ...int) predicate.MatchPlayer {
v[i] = vs[i]
}
return predicate.MatchPlayer(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldFlashAssists), v...))
})
}

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -554,9 +554,15 @@ func (mpc *MatchPlayerCreate) Save(ctx context.Context) (*MatchPlayer, error) {
}
mut = mpc.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, mpc.mutation); err != nil {
v, err := mut.Mutate(ctx, mpc.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*MatchPlayer)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from MatchPlayerMutation", v)
}
node = nv
}
return node, err
}
@@ -618,7 +624,7 @@ func (mpc *MatchPlayerCreate) sqlSave(ctx context.Context) (*MatchPlayer, error)
_node, _spec := mpc.createSpec()
if err := sqlgraph.CreateNode(ctx, mpc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
@@ -1029,7 +1035,7 @@ func (mpcb *MatchPlayerCreateBulk) Save(ctx context.Context) ([]*MatchPlayer, er
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, mpcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
@@ -1037,11 +1043,11 @@ func (mpcb *MatchPlayerCreateBulk) Save(ctx context.Context) ([]*MatchPlayer, er
return nil, err
}
mutation.id = &nodes[i].ID
mutation.done = true
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -84,7 +84,11 @@ func (mpd *MatchPlayerDelete) sqlExec(ctx context.Context) (int, error) {
}
}
}
return sqlgraph.DeleteNodes(ctx, mpd.driver, _spec)
affected, err := sqlgraph.DeleteNodes(ctx, mpd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return affected, err
}
// MatchPlayerDeleteOne is the builder for deleting a single MatchPlayer entity.

View File

@@ -1,11 +1,10 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"database/sql/driver"
"errors"
"fmt"
"math"
@@ -25,20 +24,19 @@ import (
// MatchPlayerQuery is the builder for querying MatchPlayer entities.
type MatchPlayerQuery struct {
config
limit *int
offset *int
unique *bool
order []OrderFunc
fields []string
predicates []predicate.MatchPlayer
// eager-loading edges.
limit *int
offset *int
unique *bool
order []OrderFunc
fields []string
predicates []predicate.MatchPlayer
withMatches *MatchQuery
withPlayers *PlayerQuery
withWeaponStats *WeaponQuery
withRoundStats *RoundStatsQuery
withSpray *SprayQuery
withMessages *MessagesQuery
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)
@@ -481,17 +479,18 @@ func (mpq *MatchPlayerQuery) WithMessages(opts ...func(*MessagesQuery)) *MatchPl
// GroupBy(matchplayer.FieldTeamID).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
//
func (mpq *MatchPlayerQuery) GroupBy(field string, fields ...string) *MatchPlayerGroupBy {
group := &MatchPlayerGroupBy{config: mpq.config}
group.fields = append([]string{field}, fields...)
group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
grbuild := &MatchPlayerGroupBy{config: mpq.config}
grbuild.fields = append([]string{field}, fields...)
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) {
if err := mpq.prepareQuery(ctx); err != nil {
return nil, err
}
return mpq.sqlQuery(ctx), nil
}
return group
grbuild.label = matchplayer.Label
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
@@ -506,10 +505,12 @@ func (mpq *MatchPlayerQuery) GroupBy(field string, fields ...string) *MatchPlaye
// client.MatchPlayer.Query().
// Select(matchplayer.FieldTeamID).
// Scan(ctx, &v)
//
func (mpq *MatchPlayerQuery) Select(fields ...string) *MatchPlayerSelect {
mpq.fields = append(mpq.fields, fields...)
return &MatchPlayerSelect{MatchPlayerQuery: mpq}
selbuild := &MatchPlayerSelect{MatchPlayerQuery: mpq}
selbuild.label = matchplayer.Label
selbuild.flds, selbuild.scan = &mpq.fields, selbuild.Scan
return selbuild
}
func (mpq *MatchPlayerQuery) prepareQuery(ctx context.Context) error {
@@ -528,7 +529,7 @@ func (mpq *MatchPlayerQuery) prepareQuery(ctx context.Context) error {
return nil
}
func (mpq *MatchPlayerQuery) sqlAll(ctx context.Context) ([]*MatchPlayer, error) {
func (mpq *MatchPlayerQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*MatchPlayer, error) {
var (
nodes = []*MatchPlayer{}
_spec = mpq.querySpec()
@@ -542,197 +543,244 @@ func (mpq *MatchPlayerQuery) sqlAll(ctx context.Context) ([]*MatchPlayer, error)
}
)
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
node := &MatchPlayer{config: mpq.config}
nodes = append(nodes, node)
return node.scanValues(columns)
return (*MatchPlayer).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 := &MatchPlayer{config: mpq.config}
nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
}
if len(mpq.modifiers) > 0 {
_spec.Modifiers = mpq.modifiers
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, mpq.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
if query := mpq.withMatches; query != nil {
ids := make([]uint64, 0, len(nodes))
nodeids := make(map[uint64][]*MatchPlayer)
for i := range nodes {
fk := nodes[i].MatchStats
if _, ok := nodeids[fk]; !ok {
ids = append(ids, fk)
}
nodeids[fk] = append(nodeids[fk], nodes[i])
}
query.Where(match.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
if err := mpq.loadMatches(ctx, query, nodes, nil,
func(n *MatchPlayer, e *Match) { n.Edges.Matches = 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_stats" returned %v`, n.ID)
}
for i := range nodes {
nodes[i].Edges.Matches = n
}
}
}
if query := mpq.withPlayers; query != nil {
ids := make([]uint64, 0, len(nodes))
nodeids := make(map[uint64][]*MatchPlayer)
for i := range nodes {
fk := nodes[i].PlayerStats
if _, ok := nodeids[fk]; !ok {
ids = append(ids, fk)
}
nodeids[fk] = append(nodeids[fk], nodes[i])
}
query.Where(player.IDIn(ids...))
neighbors, err := query.All(ctx)
if err != nil {
if err := mpq.loadPlayers(ctx, query, nodes, nil,
func(n *MatchPlayer, e *Player) { n.Edges.Players = e }); err != nil {
return nil, err
}
for _, n := range neighbors {
nodes, ok := nodeids[n.ID]
if !ok {
return nil, fmt.Errorf(`unexpected foreign-key "player_stats" returned %v`, n.ID)
}
for i := range nodes {
nodes[i].Edges.Players = n
}
}
}
if query := mpq.withWeaponStats; query != nil {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[int]*MatchPlayer)
for i := range nodes {
fks = append(fks, nodes[i].ID)
nodeids[nodes[i].ID] = nodes[i]
nodes[i].Edges.WeaponStats = []*Weapon{}
}
query.withFKs = true
query.Where(predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.InValues(matchplayer.WeaponStatsColumn, fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
if err := mpq.loadWeaponStats(ctx, query, nodes,
func(n *MatchPlayer) { n.Edges.WeaponStats = []*Weapon{} },
func(n *MatchPlayer, e *Weapon) { n.Edges.WeaponStats = append(n.Edges.WeaponStats, e) }); err != nil {
return nil, err
}
for _, n := range neighbors {
fk := n.match_player_weapon_stats
if fk == nil {
return nil, fmt.Errorf(`foreign-key "match_player_weapon_stats" is nil for node %v`, n.ID)
}
node, ok := nodeids[*fk]
if !ok {
return nil, fmt.Errorf(`unexpected foreign-key "match_player_weapon_stats" returned %v for node %v`, *fk, n.ID)
}
node.Edges.WeaponStats = append(node.Edges.WeaponStats, n)
}
}
if query := mpq.withRoundStats; query != nil {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[int]*MatchPlayer)
for i := range nodes {
fks = append(fks, nodes[i].ID)
nodeids[nodes[i].ID] = nodes[i]
nodes[i].Edges.RoundStats = []*RoundStats{}
}
query.withFKs = true
query.Where(predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.InValues(matchplayer.RoundStatsColumn, fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
if err := mpq.loadRoundStats(ctx, query, nodes,
func(n *MatchPlayer) { n.Edges.RoundStats = []*RoundStats{} },
func(n *MatchPlayer, e *RoundStats) { n.Edges.RoundStats = append(n.Edges.RoundStats, e) }); err != nil {
return nil, err
}
for _, n := range neighbors {
fk := n.match_player_round_stats
if fk == nil {
return nil, fmt.Errorf(`foreign-key "match_player_round_stats" is nil for node %v`, n.ID)
}
node, ok := nodeids[*fk]
if !ok {
return nil, fmt.Errorf(`unexpected foreign-key "match_player_round_stats" returned %v for node %v`, *fk, n.ID)
}
node.Edges.RoundStats = append(node.Edges.RoundStats, n)
}
}
if query := mpq.withSpray; query != nil {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[int]*MatchPlayer)
for i := range nodes {
fks = append(fks, nodes[i].ID)
nodeids[nodes[i].ID] = nodes[i]
nodes[i].Edges.Spray = []*Spray{}
}
query.withFKs = true
query.Where(predicate.Spray(func(s *sql.Selector) {
s.Where(sql.InValues(matchplayer.SprayColumn, fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
if err := mpq.loadSpray(ctx, query, nodes,
func(n *MatchPlayer) { n.Edges.Spray = []*Spray{} },
func(n *MatchPlayer, e *Spray) { n.Edges.Spray = append(n.Edges.Spray, e) }); err != nil {
return nil, err
}
for _, n := range neighbors {
fk := n.match_player_spray
if fk == nil {
return nil, fmt.Errorf(`foreign-key "match_player_spray" is nil for node %v`, n.ID)
}
node, ok := nodeids[*fk]
if !ok {
return nil, fmt.Errorf(`unexpected foreign-key "match_player_spray" returned %v for node %v`, *fk, n.ID)
}
node.Edges.Spray = append(node.Edges.Spray, n)
}
}
if query := mpq.withMessages; query != nil {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[int]*MatchPlayer)
for i := range nodes {
fks = append(fks, nodes[i].ID)
nodeids[nodes[i].ID] = nodes[i]
nodes[i].Edges.Messages = []*Messages{}
}
query.withFKs = true
query.Where(predicate.Messages(func(s *sql.Selector) {
s.Where(sql.InValues(matchplayer.MessagesColumn, fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
if err := mpq.loadMessages(ctx, query, nodes,
func(n *MatchPlayer) { n.Edges.Messages = []*Messages{} },
func(n *MatchPlayer, e *Messages) { n.Edges.Messages = append(n.Edges.Messages, e) }); err != nil {
return nil, err
}
for _, n := range neighbors {
fk := n.match_player_messages
if fk == nil {
return nil, fmt.Errorf(`foreign-key "match_player_messages" is nil for node %v`, n.ID)
}
node, ok := nodeids[*fk]
if !ok {
return nil, fmt.Errorf(`unexpected foreign-key "match_player_messages" returned %v for node %v`, *fk, n.ID)
}
node.Edges.Messages = append(node.Edges.Messages, n)
}
return nodes, nil
}
func (mpq *MatchPlayerQuery) loadMatches(ctx context.Context, query *MatchQuery, nodes []*MatchPlayer, init func(*MatchPlayer), assign func(*MatchPlayer, *Match)) error {
ids := make([]uint64, 0, len(nodes))
nodeids := make(map[uint64][]*MatchPlayer)
for i := range nodes {
fk := nodes[i].MatchStats
if _, ok := nodeids[fk]; !ok {
ids = append(ids, fk)
}
nodeids[fk] = append(nodeids[fk], nodes[i])
}
query.Where(match.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_stats" returned %v`, n.ID)
}
for i := range nodes {
assign(nodes[i], n)
}
}
return nodes, nil
return nil
}
func (mpq *MatchPlayerQuery) loadPlayers(ctx context.Context, query *PlayerQuery, nodes []*MatchPlayer, init func(*MatchPlayer), assign func(*MatchPlayer, *Player)) error {
ids := make([]uint64, 0, len(nodes))
nodeids := make(map[uint64][]*MatchPlayer)
for i := range nodes {
fk := nodes[i].PlayerStats
if _, ok := nodeids[fk]; !ok {
ids = append(ids, fk)
}
nodeids[fk] = append(nodeids[fk], nodes[i])
}
query.Where(player.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 "player_stats" returned %v`, n.ID)
}
for i := range nodes {
assign(nodes[i], n)
}
}
return nil
}
func (mpq *MatchPlayerQuery) loadWeaponStats(ctx context.Context, query *WeaponQuery, nodes []*MatchPlayer, init func(*MatchPlayer), assign func(*MatchPlayer, *Weapon)) error {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[int]*MatchPlayer)
for i := range nodes {
fks = append(fks, nodes[i].ID)
nodeids[nodes[i].ID] = nodes[i]
if init != nil {
init(nodes[i])
}
}
query.withFKs = true
query.Where(predicate.Weapon(func(s *sql.Selector) {
s.Where(sql.InValues(matchplayer.WeaponStatsColumn, fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
fk := n.match_player_weapon_stats
if fk == nil {
return fmt.Errorf(`foreign-key "match_player_weapon_stats" is nil for node %v`, n.ID)
}
node, ok := nodeids[*fk]
if !ok {
return fmt.Errorf(`unexpected foreign-key "match_player_weapon_stats" returned %v for node %v`, *fk, n.ID)
}
assign(node, n)
}
return nil
}
func (mpq *MatchPlayerQuery) loadRoundStats(ctx context.Context, query *RoundStatsQuery, nodes []*MatchPlayer, init func(*MatchPlayer), assign func(*MatchPlayer, *RoundStats)) error {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[int]*MatchPlayer)
for i := range nodes {
fks = append(fks, nodes[i].ID)
nodeids[nodes[i].ID] = nodes[i]
if init != nil {
init(nodes[i])
}
}
query.withFKs = true
query.Where(predicate.RoundStats(func(s *sql.Selector) {
s.Where(sql.InValues(matchplayer.RoundStatsColumn, fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
fk := n.match_player_round_stats
if fk == nil {
return fmt.Errorf(`foreign-key "match_player_round_stats" is nil for node %v`, n.ID)
}
node, ok := nodeids[*fk]
if !ok {
return fmt.Errorf(`unexpected foreign-key "match_player_round_stats" returned %v for node %v`, *fk, n.ID)
}
assign(node, n)
}
return nil
}
func (mpq *MatchPlayerQuery) loadSpray(ctx context.Context, query *SprayQuery, nodes []*MatchPlayer, init func(*MatchPlayer), assign func(*MatchPlayer, *Spray)) error {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[int]*MatchPlayer)
for i := range nodes {
fks = append(fks, nodes[i].ID)
nodeids[nodes[i].ID] = nodes[i]
if init != nil {
init(nodes[i])
}
}
query.withFKs = true
query.Where(predicate.Spray(func(s *sql.Selector) {
s.Where(sql.InValues(matchplayer.SprayColumn, fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
fk := n.match_player_spray
if fk == nil {
return fmt.Errorf(`foreign-key "match_player_spray" is nil for node %v`, n.ID)
}
node, ok := nodeids[*fk]
if !ok {
return fmt.Errorf(`unexpected foreign-key "match_player_spray" returned %v for node %v`, *fk, n.ID)
}
assign(node, n)
}
return nil
}
func (mpq *MatchPlayerQuery) loadMessages(ctx context.Context, query *MessagesQuery, nodes []*MatchPlayer, init func(*MatchPlayer), assign func(*MatchPlayer, *Messages)) error {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[int]*MatchPlayer)
for i := range nodes {
fks = append(fks, nodes[i].ID)
nodeids[nodes[i].ID] = nodes[i]
if init != nil {
init(nodes[i])
}
}
query.withFKs = true
query.Where(predicate.Messages(func(s *sql.Selector) {
s.Where(sql.InValues(matchplayer.MessagesColumn, fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
fk := n.match_player_messages
if fk == nil {
return fmt.Errorf(`foreign-key "match_player_messages" is nil for node %v`, n.ID)
}
node, ok := nodeids[*fk]
if !ok {
return fmt.Errorf(`unexpected foreign-key "match_player_messages" returned %v for node %v`, *fk, n.ID)
}
assign(node, n)
}
return nil
}
func (mpq *MatchPlayerQuery) sqlCount(ctx context.Context) (int, error) {
@@ -847,6 +895,7 @@ func (mpq *MatchPlayerQuery) Modify(modifiers ...func(s *sql.Selector)) *MatchPl
// MatchPlayerGroupBy is the group-by builder for MatchPlayer entities.
type MatchPlayerGroupBy struct {
config
selector
fields []string
fns []AggregateFunc
// intermediate query (i.e. traversal path).
@@ -870,209 +919,6 @@ func (mpgb *MatchPlayerGroupBy) Scan(ctx context.Context, v interface{}) error {
return mpgb.sqlScan(ctx, v)
}
// ScanX is like Scan, but panics if an error occurs.
func (mpgb *MatchPlayerGroupBy) ScanX(ctx context.Context, v interface{}) {
if err := mpgb.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 (mpgb *MatchPlayerGroupBy) Strings(ctx context.Context) ([]string, error) {
if len(mpgb.fields) > 1 {
return nil, errors.New("ent: MatchPlayerGroupBy.Strings is not achievable when grouping more than 1 field")
}
var v []string
if err := mpgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (mpgb *MatchPlayerGroupBy) StringsX(ctx context.Context) []string {
v, err := mpgb.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 (mpgb *MatchPlayerGroupBy) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = mpgb.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{matchplayer.Label}
default:
err = fmt.Errorf("ent: MatchPlayerGroupBy.Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (mpgb *MatchPlayerGroupBy) StringX(ctx context.Context) string {
v, err := mpgb.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 (mpgb *MatchPlayerGroupBy) Ints(ctx context.Context) ([]int, error) {
if len(mpgb.fields) > 1 {
return nil, errors.New("ent: MatchPlayerGroupBy.Ints is not achievable when grouping more than 1 field")
}
var v []int
if err := mpgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (mpgb *MatchPlayerGroupBy) IntsX(ctx context.Context) []int {
v, err := mpgb.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 (mpgb *MatchPlayerGroupBy) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = mpgb.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{matchplayer.Label}
default:
err = fmt.Errorf("ent: MatchPlayerGroupBy.Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (mpgb *MatchPlayerGroupBy) IntX(ctx context.Context) int {
v, err := mpgb.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 (mpgb *MatchPlayerGroupBy) Float64s(ctx context.Context) ([]float64, error) {
if len(mpgb.fields) > 1 {
return nil, errors.New("ent: MatchPlayerGroupBy.Float64s is not achievable when grouping more than 1 field")
}
var v []float64
if err := mpgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (mpgb *MatchPlayerGroupBy) Float64sX(ctx context.Context) []float64 {
v, err := mpgb.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 (mpgb *MatchPlayerGroupBy) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = mpgb.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{matchplayer.Label}
default:
err = fmt.Errorf("ent: MatchPlayerGroupBy.Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (mpgb *MatchPlayerGroupBy) Float64X(ctx context.Context) float64 {
v, err := mpgb.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 (mpgb *MatchPlayerGroupBy) Bools(ctx context.Context) ([]bool, error) {
if len(mpgb.fields) > 1 {
return nil, errors.New("ent: MatchPlayerGroupBy.Bools is not achievable when grouping more than 1 field")
}
var v []bool
if err := mpgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (mpgb *MatchPlayerGroupBy) BoolsX(ctx context.Context) []bool {
v, err := mpgb.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 (mpgb *MatchPlayerGroupBy) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = mpgb.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{matchplayer.Label}
default:
err = fmt.Errorf("ent: MatchPlayerGroupBy.Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (mpgb *MatchPlayerGroupBy) BoolX(ctx context.Context) bool {
v, err := mpgb.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
func (mpgb *MatchPlayerGroupBy) sqlScan(ctx context.Context, v interface{}) error {
for _, f := range mpgb.fields {
if !matchplayer.ValidColumn(f) {
@@ -1114,6 +960,7 @@ func (mpgb *MatchPlayerGroupBy) sqlQuery() *sql.Selector {
// MatchPlayerSelect is the builder for selecting fields of MatchPlayer entities.
type MatchPlayerSelect struct {
*MatchPlayerQuery
selector
// intermediate query (i.e. traversal path).
sql *sql.Selector
}
@@ -1127,201 +974,6 @@ func (mps *MatchPlayerSelect) Scan(ctx context.Context, v interface{}) error {
return mps.sqlScan(ctx, v)
}
// ScanX is like Scan, but panics if an error occurs.
func (mps *MatchPlayerSelect) ScanX(ctx context.Context, v interface{}) {
if err := mps.Scan(ctx, v); err != nil {
panic(err)
}
}
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
func (mps *MatchPlayerSelect) Strings(ctx context.Context) ([]string, error) {
if len(mps.fields) > 1 {
return nil, errors.New("ent: MatchPlayerSelect.Strings is not achievable when selecting more than 1 field")
}
var v []string
if err := mps.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (mps *MatchPlayerSelect) StringsX(ctx context.Context) []string {
v, err := mps.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 (mps *MatchPlayerSelect) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = mps.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{matchplayer.Label}
default:
err = fmt.Errorf("ent: MatchPlayerSelect.Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (mps *MatchPlayerSelect) StringX(ctx context.Context) string {
v, err := mps.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 (mps *MatchPlayerSelect) Ints(ctx context.Context) ([]int, error) {
if len(mps.fields) > 1 {
return nil, errors.New("ent: MatchPlayerSelect.Ints is not achievable when selecting more than 1 field")
}
var v []int
if err := mps.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (mps *MatchPlayerSelect) IntsX(ctx context.Context) []int {
v, err := mps.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 (mps *MatchPlayerSelect) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = mps.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{matchplayer.Label}
default:
err = fmt.Errorf("ent: MatchPlayerSelect.Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (mps *MatchPlayerSelect) IntX(ctx context.Context) int {
v, err := mps.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 (mps *MatchPlayerSelect) Float64s(ctx context.Context) ([]float64, error) {
if len(mps.fields) > 1 {
return nil, errors.New("ent: MatchPlayerSelect.Float64s is not achievable when selecting more than 1 field")
}
var v []float64
if err := mps.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (mps *MatchPlayerSelect) Float64sX(ctx context.Context) []float64 {
v, err := mps.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 (mps *MatchPlayerSelect) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = mps.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{matchplayer.Label}
default:
err = fmt.Errorf("ent: MatchPlayerSelect.Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (mps *MatchPlayerSelect) Float64X(ctx context.Context) float64 {
v, err := mps.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 (mps *MatchPlayerSelect) Bools(ctx context.Context) ([]bool, error) {
if len(mps.fields) > 1 {
return nil, errors.New("ent: MatchPlayerSelect.Bools is not achievable when selecting more than 1 field")
}
var v []bool
if err := mps.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (mps *MatchPlayerSelect) BoolsX(ctx context.Context) []bool {
v, err := mps.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 (mps *MatchPlayerSelect) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = mps.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{matchplayer.Label}
default:
err = fmt.Errorf("ent: MatchPlayerSelect.Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (mps *MatchPlayerSelect) BoolX(ctx context.Context) bool {
v, err := mps.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
func (mps *MatchPlayerSelect) sqlScan(ctx context.Context, v interface{}) error {
rows := &sql.Rows{}
query, args := mps.sql.Query()

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -23,8 +23,9 @@ import (
// MatchPlayerUpdate is the builder for updating MatchPlayer entities.
type MatchPlayerUpdate struct {
config
hooks []Hook
mutation *MatchPlayerMutation
hooks []Hook
mutation *MatchPlayerMutation
modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the MatchPlayerUpdate builder.
@@ -1040,6 +1041,12 @@ func (mpu *MatchPlayerUpdate) check() error {
return nil
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (mpu *MatchPlayerUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MatchPlayerUpdate {
mpu.modifiers = append(mpu.modifiers, modifiers...)
return mpu
}
func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
@@ -1888,11 +1895,12 @@ func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.Modifiers = mpu.modifiers
if n, err = sqlgraph.UpdateNodes(ctx, mpu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{matchplayer.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
@@ -1902,9 +1910,10 @@ func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) {
// MatchPlayerUpdateOne is the builder for updating a single MatchPlayer entity.
type MatchPlayerUpdateOne struct {
config
fields []string
hooks []Hook
mutation *MatchPlayerMutation
fields []string
hooks []Hook
mutation *MatchPlayerMutation
modifiers []func(*sql.UpdateBuilder)
}
// SetTeamID sets the "team_id" field.
@@ -2882,9 +2891,15 @@ func (mpuo *MatchPlayerUpdateOne) Save(ctx context.Context) (*MatchPlayer, error
}
mut = mpuo.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, mpuo.mutation); err != nil {
v, err := mut.Mutate(ctx, mpuo.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*MatchPlayer)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from MatchPlayerMutation", v)
}
node = nv
}
return node, err
}
@@ -2921,6 +2936,12 @@ func (mpuo *MatchPlayerUpdateOne) check() error {
return nil
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (mpuo *MatchPlayerUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MatchPlayerUpdateOne {
mpuo.modifiers = append(mpuo.modifiers, modifiers...)
return mpuo
}
func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlayer, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
@@ -3786,6 +3807,7 @@ func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlay
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.Modifiers = mpuo.modifiers
_node = &MatchPlayer{config: mpuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
@@ -3793,7 +3815,7 @@ func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlay
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{matchplayer.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -42,8 +42,7 @@ type MessagesEdges struct {
func (e MessagesEdges) MatchPlayerOrErr() (*MatchPlayer, error) {
if e.loadedTypes[0] {
if e.MatchPlayer == nil {
// The edge match_player was loaded in eager-loading,
// but was not found.
// Edge was loaded but was not found.
return nil, &NotFoundError{label: matchplayer.Label}
}
return e.MatchPlayer, nil
@@ -130,11 +129,11 @@ func (m *Messages) Update() *MessagesUpdateOne {
// Unwrap unwraps the Messages entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (m *Messages) Unwrap() *Messages {
tx, ok := m.config.driver.(*txDriver)
_tx, ok := m.config.driver.(*txDriver)
if !ok {
panic("ent: Messages is not a transactional entity")
}
m.config.driver = tx.drv
m.config.driver = _tx.drv
return m
}
@@ -142,12 +141,14 @@ func (m *Messages) Unwrap() *Messages {
func (m *Messages) String() string {
var builder strings.Builder
builder.WriteString("Messages(")
builder.WriteString(fmt.Sprintf("id=%v", m.ID))
builder.WriteString(", message=")
builder.WriteString(fmt.Sprintf("id=%v, ", m.ID))
builder.WriteString("message=")
builder.WriteString(m.Message)
builder.WriteString(", all_chat=")
builder.WriteString(", ")
builder.WriteString("all_chat=")
builder.WriteString(fmt.Sprintf("%v", m.AllChat))
builder.WriteString(", tick=")
builder.WriteString(", ")
builder.WriteString("tick=")
builder.WriteString(fmt.Sprintf("%v", m.Tick))
builder.WriteByte(')')
return builder.String()

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package messages

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package messages
@@ -32,12 +32,6 @@ func IDNEQ(id int) predicate.Messages {
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(ids) == 0 {
s.Where(sql.False())
return
}
v := make([]interface{}, len(ids))
for i := range v {
v[i] = ids[i]
@@ -49,12 +43,6 @@ func IDIn(ids ...int) predicate.Messages {
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(ids) == 0 {
s.Where(sql.False())
return
}
v := make([]interface{}, len(ids))
for i := range v {
v[i] = ids[i]
@@ -133,12 +121,6 @@ func MessageIn(vs ...string) predicate.Messages {
v[i] = vs[i]
}
return predicate.Messages(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldMessage), v...))
})
}
@@ -150,12 +132,6 @@ func MessageNotIn(vs ...string) predicate.Messages {
v[i] = vs[i]
}
return predicate.Messages(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldMessage), v...))
})
}
@@ -258,12 +234,6 @@ func TickIn(vs ...int) predicate.Messages {
v[i] = vs[i]
}
return predicate.Messages(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldTick), v...))
})
}
@@ -275,12 +245,6 @@ func TickNotIn(vs ...int) predicate.Messages {
v[i] = vs[i]
}
return predicate.Messages(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldTick), v...))
})
}

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -96,9 +96,15 @@ func (mc *MessagesCreate) Save(ctx context.Context) (*Messages, error) {
}
mut = mc.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, mc.mutation); err != nil {
v, err := mut.Mutate(ctx, mc.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*Messages)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from MessagesMutation", v)
}
node = nv
}
return node, err
}
@@ -143,7 +149,7 @@ func (mc *MessagesCreate) sqlSave(ctx context.Context) (*Messages, error) {
_node, _spec := mc.createSpec()
if err := sqlgraph.CreateNode(ctx, mc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
@@ -242,7 +248,7 @@ func (mcb *MessagesCreateBulk) Save(ctx context.Context) ([]*Messages, error) {
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, mcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
@@ -250,11 +256,11 @@ func (mcb *MessagesCreateBulk) Save(ctx context.Context) ([]*Messages, error) {
return nil, err
}
mutation.id = &nodes[i].ID
mutation.done = true
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -84,7 +84,11 @@ func (md *MessagesDelete) sqlExec(ctx context.Context) (int, error) {
}
}
}
return sqlgraph.DeleteNodes(ctx, md.driver, _spec)
affected, err := sqlgraph.DeleteNodes(ctx, md.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return affected, err
}
// MessagesDeleteOne is the builder for deleting a single Messages entity.

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 (
// MessagesQuery is the builder for querying Messages entities.
type MessagesQuery struct {
config
limit *int
offset *int
unique *bool
order []OrderFunc
fields []string
predicates []predicate.Messages
// eager-loading edges.
limit *int
offset *int
unique *bool
order []OrderFunc
fields []string
predicates []predicate.Messages
withMatchPlayer *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 (mq *MessagesQuery) WithMatchPlayer(opts ...func(*MatchPlayerQuery)) *Messa
// GroupBy(messages.FieldMessage).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
//
func (mq *MessagesQuery) GroupBy(field string, fields ...string) *MessagesGroupBy {
group := &MessagesGroupBy{config: mq.config}
group.fields = append([]string{field}, fields...)
group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
grbuild := &MessagesGroupBy{config: mq.config}
grbuild.fields = append([]string{field}, fields...)
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) {
if err := mq.prepareQuery(ctx); err != nil {
return nil, err
}
return mq.sqlQuery(ctx), nil
}
return group
grbuild.label = messages.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 (mq *MessagesQuery) GroupBy(field string, fields ...string) *MessagesGroupB
// client.Messages.Query().
// Select(messages.FieldMessage).
// Scan(ctx, &v)
//
func (mq *MessagesQuery) Select(fields ...string) *MessagesSelect {
mq.fields = append(mq.fields, fields...)
return &MessagesSelect{MessagesQuery: mq}
selbuild := &MessagesSelect{MessagesQuery: mq}
selbuild.label = messages.Label
selbuild.flds, selbuild.scan = &mq.fields, selbuild.Scan
return selbuild
}
func (mq *MessagesQuery) prepareQuery(ctx context.Context) error {
@@ -348,7 +349,7 @@ func (mq *MessagesQuery) prepareQuery(ctx context.Context) error {
return nil
}
func (mq *MessagesQuery) sqlAll(ctx context.Context) ([]*Messages, error) {
func (mq *MessagesQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Messages, error) {
var (
nodes = []*Messages{}
withFKs = mq.withFKs
@@ -364,58 +365,63 @@ func (mq *MessagesQuery) sqlAll(ctx context.Context) ([]*Messages, error) {
_spec.Node.Columns = append(_spec.Node.Columns, messages.ForeignKeys...)
}
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
node := &Messages{config: mq.config}
nodes = append(nodes, node)
return node.scanValues(columns)
return (*Messages).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 := &Messages{config: mq.config}
nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
}
if len(mq.modifiers) > 0 {
_spec.Modifiers = mq.modifiers
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, mq.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
if query := mq.withMatchPlayer; query != nil {
ids := make([]int, 0, len(nodes))
nodeids := make(map[int][]*Messages)
for i := range nodes {
if nodes[i].match_player_messages == nil {
continue
}
fk := *nodes[i].match_player_messages
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 := mq.loadMatchPlayer(ctx, query, nodes, nil,
func(n *Messages, e *MatchPlayer) { n.Edges.MatchPlayer = 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_messages" returned %v`, n.ID)
}
for i := range nodes {
nodes[i].Edges.MatchPlayer = n
}
}
return nodes, nil
}
func (mq *MessagesQuery) loadMatchPlayer(ctx context.Context, query *MatchPlayerQuery, nodes []*Messages, init func(*Messages), assign func(*Messages, *MatchPlayer)) error {
ids := make([]int, 0, len(nodes))
nodeids := make(map[int][]*Messages)
for i := range nodes {
if nodes[i].match_player_messages == nil {
continue
}
fk := *nodes[i].match_player_messages
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_messages" returned %v`, n.ID)
}
for i := range nodes {
assign(nodes[i], n)
}
}
return nodes, nil
return nil
}
func (mq *MessagesQuery) sqlCount(ctx context.Context) (int, error) {
@@ -530,6 +536,7 @@ func (mq *MessagesQuery) Modify(modifiers ...func(s *sql.Selector)) *MessagesSel
// MessagesGroupBy is the group-by builder for Messages entities.
type MessagesGroupBy struct {
config
selector
fields []string
fns []AggregateFunc
// intermediate query (i.e. traversal path).
@@ -553,209 +560,6 @@ func (mgb *MessagesGroupBy) Scan(ctx context.Context, v interface{}) error {
return mgb.sqlScan(ctx, v)
}
// ScanX is like Scan, but panics if an error occurs.
func (mgb *MessagesGroupBy) ScanX(ctx context.Context, v interface{}) {
if err := mgb.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 (mgb *MessagesGroupBy) Strings(ctx context.Context) ([]string, error) {
if len(mgb.fields) > 1 {
return nil, errors.New("ent: MessagesGroupBy.Strings is not achievable when grouping more than 1 field")
}
var v []string
if err := mgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (mgb *MessagesGroupBy) StringsX(ctx context.Context) []string {
v, err := mgb.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 (mgb *MessagesGroupBy) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = mgb.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{messages.Label}
default:
err = fmt.Errorf("ent: MessagesGroupBy.Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (mgb *MessagesGroupBy) StringX(ctx context.Context) string {
v, err := mgb.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 (mgb *MessagesGroupBy) Ints(ctx context.Context) ([]int, error) {
if len(mgb.fields) > 1 {
return nil, errors.New("ent: MessagesGroupBy.Ints is not achievable when grouping more than 1 field")
}
var v []int
if err := mgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (mgb *MessagesGroupBy) IntsX(ctx context.Context) []int {
v, err := mgb.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 (mgb *MessagesGroupBy) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = mgb.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{messages.Label}
default:
err = fmt.Errorf("ent: MessagesGroupBy.Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (mgb *MessagesGroupBy) IntX(ctx context.Context) int {
v, err := mgb.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 (mgb *MessagesGroupBy) Float64s(ctx context.Context) ([]float64, error) {
if len(mgb.fields) > 1 {
return nil, errors.New("ent: MessagesGroupBy.Float64s is not achievable when grouping more than 1 field")
}
var v []float64
if err := mgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (mgb *MessagesGroupBy) Float64sX(ctx context.Context) []float64 {
v, err := mgb.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 (mgb *MessagesGroupBy) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = mgb.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{messages.Label}
default:
err = fmt.Errorf("ent: MessagesGroupBy.Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (mgb *MessagesGroupBy) Float64X(ctx context.Context) float64 {
v, err := mgb.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 (mgb *MessagesGroupBy) Bools(ctx context.Context) ([]bool, error) {
if len(mgb.fields) > 1 {
return nil, errors.New("ent: MessagesGroupBy.Bools is not achievable when grouping more than 1 field")
}
var v []bool
if err := mgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (mgb *MessagesGroupBy) BoolsX(ctx context.Context) []bool {
v, err := mgb.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 (mgb *MessagesGroupBy) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = mgb.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{messages.Label}
default:
err = fmt.Errorf("ent: MessagesGroupBy.Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (mgb *MessagesGroupBy) BoolX(ctx context.Context) bool {
v, err := mgb.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
func (mgb *MessagesGroupBy) sqlScan(ctx context.Context, v interface{}) error {
for _, f := range mgb.fields {
if !messages.ValidColumn(f) {
@@ -797,6 +601,7 @@ func (mgb *MessagesGroupBy) sqlQuery() *sql.Selector {
// MessagesSelect is the builder for selecting fields of Messages entities.
type MessagesSelect struct {
*MessagesQuery
selector
// intermediate query (i.e. traversal path).
sql *sql.Selector
}
@@ -810,201 +615,6 @@ func (ms *MessagesSelect) Scan(ctx context.Context, v interface{}) error {
return ms.sqlScan(ctx, v)
}
// ScanX is like Scan, but panics if an error occurs.
func (ms *MessagesSelect) ScanX(ctx context.Context, v interface{}) {
if err := ms.Scan(ctx, v); err != nil {
panic(err)
}
}
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
func (ms *MessagesSelect) Strings(ctx context.Context) ([]string, error) {
if len(ms.fields) > 1 {
return nil, errors.New("ent: MessagesSelect.Strings is not achievable when selecting more than 1 field")
}
var v []string
if err := ms.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (ms *MessagesSelect) StringsX(ctx context.Context) []string {
v, err := ms.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 (ms *MessagesSelect) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = ms.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{messages.Label}
default:
err = fmt.Errorf("ent: MessagesSelect.Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (ms *MessagesSelect) StringX(ctx context.Context) string {
v, err := ms.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 (ms *MessagesSelect) Ints(ctx context.Context) ([]int, error) {
if len(ms.fields) > 1 {
return nil, errors.New("ent: MessagesSelect.Ints is not achievable when selecting more than 1 field")
}
var v []int
if err := ms.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (ms *MessagesSelect) IntsX(ctx context.Context) []int {
v, err := ms.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 (ms *MessagesSelect) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = ms.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{messages.Label}
default:
err = fmt.Errorf("ent: MessagesSelect.Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (ms *MessagesSelect) IntX(ctx context.Context) int {
v, err := ms.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 (ms *MessagesSelect) Float64s(ctx context.Context) ([]float64, error) {
if len(ms.fields) > 1 {
return nil, errors.New("ent: MessagesSelect.Float64s is not achievable when selecting more than 1 field")
}
var v []float64
if err := ms.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (ms *MessagesSelect) Float64sX(ctx context.Context) []float64 {
v, err := ms.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 (ms *MessagesSelect) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = ms.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{messages.Label}
default:
err = fmt.Errorf("ent: MessagesSelect.Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (ms *MessagesSelect) Float64X(ctx context.Context) float64 {
v, err := ms.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 (ms *MessagesSelect) Bools(ctx context.Context) ([]bool, error) {
if len(ms.fields) > 1 {
return nil, errors.New("ent: MessagesSelect.Bools is not achievable when selecting more than 1 field")
}
var v []bool
if err := ms.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (ms *MessagesSelect) BoolsX(ctx context.Context) []bool {
v, err := ms.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 (ms *MessagesSelect) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = ms.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{messages.Label}
default:
err = fmt.Errorf("ent: MessagesSelect.Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (ms *MessagesSelect) BoolX(ctx context.Context) bool {
v, err := ms.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
func (ms *MessagesSelect) sqlScan(ctx context.Context, v interface{}) error {
rows := &sql.Rows{}
query, args := ms.sql.Query()

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -18,8 +18,9 @@ import (
// MessagesUpdate is the builder for updating Messages entities.
type MessagesUpdate struct {
config
hooks []Hook
mutation *MessagesMutation
hooks []Hook
mutation *MessagesMutation
modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the MessagesUpdate builder.
@@ -137,6 +138,12 @@ func (mu *MessagesUpdate) ExecX(ctx context.Context) {
}
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (mu *MessagesUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MessagesUpdate {
mu.modifiers = append(mu.modifiers, modifiers...)
return mu
}
func (mu *MessagesUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
@@ -218,11 +225,12 @@ func (mu *MessagesUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.Modifiers = mu.modifiers
if n, err = sqlgraph.UpdateNodes(ctx, mu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{messages.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
@@ -232,9 +240,10 @@ func (mu *MessagesUpdate) sqlSave(ctx context.Context) (n int, err error) {
// MessagesUpdateOne is the builder for updating a single Messages entity.
type MessagesUpdateOne struct {
config
fields []string
hooks []Hook
mutation *MessagesMutation
fields []string
hooks []Hook
mutation *MessagesMutation
modifiers []func(*sql.UpdateBuilder)
}
// SetMessage sets the "message" field.
@@ -324,9 +333,15 @@ func (muo *MessagesUpdateOne) Save(ctx context.Context) (*Messages, error) {
}
mut = muo.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, muo.mutation); err != nil {
v, err := mut.Mutate(ctx, muo.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*Messages)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from MessagesMutation", v)
}
node = nv
}
return node, err
}
@@ -353,6 +368,12 @@ func (muo *MessagesUpdateOne) ExecX(ctx context.Context) {
}
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (muo *MessagesUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MessagesUpdateOne {
muo.modifiers = append(muo.modifiers, modifiers...)
return muo
}
func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
@@ -451,6 +472,7 @@ func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.Modifiers = muo.modifiers
_node = &Messages{config: muo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
@@ -458,7 +480,7 @@ func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{messages.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package migrate
@@ -28,9 +28,6 @@ var (
// and therefore, it's recommended to enable this option to get more
// flexibility in the schema changes.
WithDropIndex = schema.WithDropIndex
// WithFixture sets the foreign-key renaming option to the migration when upgrading
// ent from v0.1.0 (issue-#285). Defaults to false.
WithFixture = schema.WithFixture
// WithForeignKeys enables creating foreign-key in schema DDL. This defaults to true.
WithForeignKeys = schema.WithForeignKeys
)
@@ -45,27 +42,23 @@ func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} }
// Create creates all schema resources.
func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error {
return Create(ctx, s, Tables, opts...)
}
// Create creates all table resources using the given schema driver.
func Create(ctx context.Context, s *Schema, tables []*schema.Table, opts ...schema.MigrateOption) error {
migrate, err := schema.NewMigrate(s.drv, opts...)
if err != nil {
return fmt.Errorf("ent/migrate: %w", err)
}
return migrate.Create(ctx, Tables...)
return migrate.Create(ctx, tables...)
}
// WriteTo writes the schema changes to w instead of running them against the database.
//
// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil {
// if err := client.Schema.WriteTo(context.Background(), os.Stdout); err != nil {
// log.Fatal(err)
// }
//
// }
func (s *Schema) WriteTo(ctx context.Context, w io.Writer, opts ...schema.MigrateOption) error {
drv := &schema.WriteDriver{
Writer: w,
Driver: s.drv,
}
migrate, err := schema.NewMigrate(drv, opts...)
if err != nil {
return fmt.Errorf("ent/migrate: %w", err)
}
return migrate.Create(ctx, Tables...)
return Create(ctx, &Schema{drv: &schema.WriteDriver{Writer: w, Driver: s.drv}}, Tables, opts...)
}

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package migrate

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -235,11 +235,11 @@ func (pl *Player) Update() *PlayerUpdateOne {
// Unwrap unwraps the Player entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (pl *Player) Unwrap() *Player {
tx, ok := pl.config.driver.(*txDriver)
_tx, ok := pl.config.driver.(*txDriver)
if !ok {
panic("ent: Player is not a transactional entity")
}
pl.config.driver = tx.drv
pl.config.driver = _tx.drv
return pl
}
@@ -247,37 +247,52 @@ func (pl *Player) Unwrap() *Player {
func (pl *Player) String() string {
var builder strings.Builder
builder.WriteString("Player(")
builder.WriteString(fmt.Sprintf("id=%v", pl.ID))
builder.WriteString(", name=")
builder.WriteString(fmt.Sprintf("id=%v, ", pl.ID))
builder.WriteString("name=")
builder.WriteString(pl.Name)
builder.WriteString(", avatar=")
builder.WriteString(", ")
builder.WriteString("avatar=")
builder.WriteString(pl.Avatar)
builder.WriteString(", vanity_url=")
builder.WriteString(", ")
builder.WriteString("vanity_url=")
builder.WriteString(pl.VanityURL)
builder.WriteString(", vanity_url_real=")
builder.WriteString(", ")
builder.WriteString("vanity_url_real=")
builder.WriteString(pl.VanityURLReal)
builder.WriteString(", vac_date=")
builder.WriteString(", ")
builder.WriteString("vac_date=")
builder.WriteString(pl.VacDate.Format(time.ANSIC))
builder.WriteString(", vac_count=")
builder.WriteString(", ")
builder.WriteString("vac_count=")
builder.WriteString(fmt.Sprintf("%v", pl.VacCount))
builder.WriteString(", game_ban_date=")
builder.WriteString(", ")
builder.WriteString("game_ban_date=")
builder.WriteString(pl.GameBanDate.Format(time.ANSIC))
builder.WriteString(", game_ban_count=")
builder.WriteString(", ")
builder.WriteString("game_ban_count=")
builder.WriteString(fmt.Sprintf("%v", pl.GameBanCount))
builder.WriteString(", steam_updated=")
builder.WriteString(", ")
builder.WriteString("steam_updated=")
builder.WriteString(pl.SteamUpdated.Format(time.ANSIC))
builder.WriteString(", sharecode_updated=")
builder.WriteString(", ")
builder.WriteString("sharecode_updated=")
builder.WriteString(pl.SharecodeUpdated.Format(time.ANSIC))
builder.WriteString(", auth_code=<sensitive>")
builder.WriteString(", profile_created=")
builder.WriteString(", ")
builder.WriteString("auth_code=<sensitive>")
builder.WriteString(", ")
builder.WriteString("profile_created=")
builder.WriteString(pl.ProfileCreated.Format(time.ANSIC))
builder.WriteString(", oldest_sharecode_seen=")
builder.WriteString(", ")
builder.WriteString("oldest_sharecode_seen=")
builder.WriteString(pl.OldestSharecodeSeen)
builder.WriteString(", wins=")
builder.WriteString(", ")
builder.WriteString("wins=")
builder.WriteString(fmt.Sprintf("%v", pl.Wins))
builder.WriteString(", looses=")
builder.WriteString(", ")
builder.WriteString("looses=")
builder.WriteString(fmt.Sprintf("%v", pl.Looses))
builder.WriteString(", ties=")
builder.WriteString(", ")
builder.WriteString("ties=")
builder.WriteString(fmt.Sprintf("%v", pl.Ties))
builder.WriteByte(')')
return builder.String()

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package player

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package player
@@ -34,12 +34,6 @@ func IDNEQ(id uint64) predicate.Player {
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...uint64) predicate.Player {
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(ids) == 0 {
s.Where(sql.False())
return
}
v := make([]interface{}, len(ids))
for i := range v {
v[i] = ids[i]
@@ -51,12 +45,6 @@ func IDIn(ids ...uint64) predicate.Player {
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...uint64) predicate.Player {
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(ids) == 0 {
s.Where(sql.False())
return
}
v := make([]interface{}, len(ids))
for i := range v {
v[i] = ids[i]
@@ -226,12 +214,6 @@ func NameIn(vs ...string) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldName), v...))
})
}
@@ -243,12 +225,6 @@ func NameNotIn(vs ...string) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldName), v...))
})
}
@@ -351,12 +327,6 @@ func AvatarIn(vs ...string) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldAvatar), v...))
})
}
@@ -368,12 +338,6 @@ func AvatarNotIn(vs ...string) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldAvatar), v...))
})
}
@@ -476,12 +440,6 @@ func VanityURLIn(vs ...string) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldVanityURL), v...))
})
}
@@ -493,12 +451,6 @@ func VanityURLNotIn(vs ...string) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldVanityURL), v...))
})
}
@@ -601,12 +553,6 @@ func VanityURLRealIn(vs ...string) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldVanityURLReal), v...))
})
}
@@ -618,12 +564,6 @@ func VanityURLRealNotIn(vs ...string) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldVanityURLReal), v...))
})
}
@@ -726,12 +666,6 @@ func VacDateIn(vs ...time.Time) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldVacDate), v...))
})
}
@@ -743,12 +677,6 @@ func VacDateNotIn(vs ...time.Time) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldVacDate), v...))
})
}
@@ -816,12 +744,6 @@ func VacCountIn(vs ...int) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldVacCount), v...))
})
}
@@ -833,12 +755,6 @@ func VacCountNotIn(vs ...int) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldVacCount), v...))
})
}
@@ -906,12 +822,6 @@ func GameBanDateIn(vs ...time.Time) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldGameBanDate), v...))
})
}
@@ -923,12 +833,6 @@ func GameBanDateNotIn(vs ...time.Time) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldGameBanDate), v...))
})
}
@@ -996,12 +900,6 @@ func GameBanCountIn(vs ...int) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldGameBanCount), v...))
})
}
@@ -1013,12 +911,6 @@ func GameBanCountNotIn(vs ...int) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldGameBanCount), v...))
})
}
@@ -1086,12 +978,6 @@ func SteamUpdatedIn(vs ...time.Time) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldSteamUpdated), v...))
})
}
@@ -1103,12 +989,6 @@ func SteamUpdatedNotIn(vs ...time.Time) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldSteamUpdated), v...))
})
}
@@ -1162,12 +1042,6 @@ func SharecodeUpdatedIn(vs ...time.Time) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldSharecodeUpdated), v...))
})
}
@@ -1179,12 +1053,6 @@ func SharecodeUpdatedNotIn(vs ...time.Time) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldSharecodeUpdated), v...))
})
}
@@ -1252,12 +1120,6 @@ func AuthCodeIn(vs ...string) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldAuthCode), v...))
})
}
@@ -1269,12 +1131,6 @@ func AuthCodeNotIn(vs ...string) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldAuthCode), v...))
})
}
@@ -1377,12 +1233,6 @@ func ProfileCreatedIn(vs ...time.Time) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldProfileCreated), v...))
})
}
@@ -1394,12 +1244,6 @@ func ProfileCreatedNotIn(vs ...time.Time) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldProfileCreated), v...))
})
}
@@ -1467,12 +1311,6 @@ func OldestSharecodeSeenIn(vs ...string) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldOldestSharecodeSeen), v...))
})
}
@@ -1484,12 +1322,6 @@ func OldestSharecodeSeenNotIn(vs ...string) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldOldestSharecodeSeen), v...))
})
}
@@ -1592,12 +1424,6 @@ func WinsIn(vs ...int) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldWins), v...))
})
}
@@ -1609,12 +1435,6 @@ func WinsNotIn(vs ...int) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldWins), v...))
})
}
@@ -1682,12 +1502,6 @@ func LoosesIn(vs ...int) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldLooses), v...))
})
}
@@ -1699,12 +1513,6 @@ func LoosesNotIn(vs ...int) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldLooses), v...))
})
}
@@ -1772,12 +1580,6 @@ func TiesIn(vs ...int) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldTies), v...))
})
}
@@ -1789,12 +1591,6 @@ func TiesNotIn(vs ...int) predicate.Player {
v[i] = vs[i]
}
return predicate.Player(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldTies), v...))
})
}

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -322,9 +322,15 @@ func (pc *PlayerCreate) Save(ctx context.Context) (*Player, error) {
}
mut = pc.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, pc.mutation); err != nil {
v, err := mut.Mutate(ctx, pc.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*Player)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from PlayerMutation", v)
}
node = nv
}
return node, err
}
@@ -371,7 +377,7 @@ func (pc *PlayerCreate) sqlSave(ctx context.Context) (*Player, error) {
_node, _spec := pc.createSpec()
if err := sqlgraph.CreateNode(ctx, pc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
@@ -599,7 +605,7 @@ func (pcb *PlayerCreateBulk) Save(ctx context.Context) ([]*Player, error) {
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, pcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
@@ -607,11 +613,11 @@ func (pcb *PlayerCreateBulk) Save(ctx context.Context) ([]*Player, error) {
return nil, err
}
mutation.id = &nodes[i].ID
mutation.done = true
if specs[i].ID.Value != nil && nodes[i].ID == 0 {
id := specs[i].ID.Value.(int64)
nodes[i].ID = uint64(id)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -84,7 +84,11 @@ func (pd *PlayerDelete) sqlExec(ctx context.Context) (int, error) {
}
}
}
return sqlgraph.DeleteNodes(ctx, pd.driver, _spec)
affected, err := sqlgraph.DeleteNodes(ctx, pd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return affected, err
}
// PlayerDeleteOne is the builder for deleting a single Player entity.

View File

@@ -1,11 +1,10 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
import (
"context"
"database/sql/driver"
"errors"
"fmt"
"math"
@@ -21,16 +20,15 @@ import (
// PlayerQuery is the builder for querying Player entities.
type PlayerQuery struct {
config
limit *int
offset *int
unique *bool
order []OrderFunc
fields []string
predicates []predicate.Player
// eager-loading edges.
limit *int
offset *int
unique *bool
order []OrderFunc
fields []string
predicates []predicate.Player
withStats *MatchPlayerQuery
withMatches *MatchQuery
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)
@@ -337,17 +335,18 @@ func (pq *PlayerQuery) WithMatches(opts ...func(*MatchQuery)) *PlayerQuery {
// GroupBy(player.FieldName).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
//
func (pq *PlayerQuery) GroupBy(field string, fields ...string) *PlayerGroupBy {
group := &PlayerGroupBy{config: pq.config}
group.fields = append([]string{field}, fields...)
group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
grbuild := &PlayerGroupBy{config: pq.config}
grbuild.fields = append([]string{field}, fields...)
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) {
if err := pq.prepareQuery(ctx); err != nil {
return nil, err
}
return pq.sqlQuery(ctx), nil
}
return group
grbuild.label = player.Label
grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan
return grbuild
}
// Select allows the selection one or more fields/columns for the given query,
@@ -362,10 +361,12 @@ func (pq *PlayerQuery) GroupBy(field string, fields ...string) *PlayerGroupBy {
// client.Player.Query().
// Select(player.FieldName).
// Scan(ctx, &v)
//
func (pq *PlayerQuery) Select(fields ...string) *PlayerSelect {
pq.fields = append(pq.fields, fields...)
return &PlayerSelect{PlayerQuery: pq}
selbuild := &PlayerSelect{PlayerQuery: pq}
selbuild.label = player.Label
selbuild.flds, selbuild.scan = &pq.fields, selbuild.Scan
return selbuild
}
func (pq *PlayerQuery) prepareQuery(ctx context.Context) error {
@@ -384,7 +385,7 @@ func (pq *PlayerQuery) prepareQuery(ctx context.Context) error {
return nil
}
func (pq *PlayerQuery) sqlAll(ctx context.Context) ([]*Player, error) {
func (pq *PlayerQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Player, error) {
var (
nodes = []*Player{}
_spec = pq.querySpec()
@@ -394,119 +395,127 @@ func (pq *PlayerQuery) sqlAll(ctx context.Context) ([]*Player, error) {
}
)
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
node := &Player{config: pq.config}
nodes = append(nodes, node)
return node.scanValues(columns)
return (*Player).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 := &Player{config: pq.config}
nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
}
if len(pq.modifiers) > 0 {
_spec.Modifiers = pq.modifiers
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, pq.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
if query := pq.withStats; query != nil {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[uint64]*Player)
for i := range nodes {
fks = append(fks, nodes[i].ID)
nodeids[nodes[i].ID] = nodes[i]
nodes[i].Edges.Stats = []*MatchPlayer{}
}
query.Where(predicate.MatchPlayer(func(s *sql.Selector) {
s.Where(sql.InValues(player.StatsColumn, fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
if err := pq.loadStats(ctx, query, nodes,
func(n *Player) { n.Edges.Stats = []*MatchPlayer{} },
func(n *Player, e *MatchPlayer) { n.Edges.Stats = append(n.Edges.Stats, e) }); err != nil {
return nil, err
}
for _, n := range neighbors {
fk := n.PlayerStats
node, ok := nodeids[fk]
if !ok {
return nil, fmt.Errorf(`unexpected foreign-key "player_stats" returned %v for node %v`, fk, n.ID)
}
node.Edges.Stats = append(node.Edges.Stats, n)
}
}
if query := pq.withMatches; query != nil {
fks := make([]driver.Value, 0, len(nodes))
ids := make(map[uint64]*Player, len(nodes))
for _, node := range nodes {
ids[node.ID] = node
fks = append(fks, node.ID)
node.Edges.Matches = []*Match{}
}
var (
edgeids []uint64
edges = make(map[uint64][]*Player)
)
_spec := &sqlgraph.EdgeQuerySpec{
Edge: &sqlgraph.EdgeSpec{
Inverse: false,
Table: player.MatchesTable,
Columns: player.MatchesPrimaryKey,
},
Predicate: func(s *sql.Selector) {
s.Where(sql.InValues(player.MatchesPrimaryKey[0], fks...))
},
ScanValues: func() [2]interface{} {
return [2]interface{}{new(sql.NullInt64), new(sql.NullInt64)}
},
Assign: func(out, in interface{}) error {
eout, ok := out.(*sql.NullInt64)
if !ok || eout == nil {
return fmt.Errorf("unexpected id value for edge-out")
}
ein, ok := in.(*sql.NullInt64)
if !ok || ein == nil {
return fmt.Errorf("unexpected id value for edge-in")
}
outValue := uint64(eout.Int64)
inValue := uint64(ein.Int64)
node, ok := ids[outValue]
if !ok {
return fmt.Errorf("unexpected node id in edges: %v", outValue)
}
if _, ok := edges[inValue]; !ok {
edgeids = append(edgeids, inValue)
}
edges[inValue] = append(edges[inValue], node)
return nil
},
}
if err := sqlgraph.QueryEdges(ctx, pq.driver, _spec); err != nil {
return nil, fmt.Errorf(`query edges "matches": %w`, err)
}
query.Where(match.IDIn(edgeids...))
neighbors, err := query.All(ctx)
if err != nil {
if err := pq.loadMatches(ctx, query, nodes,
func(n *Player) { n.Edges.Matches = []*Match{} },
func(n *Player, e *Match) { n.Edges.Matches = append(n.Edges.Matches, e) }); err != nil {
return nil, err
}
for _, n := range neighbors {
nodes, ok := edges[n.ID]
if !ok {
return nil, fmt.Errorf(`unexpected "matches" node returned %v`, n.ID)
}
for i := range nodes {
nodes[i].Edges.Matches = append(nodes[i].Edges.Matches, n)
}
}
return nodes, nil
}
func (pq *PlayerQuery) loadStats(ctx context.Context, query *MatchPlayerQuery, nodes []*Player, init func(*Player), assign func(*Player, *MatchPlayer)) error {
fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[uint64]*Player)
for i := range nodes {
fks = append(fks, nodes[i].ID)
nodeids[nodes[i].ID] = nodes[i]
if init != nil {
init(nodes[i])
}
}
return nodes, nil
query.Where(predicate.MatchPlayer(func(s *sql.Selector) {
s.Where(sql.InValues(player.StatsColumn, fks...))
}))
neighbors, err := query.All(ctx)
if err != nil {
return err
}
for _, n := range neighbors {
fk := n.PlayerStats
node, ok := nodeids[fk]
if !ok {
return fmt.Errorf(`unexpected foreign-key "player_stats" returned %v for node %v`, fk, n.ID)
}
assign(node, n)
}
return nil
}
func (pq *PlayerQuery) loadMatches(ctx context.Context, query *MatchQuery, nodes []*Player, init func(*Player), assign func(*Player, *Match)) error {
edgeIDs := make([]driver.Value, len(nodes))
byID := make(map[uint64]*Player)
nids := make(map[uint64]map[*Player]struct{})
for i, node := range nodes {
edgeIDs[i] = node.ID
byID[node.ID] = node
if init != nil {
init(node)
}
}
query.Where(func(s *sql.Selector) {
joinT := sql.Table(player.MatchesTable)
s.Join(joinT).On(s.C(match.FieldID), joinT.C(player.MatchesPrimaryKey[1]))
s.Where(sql.InValues(joinT.C(player.MatchesPrimaryKey[0]), edgeIDs...))
columns := s.SelectedColumns()
s.Select(joinT.C(player.MatchesPrimaryKey[0]))
s.AppendSelect(columns...)
s.SetDistinct(false)
})
if err := query.prepareQuery(ctx); err != nil {
return err
}
neighbors, err := query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) {
assign := spec.Assign
values := spec.ScanValues
spec.ScanValues = func(columns []string) ([]interface{}, error) {
values, err := values(columns[1:])
if err != nil {
return nil, err
}
return append([]interface{}{new(sql.NullInt64)}, values...), nil
}
spec.Assign = func(columns []string, values []interface{}) 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{}{}}
return assign(columns[1:], values[1:])
}
nids[inValue][byID[outValue]] = struct{}{}
return nil
}
})
if err != nil {
return err
}
for _, n := range neighbors {
nodes, ok := nids[n.ID]
if !ok {
return fmt.Errorf(`unexpected "matches" node returned %v`, n.ID)
}
for kn := range nodes {
assign(kn, n)
}
}
return nil
}
func (pq *PlayerQuery) sqlCount(ctx context.Context) (int, error) {
@@ -621,6 +630,7 @@ func (pq *PlayerQuery) Modify(modifiers ...func(s *sql.Selector)) *PlayerSelect
// PlayerGroupBy is the group-by builder for Player entities.
type PlayerGroupBy struct {
config
selector
fields []string
fns []AggregateFunc
// intermediate query (i.e. traversal path).
@@ -644,209 +654,6 @@ func (pgb *PlayerGroupBy) Scan(ctx context.Context, v interface{}) error {
return pgb.sqlScan(ctx, v)
}
// ScanX is like Scan, but panics if an error occurs.
func (pgb *PlayerGroupBy) ScanX(ctx context.Context, v interface{}) {
if err := pgb.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 (pgb *PlayerGroupBy) Strings(ctx context.Context) ([]string, error) {
if len(pgb.fields) > 1 {
return nil, errors.New("ent: PlayerGroupBy.Strings is not achievable when grouping more than 1 field")
}
var v []string
if err := pgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (pgb *PlayerGroupBy) StringsX(ctx context.Context) []string {
v, err := pgb.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 (pgb *PlayerGroupBy) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = pgb.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{player.Label}
default:
err = fmt.Errorf("ent: PlayerGroupBy.Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (pgb *PlayerGroupBy) StringX(ctx context.Context) string {
v, err := pgb.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 (pgb *PlayerGroupBy) Ints(ctx context.Context) ([]int, error) {
if len(pgb.fields) > 1 {
return nil, errors.New("ent: PlayerGroupBy.Ints is not achievable when grouping more than 1 field")
}
var v []int
if err := pgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (pgb *PlayerGroupBy) IntsX(ctx context.Context) []int {
v, err := pgb.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 (pgb *PlayerGroupBy) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = pgb.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{player.Label}
default:
err = fmt.Errorf("ent: PlayerGroupBy.Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (pgb *PlayerGroupBy) IntX(ctx context.Context) int {
v, err := pgb.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 (pgb *PlayerGroupBy) Float64s(ctx context.Context) ([]float64, error) {
if len(pgb.fields) > 1 {
return nil, errors.New("ent: PlayerGroupBy.Float64s is not achievable when grouping more than 1 field")
}
var v []float64
if err := pgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (pgb *PlayerGroupBy) Float64sX(ctx context.Context) []float64 {
v, err := pgb.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 (pgb *PlayerGroupBy) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = pgb.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{player.Label}
default:
err = fmt.Errorf("ent: PlayerGroupBy.Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (pgb *PlayerGroupBy) Float64X(ctx context.Context) float64 {
v, err := pgb.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 (pgb *PlayerGroupBy) Bools(ctx context.Context) ([]bool, error) {
if len(pgb.fields) > 1 {
return nil, errors.New("ent: PlayerGroupBy.Bools is not achievable when grouping more than 1 field")
}
var v []bool
if err := pgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (pgb *PlayerGroupBy) BoolsX(ctx context.Context) []bool {
v, err := pgb.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 (pgb *PlayerGroupBy) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = pgb.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{player.Label}
default:
err = fmt.Errorf("ent: PlayerGroupBy.Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (pgb *PlayerGroupBy) BoolX(ctx context.Context) bool {
v, err := pgb.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
func (pgb *PlayerGroupBy) sqlScan(ctx context.Context, v interface{}) error {
for _, f := range pgb.fields {
if !player.ValidColumn(f) {
@@ -888,6 +695,7 @@ func (pgb *PlayerGroupBy) sqlQuery() *sql.Selector {
// PlayerSelect is the builder for selecting fields of Player entities.
type PlayerSelect struct {
*PlayerQuery
selector
// intermediate query (i.e. traversal path).
sql *sql.Selector
}
@@ -901,201 +709,6 @@ func (ps *PlayerSelect) Scan(ctx context.Context, v interface{}) error {
return ps.sqlScan(ctx, v)
}
// ScanX is like Scan, but panics if an error occurs.
func (ps *PlayerSelect) ScanX(ctx context.Context, v interface{}) {
if err := ps.Scan(ctx, v); err != nil {
panic(err)
}
}
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
func (ps *PlayerSelect) Strings(ctx context.Context) ([]string, error) {
if len(ps.fields) > 1 {
return nil, errors.New("ent: PlayerSelect.Strings is not achievable when selecting more than 1 field")
}
var v []string
if err := ps.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (ps *PlayerSelect) StringsX(ctx context.Context) []string {
v, err := ps.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 (ps *PlayerSelect) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = ps.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{player.Label}
default:
err = fmt.Errorf("ent: PlayerSelect.Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (ps *PlayerSelect) StringX(ctx context.Context) string {
v, err := ps.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 (ps *PlayerSelect) Ints(ctx context.Context) ([]int, error) {
if len(ps.fields) > 1 {
return nil, errors.New("ent: PlayerSelect.Ints is not achievable when selecting more than 1 field")
}
var v []int
if err := ps.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (ps *PlayerSelect) IntsX(ctx context.Context) []int {
v, err := ps.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 (ps *PlayerSelect) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = ps.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{player.Label}
default:
err = fmt.Errorf("ent: PlayerSelect.Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (ps *PlayerSelect) IntX(ctx context.Context) int {
v, err := ps.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 (ps *PlayerSelect) Float64s(ctx context.Context) ([]float64, error) {
if len(ps.fields) > 1 {
return nil, errors.New("ent: PlayerSelect.Float64s is not achievable when selecting more than 1 field")
}
var v []float64
if err := ps.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (ps *PlayerSelect) Float64sX(ctx context.Context) []float64 {
v, err := ps.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 (ps *PlayerSelect) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = ps.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{player.Label}
default:
err = fmt.Errorf("ent: PlayerSelect.Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (ps *PlayerSelect) Float64X(ctx context.Context) float64 {
v, err := ps.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 (ps *PlayerSelect) Bools(ctx context.Context) ([]bool, error) {
if len(ps.fields) > 1 {
return nil, errors.New("ent: PlayerSelect.Bools is not achievable when selecting more than 1 field")
}
var v []bool
if err := ps.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (ps *PlayerSelect) BoolsX(ctx context.Context) []bool {
v, err := ps.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 (ps *PlayerSelect) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = ps.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{player.Label}
default:
err = fmt.Errorf("ent: PlayerSelect.Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (ps *PlayerSelect) BoolX(ctx context.Context) bool {
v, err := ps.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
func (ps *PlayerSelect) sqlScan(ctx context.Context, v interface{}) error {
rows := &sql.Rows{}
query, args := ps.sql.Query()

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -20,8 +20,9 @@ import (
// PlayerUpdate is the builder for updating Player entities.
type PlayerUpdate struct {
config
hooks []Hook
mutation *PlayerMutation
hooks []Hook
mutation *PlayerMutation
modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the PlayerUpdate builder.
@@ -510,6 +511,12 @@ func (pu *PlayerUpdate) ExecX(ctx context.Context) {
}
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (pu *PlayerUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PlayerUpdate {
pu.modifiers = append(pu.modifiers, modifiers...)
return pu
}
func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
@@ -873,11 +880,12 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.Modifiers = pu.modifiers
if n, err = sqlgraph.UpdateNodes(ctx, pu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{player.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
@@ -887,9 +895,10 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) {
// PlayerUpdateOne is the builder for updating a single Player entity.
type PlayerUpdateOne struct {
config
fields []string
hooks []Hook
mutation *PlayerMutation
fields []string
hooks []Hook
mutation *PlayerMutation
modifiers []func(*sql.UpdateBuilder)
}
// SetName sets the "name" field.
@@ -1350,9 +1359,15 @@ func (puo *PlayerUpdateOne) Save(ctx context.Context) (*Player, error) {
}
mut = puo.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, puo.mutation); err != nil {
v, err := mut.Mutate(ctx, puo.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*Player)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from PlayerMutation", v)
}
node = nv
}
return node, err
}
@@ -1379,6 +1394,12 @@ func (puo *PlayerUpdateOne) ExecX(ctx context.Context) {
}
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (puo *PlayerUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PlayerUpdateOne {
puo.modifiers = append(puo.modifiers, modifiers...)
return puo
}
func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
@@ -1759,6 +1780,7 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.Modifiers = puo.modifiers
_node = &Player{config: puo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
@@ -1766,7 +1788,7 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{player.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package predicate

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -44,8 +44,7 @@ type RoundStatsEdges struct {
func (e RoundStatsEdges) MatchPlayerOrErr() (*MatchPlayer, error) {
if e.loadedTypes[0] {
if e.MatchPlayer == nil {
// The edge match_player was loaded in eager-loading,
// but was not found.
// Edge was loaded but was not found.
return nil, &NotFoundError{label: matchplayer.Label}
}
return e.MatchPlayer, nil
@@ -134,11 +133,11 @@ func (rs *RoundStats) Update() *RoundStatsUpdateOne {
// Unwrap unwraps the RoundStats entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (rs *RoundStats) Unwrap() *RoundStats {
tx, ok := rs.config.driver.(*txDriver)
_tx, ok := rs.config.driver.(*txDriver)
if !ok {
panic("ent: RoundStats is not a transactional entity")
}
rs.config.driver = tx.drv
rs.config.driver = _tx.drv
return rs
}
@@ -146,14 +145,17 @@ func (rs *RoundStats) Unwrap() *RoundStats {
func (rs *RoundStats) String() string {
var builder strings.Builder
builder.WriteString("RoundStats(")
builder.WriteString(fmt.Sprintf("id=%v", rs.ID))
builder.WriteString(", round=")
builder.WriteString(fmt.Sprintf("id=%v, ", rs.ID))
builder.WriteString("round=")
builder.WriteString(fmt.Sprintf("%v", rs.Round))
builder.WriteString(", bank=")
builder.WriteString(", ")
builder.WriteString("bank=")
builder.WriteString(fmt.Sprintf("%v", rs.Bank))
builder.WriteString(", equipment=")
builder.WriteString(", ")
builder.WriteString("equipment=")
builder.WriteString(fmt.Sprintf("%v", rs.Equipment))
builder.WriteString(", spent=")
builder.WriteString(", ")
builder.WriteString("spent=")
builder.WriteString(fmt.Sprintf("%v", rs.Spent))
builder.WriteByte(')')
return builder.String()

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package roundstats

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package roundstats
@@ -32,12 +32,6 @@ func IDNEQ(id int) predicate.RoundStats {
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(ids) == 0 {
s.Where(sql.False())
return
}
v := make([]interface{}, len(ids))
for i := range v {
v[i] = ids[i]
@@ -49,12 +43,6 @@ func IDIn(ids ...int) predicate.RoundStats {
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(ids) == 0 {
s.Where(sql.False())
return
}
v := make([]interface{}, len(ids))
for i := range v {
v[i] = ids[i]
@@ -140,12 +128,6 @@ func RoundIn(vs ...uint) predicate.RoundStats {
v[i] = vs[i]
}
return predicate.RoundStats(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldRound), v...))
})
}
@@ -157,12 +139,6 @@ func RoundNotIn(vs ...uint) predicate.RoundStats {
v[i] = vs[i]
}
return predicate.RoundStats(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldRound), v...))
})
}
@@ -216,12 +192,6 @@ func BankIn(vs ...uint) predicate.RoundStats {
v[i] = vs[i]
}
return predicate.RoundStats(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldBank), v...))
})
}
@@ -233,12 +203,6 @@ func BankNotIn(vs ...uint) predicate.RoundStats {
v[i] = vs[i]
}
return predicate.RoundStats(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldBank), v...))
})
}
@@ -292,12 +256,6 @@ func EquipmentIn(vs ...uint) predicate.RoundStats {
v[i] = vs[i]
}
return predicate.RoundStats(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldEquipment), v...))
})
}
@@ -309,12 +267,6 @@ func EquipmentNotIn(vs ...uint) predicate.RoundStats {
v[i] = vs[i]
}
return predicate.RoundStats(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldEquipment), v...))
})
}
@@ -368,12 +320,6 @@ func SpentIn(vs ...uint) predicate.RoundStats {
v[i] = vs[i]
}
return predicate.RoundStats(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldSpent), v...))
})
}
@@ -385,12 +331,6 @@ func SpentNotIn(vs ...uint) predicate.RoundStats {
v[i] = vs[i]
}
return predicate.RoundStats(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldSpent), v...))
})
}

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -102,9 +102,15 @@ func (rsc *RoundStatsCreate) Save(ctx context.Context) (*RoundStats, error) {
}
mut = rsc.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, rsc.mutation); err != nil {
v, err := mut.Mutate(ctx, rsc.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*RoundStats)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from RoundStatsMutation", v)
}
node = nv
}
return node, err
}
@@ -152,7 +158,7 @@ func (rsc *RoundStatsCreate) sqlSave(ctx context.Context) (*RoundStats, error) {
_node, _spec := rsc.createSpec()
if err := sqlgraph.CreateNode(ctx, rsc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
@@ -259,7 +265,7 @@ func (rscb *RoundStatsCreateBulk) Save(ctx context.Context) ([]*RoundStats, erro
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, rscb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
@@ -267,11 +273,11 @@ func (rscb *RoundStatsCreateBulk) Save(ctx context.Context) ([]*RoundStats, erro
return nil, err
}
mutation.id = &nodes[i].ID
mutation.done = true
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -84,7 +84,11 @@ func (rsd *RoundStatsDelete) sqlExec(ctx context.Context) (int, error) {
}
}
}
return sqlgraph.DeleteNodes(ctx, rsd.driver, _spec)
affected, err := sqlgraph.DeleteNodes(ctx, rsd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return affected, err
}
// RoundStatsDeleteOne is the builder for deleting a single RoundStats entity.

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 (
// RoundStatsQuery is the builder for querying RoundStats entities.
type RoundStatsQuery struct {
config
limit *int
offset *int
unique *bool
order []OrderFunc
fields []string
predicates []predicate.RoundStats
// eager-loading edges.
limit *int
offset *int
unique *bool
order []OrderFunc
fields []string
predicates []predicate.RoundStats
withMatchPlayer *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 (rsq *RoundStatsQuery) WithMatchPlayer(opts ...func(*MatchPlayerQuery)) *Ro
// GroupBy(roundstats.FieldRound).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
//
func (rsq *RoundStatsQuery) GroupBy(field string, fields ...string) *RoundStatsGroupBy {
group := &RoundStatsGroupBy{config: rsq.config}
group.fields = append([]string{field}, fields...)
group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
grbuild := &RoundStatsGroupBy{config: rsq.config}
grbuild.fields = append([]string{field}, fields...)
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) {
if err := rsq.prepareQuery(ctx); err != nil {
return nil, err
}
return rsq.sqlQuery(ctx), nil
}
return group
grbuild.label = roundstats.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 (rsq *RoundStatsQuery) GroupBy(field string, fields ...string) *RoundStatsG
// client.RoundStats.Query().
// Select(roundstats.FieldRound).
// Scan(ctx, &v)
//
func (rsq *RoundStatsQuery) Select(fields ...string) *RoundStatsSelect {
rsq.fields = append(rsq.fields, fields...)
return &RoundStatsSelect{RoundStatsQuery: rsq}
selbuild := &RoundStatsSelect{RoundStatsQuery: rsq}
selbuild.label = roundstats.Label
selbuild.flds, selbuild.scan = &rsq.fields, selbuild.Scan
return selbuild
}
func (rsq *RoundStatsQuery) prepareQuery(ctx context.Context) error {
@@ -348,7 +349,7 @@ func (rsq *RoundStatsQuery) prepareQuery(ctx context.Context) error {
return nil
}
func (rsq *RoundStatsQuery) sqlAll(ctx context.Context) ([]*RoundStats, error) {
func (rsq *RoundStatsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*RoundStats, error) {
var (
nodes = []*RoundStats{}
withFKs = rsq.withFKs
@@ -364,58 +365,63 @@ func (rsq *RoundStatsQuery) sqlAll(ctx context.Context) ([]*RoundStats, error) {
_spec.Node.Columns = append(_spec.Node.Columns, roundstats.ForeignKeys...)
}
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
node := &RoundStats{config: rsq.config}
nodes = append(nodes, node)
return node.scanValues(columns)
return (*RoundStats).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 := &RoundStats{config: rsq.config}
nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
}
if len(rsq.modifiers) > 0 {
_spec.Modifiers = rsq.modifiers
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, rsq.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
if query := rsq.withMatchPlayer; query != nil {
ids := make([]int, 0, len(nodes))
nodeids := make(map[int][]*RoundStats)
for i := range nodes {
if nodes[i].match_player_round_stats == nil {
continue
}
fk := *nodes[i].match_player_round_stats
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 := rsq.loadMatchPlayer(ctx, query, nodes, nil,
func(n *RoundStats, e *MatchPlayer) { n.Edges.MatchPlayer = 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_round_stats" returned %v`, n.ID)
}
for i := range nodes {
nodes[i].Edges.MatchPlayer = n
}
}
return nodes, nil
}
func (rsq *RoundStatsQuery) loadMatchPlayer(ctx context.Context, query *MatchPlayerQuery, nodes []*RoundStats, init func(*RoundStats), assign func(*RoundStats, *MatchPlayer)) error {
ids := make([]int, 0, len(nodes))
nodeids := make(map[int][]*RoundStats)
for i := range nodes {
if nodes[i].match_player_round_stats == nil {
continue
}
fk := *nodes[i].match_player_round_stats
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_round_stats" returned %v`, n.ID)
}
for i := range nodes {
assign(nodes[i], n)
}
}
return nodes, nil
return nil
}
func (rsq *RoundStatsQuery) sqlCount(ctx context.Context) (int, error) {
@@ -530,6 +536,7 @@ func (rsq *RoundStatsQuery) Modify(modifiers ...func(s *sql.Selector)) *RoundSta
// RoundStatsGroupBy is the group-by builder for RoundStats entities.
type RoundStatsGroupBy struct {
config
selector
fields []string
fns []AggregateFunc
// intermediate query (i.e. traversal path).
@@ -553,209 +560,6 @@ func (rsgb *RoundStatsGroupBy) Scan(ctx context.Context, v interface{}) error {
return rsgb.sqlScan(ctx, v)
}
// ScanX is like Scan, but panics if an error occurs.
func (rsgb *RoundStatsGroupBy) ScanX(ctx context.Context, v interface{}) {
if err := rsgb.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 (rsgb *RoundStatsGroupBy) Strings(ctx context.Context) ([]string, error) {
if len(rsgb.fields) > 1 {
return nil, errors.New("ent: RoundStatsGroupBy.Strings is not achievable when grouping more than 1 field")
}
var v []string
if err := rsgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (rsgb *RoundStatsGroupBy) StringsX(ctx context.Context) []string {
v, err := rsgb.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 (rsgb *RoundStatsGroupBy) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = rsgb.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{roundstats.Label}
default:
err = fmt.Errorf("ent: RoundStatsGroupBy.Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (rsgb *RoundStatsGroupBy) StringX(ctx context.Context) string {
v, err := rsgb.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 (rsgb *RoundStatsGroupBy) Ints(ctx context.Context) ([]int, error) {
if len(rsgb.fields) > 1 {
return nil, errors.New("ent: RoundStatsGroupBy.Ints is not achievable when grouping more than 1 field")
}
var v []int
if err := rsgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (rsgb *RoundStatsGroupBy) IntsX(ctx context.Context) []int {
v, err := rsgb.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 (rsgb *RoundStatsGroupBy) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = rsgb.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{roundstats.Label}
default:
err = fmt.Errorf("ent: RoundStatsGroupBy.Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (rsgb *RoundStatsGroupBy) IntX(ctx context.Context) int {
v, err := rsgb.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 (rsgb *RoundStatsGroupBy) Float64s(ctx context.Context) ([]float64, error) {
if len(rsgb.fields) > 1 {
return nil, errors.New("ent: RoundStatsGroupBy.Float64s is not achievable when grouping more than 1 field")
}
var v []float64
if err := rsgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (rsgb *RoundStatsGroupBy) Float64sX(ctx context.Context) []float64 {
v, err := rsgb.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 (rsgb *RoundStatsGroupBy) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = rsgb.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{roundstats.Label}
default:
err = fmt.Errorf("ent: RoundStatsGroupBy.Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (rsgb *RoundStatsGroupBy) Float64X(ctx context.Context) float64 {
v, err := rsgb.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 (rsgb *RoundStatsGroupBy) Bools(ctx context.Context) ([]bool, error) {
if len(rsgb.fields) > 1 {
return nil, errors.New("ent: RoundStatsGroupBy.Bools is not achievable when grouping more than 1 field")
}
var v []bool
if err := rsgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (rsgb *RoundStatsGroupBy) BoolsX(ctx context.Context) []bool {
v, err := rsgb.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 (rsgb *RoundStatsGroupBy) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = rsgb.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{roundstats.Label}
default:
err = fmt.Errorf("ent: RoundStatsGroupBy.Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (rsgb *RoundStatsGroupBy) BoolX(ctx context.Context) bool {
v, err := rsgb.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
func (rsgb *RoundStatsGroupBy) sqlScan(ctx context.Context, v interface{}) error {
for _, f := range rsgb.fields {
if !roundstats.ValidColumn(f) {
@@ -797,6 +601,7 @@ func (rsgb *RoundStatsGroupBy) sqlQuery() *sql.Selector {
// RoundStatsSelect is the builder for selecting fields of RoundStats entities.
type RoundStatsSelect struct {
*RoundStatsQuery
selector
// intermediate query (i.e. traversal path).
sql *sql.Selector
}
@@ -810,201 +615,6 @@ func (rss *RoundStatsSelect) Scan(ctx context.Context, v interface{}) error {
return rss.sqlScan(ctx, v)
}
// ScanX is like Scan, but panics if an error occurs.
func (rss *RoundStatsSelect) ScanX(ctx context.Context, v interface{}) {
if err := rss.Scan(ctx, v); err != nil {
panic(err)
}
}
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
func (rss *RoundStatsSelect) Strings(ctx context.Context) ([]string, error) {
if len(rss.fields) > 1 {
return nil, errors.New("ent: RoundStatsSelect.Strings is not achievable when selecting more than 1 field")
}
var v []string
if err := rss.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (rss *RoundStatsSelect) StringsX(ctx context.Context) []string {
v, err := rss.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 (rss *RoundStatsSelect) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = rss.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{roundstats.Label}
default:
err = fmt.Errorf("ent: RoundStatsSelect.Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (rss *RoundStatsSelect) StringX(ctx context.Context) string {
v, err := rss.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 (rss *RoundStatsSelect) Ints(ctx context.Context) ([]int, error) {
if len(rss.fields) > 1 {
return nil, errors.New("ent: RoundStatsSelect.Ints is not achievable when selecting more than 1 field")
}
var v []int
if err := rss.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (rss *RoundStatsSelect) IntsX(ctx context.Context) []int {
v, err := rss.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 (rss *RoundStatsSelect) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = rss.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{roundstats.Label}
default:
err = fmt.Errorf("ent: RoundStatsSelect.Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (rss *RoundStatsSelect) IntX(ctx context.Context) int {
v, err := rss.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 (rss *RoundStatsSelect) Float64s(ctx context.Context) ([]float64, error) {
if len(rss.fields) > 1 {
return nil, errors.New("ent: RoundStatsSelect.Float64s is not achievable when selecting more than 1 field")
}
var v []float64
if err := rss.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (rss *RoundStatsSelect) Float64sX(ctx context.Context) []float64 {
v, err := rss.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 (rss *RoundStatsSelect) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = rss.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{roundstats.Label}
default:
err = fmt.Errorf("ent: RoundStatsSelect.Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (rss *RoundStatsSelect) Float64X(ctx context.Context) float64 {
v, err := rss.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 (rss *RoundStatsSelect) Bools(ctx context.Context) ([]bool, error) {
if len(rss.fields) > 1 {
return nil, errors.New("ent: RoundStatsSelect.Bools is not achievable when selecting more than 1 field")
}
var v []bool
if err := rss.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (rss *RoundStatsSelect) BoolsX(ctx context.Context) []bool {
v, err := rss.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 (rss *RoundStatsSelect) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = rss.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{roundstats.Label}
default:
err = fmt.Errorf("ent: RoundStatsSelect.Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (rss *RoundStatsSelect) BoolX(ctx context.Context) bool {
v, err := rss.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
func (rss *RoundStatsSelect) sqlScan(ctx context.Context, v interface{}) error {
rows := &sql.Rows{}
query, args := rss.sql.Query()

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -18,8 +18,9 @@ import (
// RoundStatsUpdate is the builder for updating RoundStats entities.
type RoundStatsUpdate struct {
config
hooks []Hook
mutation *RoundStatsMutation
hooks []Hook
mutation *RoundStatsMutation
modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the RoundStatsUpdate builder.
@@ -164,6 +165,12 @@ func (rsu *RoundStatsUpdate) ExecX(ctx context.Context) {
}
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (rsu *RoundStatsUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RoundStatsUpdate {
rsu.modifiers = append(rsu.modifiers, modifiers...)
return rsu
}
func (rsu *RoundStatsUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
@@ -273,11 +280,12 @@ func (rsu *RoundStatsUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.Modifiers = rsu.modifiers
if n, err = sqlgraph.UpdateNodes(ctx, rsu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{roundstats.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
@@ -287,9 +295,10 @@ func (rsu *RoundStatsUpdate) sqlSave(ctx context.Context) (n int, err error) {
// RoundStatsUpdateOne is the builder for updating a single RoundStats entity.
type RoundStatsUpdateOne struct {
config
fields []string
hooks []Hook
mutation *RoundStatsMutation
fields []string
hooks []Hook
mutation *RoundStatsMutation
modifiers []func(*sql.UpdateBuilder)
}
// SetRound sets the "round" field.
@@ -406,9 +415,15 @@ func (rsuo *RoundStatsUpdateOne) Save(ctx context.Context) (*RoundStats, error)
}
mut = rsuo.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, rsuo.mutation); err != nil {
v, err := mut.Mutate(ctx, rsuo.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*RoundStats)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from RoundStatsMutation", v)
}
node = nv
}
return node, err
}
@@ -435,6 +450,12 @@ func (rsuo *RoundStatsUpdateOne) ExecX(ctx context.Context) {
}
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (rsuo *RoundStatsUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RoundStatsUpdateOne {
rsuo.modifiers = append(rsuo.modifiers, modifiers...)
return rsuo
}
func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
@@ -561,6 +582,7 @@ func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.Modifiers = rsuo.modifiers
_node = &RoundStats{config: rsuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
@@ -568,7 +590,7 @@ func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{roundstats.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent

View File

@@ -1,10 +1,10 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package runtime
// The schema-stitching logic is generated in git.harting.dev/csgowtf/csgowtfd/ent/runtime.go
const (
Version = "v0.10.1" // Version of ent codegen.
Sum = "h1:dM5h4Zk6yHGIgw4dCqVzGw3nWgpGYJiV4/kyHEF6PFo=" // Sum of ent codegen.
Version = "v0.11.2" // Version of ent codegen.
Sum = "h1:UM2/BUhF2FfsxPHRxLjQbhqJNaDdVlOwNIAMLs2jyto=" // Sum of ent codegen.
)

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -40,8 +40,7 @@ type SprayEdges struct {
func (e SprayEdges) MatchPlayersOrErr() (*MatchPlayer, error) {
if e.loadedTypes[0] {
if e.MatchPlayers == nil {
// The edge match_players was loaded in eager-loading,
// but was not found.
// Edge was loaded but was not found.
return nil, &NotFoundError{label: matchplayer.Label}
}
return e.MatchPlayers, nil
@@ -120,11 +119,11 @@ func (s *Spray) Update() *SprayUpdateOne {
// Unwrap unwraps the Spray entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (s *Spray) Unwrap() *Spray {
tx, ok := s.config.driver.(*txDriver)
_tx, ok := s.config.driver.(*txDriver)
if !ok {
panic("ent: Spray is not a transactional entity")
}
s.config.driver = tx.drv
s.config.driver = _tx.drv
return s
}
@@ -132,10 +131,11 @@ func (s *Spray) Unwrap() *Spray {
func (s *Spray) String() string {
var builder strings.Builder
builder.WriteString("Spray(")
builder.WriteString(fmt.Sprintf("id=%v", s.ID))
builder.WriteString(", weapon=")
builder.WriteString(fmt.Sprintf("id=%v, ", s.ID))
builder.WriteString("weapon=")
builder.WriteString(fmt.Sprintf("%v", s.Weapon))
builder.WriteString(", spray=")
builder.WriteString(", ")
builder.WriteString("spray=")
builder.WriteString(fmt.Sprintf("%v", s.Spray))
builder.WriteByte(')')
return builder.String()

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package spray

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package spray
@@ -32,12 +32,6 @@ func IDNEQ(id int) predicate.Spray {
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(ids) == 0 {
s.Where(sql.False())
return
}
v := make([]interface{}, len(ids))
for i := range v {
v[i] = ids[i]
@@ -49,12 +43,6 @@ func IDIn(ids ...int) predicate.Spray {
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(ids) == 0 {
s.Where(sql.False())
return
}
v := make([]interface{}, len(ids))
for i := range v {
v[i] = ids[i]
@@ -126,12 +114,6 @@ func WeaponIn(vs ...int) predicate.Spray {
v[i] = vs[i]
}
return predicate.Spray(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldWeapon), v...))
})
}
@@ -143,12 +125,6 @@ func WeaponNotIn(vs ...int) predicate.Spray {
v[i] = vs[i]
}
return predicate.Spray(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldWeapon), v...))
})
}
@@ -202,12 +178,6 @@ func SprayIn(vs ...[]byte) predicate.Spray {
v[i] = vs[i]
}
return predicate.Spray(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldSpray), v...))
})
}
@@ -219,12 +189,6 @@ func SprayNotIn(vs ...[]byte) predicate.Spray {
v[i] = vs[i]
}
return predicate.Spray(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldSpray), v...))
})
}

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -90,9 +90,15 @@ func (sc *SprayCreate) Save(ctx context.Context) (*Spray, error) {
}
mut = sc.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, sc.mutation); err != nil {
v, err := mut.Mutate(ctx, sc.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*Spray)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from SprayMutation", v)
}
node = nv
}
return node, err
}
@@ -134,7 +140,7 @@ func (sc *SprayCreate) sqlSave(ctx context.Context) (*Spray, error) {
_node, _spec := sc.createSpec()
if err := sqlgraph.CreateNode(ctx, sc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
@@ -225,7 +231,7 @@ func (scb *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) {
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, scb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
@@ -233,11 +239,11 @@ func (scb *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) {
return nil, err
}
mutation.id = &nodes[i].ID
mutation.done = true
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -84,7 +84,11 @@ func (sd *SprayDelete) sqlExec(ctx context.Context) (int, error) {
}
}
}
return sqlgraph.DeleteNodes(ctx, sd.driver, _spec)
affected, err := sqlgraph.DeleteNodes(ctx, sd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return affected, err
}
// SprayDeleteOne is the builder for deleting a single Spray entity.

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()

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -18,8 +18,9 @@ import (
// SprayUpdate is the builder for updating Spray entities.
type SprayUpdate struct {
config
hooks []Hook
mutation *SprayMutation
hooks []Hook
mutation *SprayMutation
modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the SprayUpdate builder.
@@ -131,6 +132,12 @@ func (su *SprayUpdate) ExecX(ctx context.Context) {
}
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (su *SprayUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SprayUpdate {
su.modifiers = append(su.modifiers, modifiers...)
return su
}
func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
@@ -205,11 +212,12 @@ func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.Modifiers = su.modifiers
if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{spray.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
@@ -219,9 +227,10 @@ func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) {
// SprayUpdateOne is the builder for updating a single Spray entity.
type SprayUpdateOne struct {
config
fields []string
hooks []Hook
mutation *SprayMutation
fields []string
hooks []Hook
mutation *SprayMutation
modifiers []func(*sql.UpdateBuilder)
}
// SetWeapon sets the "weapon" field.
@@ -305,9 +314,15 @@ func (suo *SprayUpdateOne) Save(ctx context.Context) (*Spray, error) {
}
mut = suo.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, suo.mutation); err != nil {
v, err := mut.Mutate(ctx, suo.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*Spray)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from SprayMutation", v)
}
node = nv
}
return node, err
}
@@ -334,6 +349,12 @@ func (suo *SprayUpdateOne) ExecX(ctx context.Context) {
}
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (suo *SprayUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SprayUpdateOne {
suo.modifiers = append(suo.modifiers, modifiers...)
return suo
}
func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
@@ -425,6 +446,7 @@ func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.Modifiers = suo.modifiers
_node = &Spray{config: suo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
@@ -432,7 +454,7 @@ func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{spray.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -44,8 +44,7 @@ type WeaponEdges struct {
func (e WeaponEdges) StatOrErr() (*MatchPlayer, error) {
if e.loadedTypes[0] {
if e.Stat == nil {
// The edge stat was loaded in eager-loading,
// but was not found.
// Edge was loaded but was not found.
return nil, &NotFoundError{label: matchplayer.Label}
}
return e.Stat, nil
@@ -134,11 +133,11 @@ func (w *Weapon) Update() *WeaponUpdateOne {
// Unwrap unwraps the Weapon entity that was returned from a transaction after it was closed,
// so that all future queries will be executed through the driver which created the transaction.
func (w *Weapon) Unwrap() *Weapon {
tx, ok := w.config.driver.(*txDriver)
_tx, ok := w.config.driver.(*txDriver)
if !ok {
panic("ent: Weapon is not a transactional entity")
}
w.config.driver = tx.drv
w.config.driver = _tx.drv
return w
}
@@ -146,14 +145,17 @@ func (w *Weapon) Unwrap() *Weapon {
func (w *Weapon) String() string {
var builder strings.Builder
builder.WriteString("Weapon(")
builder.WriteString(fmt.Sprintf("id=%v", w.ID))
builder.WriteString(", victim=")
builder.WriteString(fmt.Sprintf("id=%v, ", w.ID))
builder.WriteString("victim=")
builder.WriteString(fmt.Sprintf("%v", w.Victim))
builder.WriteString(", dmg=")
builder.WriteString(", ")
builder.WriteString("dmg=")
builder.WriteString(fmt.Sprintf("%v", w.Dmg))
builder.WriteString(", eq_type=")
builder.WriteString(", ")
builder.WriteString("eq_type=")
builder.WriteString(fmt.Sprintf("%v", w.EqType))
builder.WriteString(", hit_group=")
builder.WriteString(", ")
builder.WriteString("hit_group=")
builder.WriteString(fmt.Sprintf("%v", w.HitGroup))
builder.WriteByte(')')
return builder.String()

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package weapon

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package weapon
@@ -32,12 +32,6 @@ func IDNEQ(id int) predicate.Weapon {
// IDIn applies the In predicate on the ID field.
func IDIn(ids ...int) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(ids) == 0 {
s.Where(sql.False())
return
}
v := make([]interface{}, len(ids))
for i := range v {
v[i] = ids[i]
@@ -49,12 +43,6 @@ func IDIn(ids ...int) predicate.Weapon {
// IDNotIn applies the NotIn predicate on the ID field.
func IDNotIn(ids ...int) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(ids) == 0 {
s.Where(sql.False())
return
}
v := make([]interface{}, len(ids))
for i := range v {
v[i] = ids[i]
@@ -140,12 +128,6 @@ func VictimIn(vs ...uint64) predicate.Weapon {
v[i] = vs[i]
}
return predicate.Weapon(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldVictim), v...))
})
}
@@ -157,12 +139,6 @@ func VictimNotIn(vs ...uint64) predicate.Weapon {
v[i] = vs[i]
}
return predicate.Weapon(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldVictim), v...))
})
}
@@ -216,12 +192,6 @@ func DmgIn(vs ...uint) predicate.Weapon {
v[i] = vs[i]
}
return predicate.Weapon(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldDmg), v...))
})
}
@@ -233,12 +203,6 @@ func DmgNotIn(vs ...uint) predicate.Weapon {
v[i] = vs[i]
}
return predicate.Weapon(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldDmg), v...))
})
}
@@ -292,12 +256,6 @@ func EqTypeIn(vs ...int) predicate.Weapon {
v[i] = vs[i]
}
return predicate.Weapon(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldEqType), v...))
})
}
@@ -309,12 +267,6 @@ func EqTypeNotIn(vs ...int) predicate.Weapon {
v[i] = vs[i]
}
return predicate.Weapon(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldEqType), v...))
})
}
@@ -368,12 +320,6 @@ func HitGroupIn(vs ...int) predicate.Weapon {
v[i] = vs[i]
}
return predicate.Weapon(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.In(s.C(FieldHitGroup), v...))
})
}
@@ -385,12 +331,6 @@ func HitGroupNotIn(vs ...int) predicate.Weapon {
v[i] = vs[i]
}
return predicate.Weapon(func(s *sql.Selector) {
// if not arguments were provided, append the FALSE constants,
// since we can't apply "IN ()". This will make this predicate falsy.
if len(v) == 0 {
s.Where(sql.False())
return
}
s.Where(sql.NotIn(s.C(FieldHitGroup), v...))
})
}

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -102,9 +102,15 @@ func (wc *WeaponCreate) Save(ctx context.Context) (*Weapon, error) {
}
mut = wc.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, wc.mutation); err != nil {
v, err := mut.Mutate(ctx, wc.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*Weapon)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from WeaponMutation", v)
}
node = nv
}
return node, err
}
@@ -152,7 +158,7 @@ func (wc *WeaponCreate) sqlSave(ctx context.Context) (*Weapon, error) {
_node, _spec := wc.createSpec()
if err := sqlgraph.CreateNode(ctx, wc.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
@@ -259,7 +265,7 @@ func (wcb *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) {
// Invoke the actual operation on the latest mutation in the chain.
if err = sqlgraph.BatchCreate(ctx, wcb.driver, spec); err != nil {
if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
}
}
@@ -267,11 +273,11 @@ func (wcb *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) {
return nil, err
}
mutation.id = &nodes[i].ID
mutation.done = true
if specs[i].ID.Value != nil {
id := specs[i].ID.Value.(int64)
nodes[i].ID = int(id)
}
mutation.done = true
return nodes[i], nil
})
for i := len(builder.hooks) - 1; i >= 0; i-- {

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -84,7 +84,11 @@ func (wd *WeaponDelete) sqlExec(ctx context.Context) (int, error) {
}
}
}
return sqlgraph.DeleteNodes(ctx, wd.driver, _spec)
affected, err := sqlgraph.DeleteNodes(ctx, wd.driver, _spec)
if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return affected, err
}
// WeaponDeleteOne is the builder for deleting a single Weapon entity.

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"
@@ -25,10 +24,9 @@ type WeaponQuery struct {
order []OrderFunc
fields []string
predicates []predicate.Weapon
// eager-loading edges.
withStat *MatchPlayerQuery
withFKs bool
modifiers []func(s *sql.Selector)
withStat *MatchPlayerQuery
withFKs bool
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 (wq *WeaponQuery) WithStat(opts ...func(*MatchPlayerQuery)) *WeaponQuery {
// GroupBy(weapon.FieldVictim).
// Aggregate(ent.Count()).
// Scan(ctx, &v)
//
func (wq *WeaponQuery) GroupBy(field string, fields ...string) *WeaponGroupBy {
group := &WeaponGroupBy{config: wq.config}
group.fields = append([]string{field}, fields...)
group.path = func(ctx context.Context) (prev *sql.Selector, err error) {
grbuild := &WeaponGroupBy{config: wq.config}
grbuild.fields = append([]string{field}, fields...)
grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) {
if err := wq.prepareQuery(ctx); err != nil {
return nil, err
}
return wq.sqlQuery(ctx), nil
}
return group
grbuild.label = weapon.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 (wq *WeaponQuery) GroupBy(field string, fields ...string) *WeaponGroupBy {
// client.Weapon.Query().
// Select(weapon.FieldVictim).
// Scan(ctx, &v)
//
func (wq *WeaponQuery) Select(fields ...string) *WeaponSelect {
wq.fields = append(wq.fields, fields...)
return &WeaponSelect{WeaponQuery: wq}
selbuild := &WeaponSelect{WeaponQuery: wq}
selbuild.label = weapon.Label
selbuild.flds, selbuild.scan = &wq.fields, selbuild.Scan
return selbuild
}
func (wq *WeaponQuery) prepareQuery(ctx context.Context) error {
@@ -348,7 +349,7 @@ func (wq *WeaponQuery) prepareQuery(ctx context.Context) error {
return nil
}
func (wq *WeaponQuery) sqlAll(ctx context.Context) ([]*Weapon, error) {
func (wq *WeaponQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Weapon, error) {
var (
nodes = []*Weapon{}
withFKs = wq.withFKs
@@ -364,58 +365,63 @@ func (wq *WeaponQuery) sqlAll(ctx context.Context) ([]*Weapon, error) {
_spec.Node.Columns = append(_spec.Node.Columns, weapon.ForeignKeys...)
}
_spec.ScanValues = func(columns []string) ([]interface{}, error) {
node := &Weapon{config: wq.config}
nodes = append(nodes, node)
return node.scanValues(columns)
return (*Weapon).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 := &Weapon{config: wq.config}
nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values)
}
if len(wq.modifiers) > 0 {
_spec.Modifiers = wq.modifiers
}
for i := range hooks {
hooks[i](ctx, _spec)
}
if err := sqlgraph.QueryNodes(ctx, wq.driver, _spec); err != nil {
return nil, err
}
if len(nodes) == 0 {
return nodes, nil
}
if query := wq.withStat; query != nil {
ids := make([]int, 0, len(nodes))
nodeids := make(map[int][]*Weapon)
for i := range nodes {
if nodes[i].match_player_weapon_stats == nil {
continue
}
fk := *nodes[i].match_player_weapon_stats
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 := wq.loadStat(ctx, query, nodes, nil,
func(n *Weapon, e *MatchPlayer) { n.Edges.Stat = 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_weapon_stats" returned %v`, n.ID)
}
for i := range nodes {
nodes[i].Edges.Stat = n
}
}
return nodes, nil
}
func (wq *WeaponQuery) loadStat(ctx context.Context, query *MatchPlayerQuery, nodes []*Weapon, init func(*Weapon), assign func(*Weapon, *MatchPlayer)) error {
ids := make([]int, 0, len(nodes))
nodeids := make(map[int][]*Weapon)
for i := range nodes {
if nodes[i].match_player_weapon_stats == nil {
continue
}
fk := *nodes[i].match_player_weapon_stats
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_weapon_stats" returned %v`, n.ID)
}
for i := range nodes {
assign(nodes[i], n)
}
}
return nodes, nil
return nil
}
func (wq *WeaponQuery) sqlCount(ctx context.Context) (int, error) {
@@ -530,6 +536,7 @@ func (wq *WeaponQuery) Modify(modifiers ...func(s *sql.Selector)) *WeaponSelect
// WeaponGroupBy is the group-by builder for Weapon entities.
type WeaponGroupBy struct {
config
selector
fields []string
fns []AggregateFunc
// intermediate query (i.e. traversal path).
@@ -553,209 +560,6 @@ func (wgb *WeaponGroupBy) Scan(ctx context.Context, v interface{}) error {
return wgb.sqlScan(ctx, v)
}
// ScanX is like Scan, but panics if an error occurs.
func (wgb *WeaponGroupBy) ScanX(ctx context.Context, v interface{}) {
if err := wgb.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 (wgb *WeaponGroupBy) Strings(ctx context.Context) ([]string, error) {
if len(wgb.fields) > 1 {
return nil, errors.New("ent: WeaponGroupBy.Strings is not achievable when grouping more than 1 field")
}
var v []string
if err := wgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (wgb *WeaponGroupBy) StringsX(ctx context.Context) []string {
v, err := wgb.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 (wgb *WeaponGroupBy) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = wgb.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{weapon.Label}
default:
err = fmt.Errorf("ent: WeaponGroupBy.Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (wgb *WeaponGroupBy) StringX(ctx context.Context) string {
v, err := wgb.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 (wgb *WeaponGroupBy) Ints(ctx context.Context) ([]int, error) {
if len(wgb.fields) > 1 {
return nil, errors.New("ent: WeaponGroupBy.Ints is not achievable when grouping more than 1 field")
}
var v []int
if err := wgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (wgb *WeaponGroupBy) IntsX(ctx context.Context) []int {
v, err := wgb.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 (wgb *WeaponGroupBy) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = wgb.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{weapon.Label}
default:
err = fmt.Errorf("ent: WeaponGroupBy.Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (wgb *WeaponGroupBy) IntX(ctx context.Context) int {
v, err := wgb.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 (wgb *WeaponGroupBy) Float64s(ctx context.Context) ([]float64, error) {
if len(wgb.fields) > 1 {
return nil, errors.New("ent: WeaponGroupBy.Float64s is not achievable when grouping more than 1 field")
}
var v []float64
if err := wgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (wgb *WeaponGroupBy) Float64sX(ctx context.Context) []float64 {
v, err := wgb.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 (wgb *WeaponGroupBy) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = wgb.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{weapon.Label}
default:
err = fmt.Errorf("ent: WeaponGroupBy.Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (wgb *WeaponGroupBy) Float64X(ctx context.Context) float64 {
v, err := wgb.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 (wgb *WeaponGroupBy) Bools(ctx context.Context) ([]bool, error) {
if len(wgb.fields) > 1 {
return nil, errors.New("ent: WeaponGroupBy.Bools is not achievable when grouping more than 1 field")
}
var v []bool
if err := wgb.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (wgb *WeaponGroupBy) BoolsX(ctx context.Context) []bool {
v, err := wgb.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 (wgb *WeaponGroupBy) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = wgb.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{weapon.Label}
default:
err = fmt.Errorf("ent: WeaponGroupBy.Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (wgb *WeaponGroupBy) BoolX(ctx context.Context) bool {
v, err := wgb.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
func (wgb *WeaponGroupBy) sqlScan(ctx context.Context, v interface{}) error {
for _, f := range wgb.fields {
if !weapon.ValidColumn(f) {
@@ -797,6 +601,7 @@ func (wgb *WeaponGroupBy) sqlQuery() *sql.Selector {
// WeaponSelect is the builder for selecting fields of Weapon entities.
type WeaponSelect struct {
*WeaponQuery
selector
// intermediate query (i.e. traversal path).
sql *sql.Selector
}
@@ -810,201 +615,6 @@ func (ws *WeaponSelect) Scan(ctx context.Context, v interface{}) error {
return ws.sqlScan(ctx, v)
}
// ScanX is like Scan, but panics if an error occurs.
func (ws *WeaponSelect) ScanX(ctx context.Context, v interface{}) {
if err := ws.Scan(ctx, v); err != nil {
panic(err)
}
}
// Strings returns list of strings from a selector. It is only allowed when selecting one field.
func (ws *WeaponSelect) Strings(ctx context.Context) ([]string, error) {
if len(ws.fields) > 1 {
return nil, errors.New("ent: WeaponSelect.Strings is not achievable when selecting more than 1 field")
}
var v []string
if err := ws.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// StringsX is like Strings, but panics if an error occurs.
func (ws *WeaponSelect) StringsX(ctx context.Context) []string {
v, err := ws.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 (ws *WeaponSelect) String(ctx context.Context) (_ string, err error) {
var v []string
if v, err = ws.Strings(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{weapon.Label}
default:
err = fmt.Errorf("ent: WeaponSelect.Strings returned %d results when one was expected", len(v))
}
return
}
// StringX is like String, but panics if an error occurs.
func (ws *WeaponSelect) StringX(ctx context.Context) string {
v, err := ws.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 (ws *WeaponSelect) Ints(ctx context.Context) ([]int, error) {
if len(ws.fields) > 1 {
return nil, errors.New("ent: WeaponSelect.Ints is not achievable when selecting more than 1 field")
}
var v []int
if err := ws.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// IntsX is like Ints, but panics if an error occurs.
func (ws *WeaponSelect) IntsX(ctx context.Context) []int {
v, err := ws.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 (ws *WeaponSelect) Int(ctx context.Context) (_ int, err error) {
var v []int
if v, err = ws.Ints(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{weapon.Label}
default:
err = fmt.Errorf("ent: WeaponSelect.Ints returned %d results when one was expected", len(v))
}
return
}
// IntX is like Int, but panics if an error occurs.
func (ws *WeaponSelect) IntX(ctx context.Context) int {
v, err := ws.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 (ws *WeaponSelect) Float64s(ctx context.Context) ([]float64, error) {
if len(ws.fields) > 1 {
return nil, errors.New("ent: WeaponSelect.Float64s is not achievable when selecting more than 1 field")
}
var v []float64
if err := ws.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// Float64sX is like Float64s, but panics if an error occurs.
func (ws *WeaponSelect) Float64sX(ctx context.Context) []float64 {
v, err := ws.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 (ws *WeaponSelect) Float64(ctx context.Context) (_ float64, err error) {
var v []float64
if v, err = ws.Float64s(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{weapon.Label}
default:
err = fmt.Errorf("ent: WeaponSelect.Float64s returned %d results when one was expected", len(v))
}
return
}
// Float64X is like Float64, but panics if an error occurs.
func (ws *WeaponSelect) Float64X(ctx context.Context) float64 {
v, err := ws.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 (ws *WeaponSelect) Bools(ctx context.Context) ([]bool, error) {
if len(ws.fields) > 1 {
return nil, errors.New("ent: WeaponSelect.Bools is not achievable when selecting more than 1 field")
}
var v []bool
if err := ws.Scan(ctx, &v); err != nil {
return nil, err
}
return v, nil
}
// BoolsX is like Bools, but panics if an error occurs.
func (ws *WeaponSelect) BoolsX(ctx context.Context) []bool {
v, err := ws.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 (ws *WeaponSelect) Bool(ctx context.Context) (_ bool, err error) {
var v []bool
if v, err = ws.Bools(ctx); err != nil {
return
}
switch len(v) {
case 1:
return v[0], nil
case 0:
err = &NotFoundError{weapon.Label}
default:
err = fmt.Errorf("ent: WeaponSelect.Bools returned %d results when one was expected", len(v))
}
return
}
// BoolX is like Bool, but panics if an error occurs.
func (ws *WeaponSelect) BoolX(ctx context.Context) bool {
v, err := ws.Bool(ctx)
if err != nil {
panic(err)
}
return v
}
func (ws *WeaponSelect) sqlScan(ctx context.Context, v interface{}) error {
rows := &sql.Rows{}
query, args := ws.sql.Query()

View File

@@ -1,4 +1,4 @@
// Code generated by entc, DO NOT EDIT.
// Code generated by ent, DO NOT EDIT.
package ent
@@ -18,8 +18,9 @@ import (
// WeaponUpdate is the builder for updating Weapon entities.
type WeaponUpdate struct {
config
hooks []Hook
mutation *WeaponMutation
hooks []Hook
mutation *WeaponMutation
modifiers []func(*sql.UpdateBuilder)
}
// Where appends a list predicates to the WeaponUpdate builder.
@@ -164,6 +165,12 @@ func (wu *WeaponUpdate) ExecX(ctx context.Context) {
}
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (wu *WeaponUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WeaponUpdate {
wu.modifiers = append(wu.modifiers, modifiers...)
return wu
}
func (wu *WeaponUpdate) sqlSave(ctx context.Context) (n int, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
@@ -273,11 +280,12 @@ func (wu *WeaponUpdate) sqlSave(ctx context.Context) (n int, err error) {
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.Modifiers = wu.modifiers
if n, err = sqlgraph.UpdateNodes(ctx, wu.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{weapon.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
@@ -287,9 +295,10 @@ func (wu *WeaponUpdate) sqlSave(ctx context.Context) (n int, err error) {
// WeaponUpdateOne is the builder for updating a single Weapon entity.
type WeaponUpdateOne struct {
config
fields []string
hooks []Hook
mutation *WeaponMutation
fields []string
hooks []Hook
mutation *WeaponMutation
modifiers []func(*sql.UpdateBuilder)
}
// SetVictim sets the "victim" field.
@@ -406,9 +415,15 @@ func (wuo *WeaponUpdateOne) Save(ctx context.Context) (*Weapon, error) {
}
mut = wuo.hooks[i](mut)
}
if _, err := mut.Mutate(ctx, wuo.mutation); err != nil {
v, err := mut.Mutate(ctx, wuo.mutation)
if err != nil {
return nil, err
}
nv, ok := v.(*Weapon)
if !ok {
return nil, fmt.Errorf("unexpected node type %T returned from WeaponMutation", v)
}
node = nv
}
return node, err
}
@@ -435,6 +450,12 @@ func (wuo *WeaponUpdateOne) ExecX(ctx context.Context) {
}
}
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (wuo *WeaponUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WeaponUpdateOne {
wuo.modifiers = append(wuo.modifiers, modifiers...)
return wuo
}
func (wuo *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err error) {
_spec := &sqlgraph.UpdateSpec{
Node: &sqlgraph.NodeSpec{
@@ -561,6 +582,7 @@ func (wuo *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err err
}
_spec.Edges.Add = append(_spec.Edges.Add, edge)
}
_spec.Modifiers = wuo.modifiers
_node = &Weapon{config: wuo.config}
_spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues
@@ -568,7 +590,7 @@ func (wuo *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err err
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{weapon.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{err.Error(), err}
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}