diff --git a/ent/client.go b/ent/client.go index c33d6eb..fe2a2a4 100644 --- a/ent/client.go +++ b/ent/client.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "log" + "reflect" "somegit.dev/csgowtf/csgowtfd/ent/migrate" @@ -46,9 +47,7 @@ type Client struct { // NewClient creates a new client configured with the given options. func NewClient(opts ...Option) *Client { - cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} - cfg.options(opts...) - client := &Client{config: cfg} + client := &Client{config: newConfig(opts...)} client.init() return client } @@ -82,6 +81,13 @@ type ( Option func(*config) ) +// newConfig creates a new config for the client. +func newConfig(opts ...Option) config { + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} + cfg.options(opts...) + return cfg +} + // options applies the options on the config object. func (c *config) options(opts ...Option) { for _, opt := range opts { @@ -129,11 +135,14 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error) } } +// ErrTxStarted is returned when trying to start a new transaction from a transactional client. +var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction") + // Tx returns a new transactional client. The provided context // 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, errors.New("ent: cannot start a transaction within a transaction") + return nil, ErrTxStarted } tx, err := newTx(ctx, c.driver) if err != nil { @@ -277,6 +286,21 @@ func (c *MatchClient) CreateBulk(builders ...*MatchCreate) *MatchCreateBulk { return &MatchCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *MatchClient) MapCreateBulk(slice any, setFunc func(*MatchCreate, int)) *MatchCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &MatchCreateBulk{err: fmt.Errorf("calling to MatchClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*MatchCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &MatchCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Match. func (c *MatchClient) Update() *MatchUpdate { mutation := newMatchMutation(c.config, OpUpdate) @@ -284,8 +308,8 @@ func (c *MatchClient) Update() *MatchUpdate { } // UpdateOne returns an update builder for the given entity. -func (c *MatchClient) UpdateOne(m *Match) *MatchUpdateOne { - mutation := newMatchMutation(c.config, OpUpdateOne, withMatch(m)) +func (c *MatchClient) UpdateOne(_m *Match) *MatchUpdateOne { + mutation := newMatchMutation(c.config, OpUpdateOne, withMatch(_m)) return &MatchUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -302,8 +326,8 @@ func (c *MatchClient) Delete() *MatchDelete { } // DeleteOne returns a builder for deleting the given entity. -func (c *MatchClient) DeleteOne(m *Match) *MatchDeleteOne { - return c.DeleteOneID(m.ID) +func (c *MatchClient) DeleteOne(_m *Match) *MatchDeleteOne { + return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. @@ -338,32 +362,32 @@ func (c *MatchClient) GetX(ctx context.Context, id uint64) *Match { } // QueryStats queries the stats edge of a Match. -func (c *MatchClient) QueryStats(m *Match) *MatchPlayerQuery { +func (c *MatchClient) QueryStats(_m *Match) *MatchPlayerQuery { query := (&MatchPlayerClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := m.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(match.Table, match.FieldID, id), sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, match.StatsTable, match.StatsColumn), ) - fromV = sqlgraph.Neighbors(m.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryPlayers queries the players edge of a Match. -func (c *MatchClient) QueryPlayers(m *Match) *PlayerQuery { +func (c *MatchClient) QueryPlayers(_m *Match) *PlayerQuery { query := (&PlayerClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := m.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(match.Table, match.FieldID, id), sqlgraph.To(player.Table, player.FieldID), sqlgraph.Edge(sqlgraph.M2M, true, match.PlayersTable, match.PlayersPrimaryKey...), ) - fromV = sqlgraph.Neighbors(m.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query @@ -427,6 +451,21 @@ func (c *MatchPlayerClient) CreateBulk(builders ...*MatchPlayerCreate) *MatchPla return &MatchPlayerCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *MatchPlayerClient) MapCreateBulk(slice any, setFunc func(*MatchPlayerCreate, int)) *MatchPlayerCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &MatchPlayerCreateBulk{err: fmt.Errorf("calling to MatchPlayerClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*MatchPlayerCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &MatchPlayerCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for MatchPlayer. func (c *MatchPlayerClient) Update() *MatchPlayerUpdate { mutation := newMatchPlayerMutation(c.config, OpUpdate) @@ -434,8 +473,8 @@ func (c *MatchPlayerClient) Update() *MatchPlayerUpdate { } // UpdateOne returns an update builder for the given entity. -func (c *MatchPlayerClient) UpdateOne(mp *MatchPlayer) *MatchPlayerUpdateOne { - mutation := newMatchPlayerMutation(c.config, OpUpdateOne, withMatchPlayer(mp)) +func (c *MatchPlayerClient) UpdateOne(_m *MatchPlayer) *MatchPlayerUpdateOne { + mutation := newMatchPlayerMutation(c.config, OpUpdateOne, withMatchPlayer(_m)) return &MatchPlayerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -452,8 +491,8 @@ func (c *MatchPlayerClient) Delete() *MatchPlayerDelete { } // DeleteOne returns a builder for deleting the given entity. -func (c *MatchPlayerClient) DeleteOne(mp *MatchPlayer) *MatchPlayerDeleteOne { - return c.DeleteOneID(mp.ID) +func (c *MatchPlayerClient) DeleteOne(_m *MatchPlayer) *MatchPlayerDeleteOne { + return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. @@ -488,96 +527,96 @@ func (c *MatchPlayerClient) GetX(ctx context.Context, id int) *MatchPlayer { } // QueryMatches queries the matches edge of a MatchPlayer. -func (c *MatchPlayerClient) QueryMatches(mp *MatchPlayer) *MatchQuery { +func (c *MatchPlayerClient) QueryMatches(_m *MatchPlayer) *MatchQuery { query := (&MatchClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := mp.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id), sqlgraph.To(match.Table, match.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, matchplayer.MatchesTable, matchplayer.MatchesColumn), ) - fromV = sqlgraph.Neighbors(mp.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryPlayers queries the players edge of a MatchPlayer. -func (c *MatchPlayerClient) QueryPlayers(mp *MatchPlayer) *PlayerQuery { +func (c *MatchPlayerClient) QueryPlayers(_m *MatchPlayer) *PlayerQuery { query := (&PlayerClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := mp.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id), sqlgraph.To(player.Table, player.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, matchplayer.PlayersTable, matchplayer.PlayersColumn), ) - fromV = sqlgraph.Neighbors(mp.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryWeaponStats queries the weapon_stats edge of a MatchPlayer. -func (c *MatchPlayerClient) QueryWeaponStats(mp *MatchPlayer) *WeaponQuery { +func (c *MatchPlayerClient) QueryWeaponStats(_m *MatchPlayer) *WeaponQuery { query := (&WeaponClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := mp.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id), sqlgraph.To(weapon.Table, weapon.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.WeaponStatsTable, matchplayer.WeaponStatsColumn), ) - fromV = sqlgraph.Neighbors(mp.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryRoundStats queries the round_stats edge of a MatchPlayer. -func (c *MatchPlayerClient) QueryRoundStats(mp *MatchPlayer) *RoundStatsQuery { +func (c *MatchPlayerClient) QueryRoundStats(_m *MatchPlayer) *RoundStatsQuery { query := (&RoundStatsClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := mp.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id), sqlgraph.To(roundstats.Table, roundstats.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.RoundStatsTable, matchplayer.RoundStatsColumn), ) - fromV = sqlgraph.Neighbors(mp.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QuerySpray queries the spray edge of a MatchPlayer. -func (c *MatchPlayerClient) QuerySpray(mp *MatchPlayer) *SprayQuery { +func (c *MatchPlayerClient) QuerySpray(_m *MatchPlayer) *SprayQuery { query := (&SprayClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := mp.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id), sqlgraph.To(spray.Table, spray.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.SprayTable, matchplayer.SprayColumn), ) - fromV = sqlgraph.Neighbors(mp.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryMessages queries the messages edge of a MatchPlayer. -func (c *MatchPlayerClient) QueryMessages(mp *MatchPlayer) *MessagesQuery { +func (c *MatchPlayerClient) QueryMessages(_m *MatchPlayer) *MessagesQuery { query := (&MessagesClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := mp.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id), sqlgraph.To(messages.Table, messages.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.MessagesTable, matchplayer.MessagesColumn), ) - fromV = sqlgraph.Neighbors(mp.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query @@ -641,6 +680,21 @@ func (c *MessagesClient) CreateBulk(builders ...*MessagesCreate) *MessagesCreate return &MessagesCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *MessagesClient) MapCreateBulk(slice any, setFunc func(*MessagesCreate, int)) *MessagesCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &MessagesCreateBulk{err: fmt.Errorf("calling to MessagesClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*MessagesCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &MessagesCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Messages. func (c *MessagesClient) Update() *MessagesUpdate { mutation := newMessagesMutation(c.config, OpUpdate) @@ -648,8 +702,8 @@ func (c *MessagesClient) Update() *MessagesUpdate { } // UpdateOne returns an update builder for the given entity. -func (c *MessagesClient) UpdateOne(m *Messages) *MessagesUpdateOne { - mutation := newMessagesMutation(c.config, OpUpdateOne, withMessages(m)) +func (c *MessagesClient) UpdateOne(_m *Messages) *MessagesUpdateOne { + mutation := newMessagesMutation(c.config, OpUpdateOne, withMessages(_m)) return &MessagesUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -666,8 +720,8 @@ func (c *MessagesClient) Delete() *MessagesDelete { } // DeleteOne returns a builder for deleting the given entity. -func (c *MessagesClient) DeleteOne(m *Messages) *MessagesDeleteOne { - return c.DeleteOneID(m.ID) +func (c *MessagesClient) DeleteOne(_m *Messages) *MessagesDeleteOne { + return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. @@ -702,16 +756,16 @@ func (c *MessagesClient) GetX(ctx context.Context, id int) *Messages { } // QueryMatchPlayer queries the match_player edge of a Messages. -func (c *MessagesClient) QueryMatchPlayer(m *Messages) *MatchPlayerQuery { +func (c *MessagesClient) QueryMatchPlayer(_m *Messages) *MatchPlayerQuery { query := (&MatchPlayerClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := m.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(messages.Table, messages.FieldID, id), sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, messages.MatchPlayerTable, messages.MatchPlayerColumn), ) - fromV = sqlgraph.Neighbors(m.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query @@ -775,6 +829,21 @@ func (c *PlayerClient) CreateBulk(builders ...*PlayerCreate) *PlayerCreateBulk { return &PlayerCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *PlayerClient) MapCreateBulk(slice any, setFunc func(*PlayerCreate, int)) *PlayerCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &PlayerCreateBulk{err: fmt.Errorf("calling to PlayerClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*PlayerCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &PlayerCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Player. func (c *PlayerClient) Update() *PlayerUpdate { mutation := newPlayerMutation(c.config, OpUpdate) @@ -782,8 +851,8 @@ func (c *PlayerClient) Update() *PlayerUpdate { } // UpdateOne returns an update builder for the given entity. -func (c *PlayerClient) UpdateOne(pl *Player) *PlayerUpdateOne { - mutation := newPlayerMutation(c.config, OpUpdateOne, withPlayer(pl)) +func (c *PlayerClient) UpdateOne(_m *Player) *PlayerUpdateOne { + mutation := newPlayerMutation(c.config, OpUpdateOne, withPlayer(_m)) return &PlayerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -800,8 +869,8 @@ func (c *PlayerClient) Delete() *PlayerDelete { } // DeleteOne returns a builder for deleting the given entity. -func (c *PlayerClient) DeleteOne(pl *Player) *PlayerDeleteOne { - return c.DeleteOneID(pl.ID) +func (c *PlayerClient) DeleteOne(_m *Player) *PlayerDeleteOne { + return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. @@ -836,32 +905,32 @@ func (c *PlayerClient) GetX(ctx context.Context, id uint64) *Player { } // QueryStats queries the stats edge of a Player. -func (c *PlayerClient) QueryStats(pl *Player) *MatchPlayerQuery { +func (c *PlayerClient) QueryStats(_m *Player) *MatchPlayerQuery { query := (&MatchPlayerClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := pl.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(player.Table, player.FieldID, id), sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, player.StatsTable, player.StatsColumn), ) - fromV = sqlgraph.Neighbors(pl.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query } // QueryMatches queries the matches edge of a Player. -func (c *PlayerClient) QueryMatches(pl *Player) *MatchQuery { +func (c *PlayerClient) QueryMatches(_m *Player) *MatchQuery { query := (&MatchClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := pl.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(player.Table, player.FieldID, id), sqlgraph.To(match.Table, match.FieldID), sqlgraph.Edge(sqlgraph.M2M, false, player.MatchesTable, player.MatchesPrimaryKey...), ) - fromV = sqlgraph.Neighbors(pl.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query @@ -925,6 +994,21 @@ func (c *RoundStatsClient) CreateBulk(builders ...*RoundStatsCreate) *RoundStats return &RoundStatsCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *RoundStatsClient) MapCreateBulk(slice any, setFunc func(*RoundStatsCreate, int)) *RoundStatsCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &RoundStatsCreateBulk{err: fmt.Errorf("calling to RoundStatsClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*RoundStatsCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &RoundStatsCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for RoundStats. func (c *RoundStatsClient) Update() *RoundStatsUpdate { mutation := newRoundStatsMutation(c.config, OpUpdate) @@ -932,8 +1016,8 @@ func (c *RoundStatsClient) Update() *RoundStatsUpdate { } // UpdateOne returns an update builder for the given entity. -func (c *RoundStatsClient) UpdateOne(rs *RoundStats) *RoundStatsUpdateOne { - mutation := newRoundStatsMutation(c.config, OpUpdateOne, withRoundStats(rs)) +func (c *RoundStatsClient) UpdateOne(_m *RoundStats) *RoundStatsUpdateOne { + mutation := newRoundStatsMutation(c.config, OpUpdateOne, withRoundStats(_m)) return &RoundStatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -950,8 +1034,8 @@ func (c *RoundStatsClient) Delete() *RoundStatsDelete { } // DeleteOne returns a builder for deleting the given entity. -func (c *RoundStatsClient) DeleteOne(rs *RoundStats) *RoundStatsDeleteOne { - return c.DeleteOneID(rs.ID) +func (c *RoundStatsClient) DeleteOne(_m *RoundStats) *RoundStatsDeleteOne { + return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. @@ -986,16 +1070,16 @@ func (c *RoundStatsClient) GetX(ctx context.Context, id int) *RoundStats { } // QueryMatchPlayer queries the match_player edge of a RoundStats. -func (c *RoundStatsClient) QueryMatchPlayer(rs *RoundStats) *MatchPlayerQuery { +func (c *RoundStatsClient) QueryMatchPlayer(_m *RoundStats) *MatchPlayerQuery { query := (&MatchPlayerClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := rs.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(roundstats.Table, roundstats.FieldID, id), sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, roundstats.MatchPlayerTable, roundstats.MatchPlayerColumn), ) - fromV = sqlgraph.Neighbors(rs.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query @@ -1059,6 +1143,21 @@ func (c *SprayClient) CreateBulk(builders ...*SprayCreate) *SprayCreateBulk { return &SprayCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *SprayClient) MapCreateBulk(slice any, setFunc func(*SprayCreate, int)) *SprayCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &SprayCreateBulk{err: fmt.Errorf("calling to SprayClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*SprayCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &SprayCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Spray. func (c *SprayClient) Update() *SprayUpdate { mutation := newSprayMutation(c.config, OpUpdate) @@ -1066,8 +1165,8 @@ func (c *SprayClient) Update() *SprayUpdate { } // UpdateOne returns an update builder for the given entity. -func (c *SprayClient) UpdateOne(s *Spray) *SprayUpdateOne { - mutation := newSprayMutation(c.config, OpUpdateOne, withSpray(s)) +func (c *SprayClient) UpdateOne(_m *Spray) *SprayUpdateOne { + mutation := newSprayMutation(c.config, OpUpdateOne, withSpray(_m)) return &SprayUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -1084,8 +1183,8 @@ func (c *SprayClient) Delete() *SprayDelete { } // DeleteOne returns a builder for deleting the given entity. -func (c *SprayClient) DeleteOne(s *Spray) *SprayDeleteOne { - return c.DeleteOneID(s.ID) +func (c *SprayClient) DeleteOne(_m *Spray) *SprayDeleteOne { + return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. @@ -1120,16 +1219,16 @@ func (c *SprayClient) GetX(ctx context.Context, id int) *Spray { } // QueryMatchPlayers queries the match_players edge of a Spray. -func (c *SprayClient) QueryMatchPlayers(s *Spray) *MatchPlayerQuery { +func (c *SprayClient) QueryMatchPlayers(_m *Spray) *MatchPlayerQuery { query := (&MatchPlayerClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := s.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(spray.Table, spray.FieldID, id), sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, spray.MatchPlayersTable, spray.MatchPlayersColumn), ) - fromV = sqlgraph.Neighbors(s.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query @@ -1193,6 +1292,21 @@ func (c *WeaponClient) CreateBulk(builders ...*WeaponCreate) *WeaponCreateBulk { return &WeaponCreateBulk{config: c.config, builders: builders} } +// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates +// a builder and applies setFunc on it. +func (c *WeaponClient) MapCreateBulk(slice any, setFunc func(*WeaponCreate, int)) *WeaponCreateBulk { + rv := reflect.ValueOf(slice) + if rv.Kind() != reflect.Slice { + return &WeaponCreateBulk{err: fmt.Errorf("calling to WeaponClient.MapCreateBulk with wrong type %T, need slice", slice)} + } + builders := make([]*WeaponCreate, rv.Len()) + for i := 0; i < rv.Len(); i++ { + builders[i] = c.Create() + setFunc(builders[i], i) + } + return &WeaponCreateBulk{config: c.config, builders: builders} +} + // Update returns an update builder for Weapon. func (c *WeaponClient) Update() *WeaponUpdate { mutation := newWeaponMutation(c.config, OpUpdate) @@ -1200,8 +1314,8 @@ func (c *WeaponClient) Update() *WeaponUpdate { } // UpdateOne returns an update builder for the given entity. -func (c *WeaponClient) UpdateOne(w *Weapon) *WeaponUpdateOne { - mutation := newWeaponMutation(c.config, OpUpdateOne, withWeapon(w)) +func (c *WeaponClient) UpdateOne(_m *Weapon) *WeaponUpdateOne { + mutation := newWeaponMutation(c.config, OpUpdateOne, withWeapon(_m)) return &WeaponUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} } @@ -1218,8 +1332,8 @@ func (c *WeaponClient) Delete() *WeaponDelete { } // DeleteOne returns a builder for deleting the given entity. -func (c *WeaponClient) DeleteOne(w *Weapon) *WeaponDeleteOne { - return c.DeleteOneID(w.ID) +func (c *WeaponClient) DeleteOne(_m *Weapon) *WeaponDeleteOne { + return c.DeleteOneID(_m.ID) } // DeleteOneID returns a builder for deleting the given entity by its id. @@ -1254,16 +1368,16 @@ func (c *WeaponClient) GetX(ctx context.Context, id int) *Weapon { } // QueryStat queries the stat edge of a Weapon. -func (c *WeaponClient) QueryStat(w *Weapon) *MatchPlayerQuery { +func (c *WeaponClient) QueryStat(_m *Weapon) *MatchPlayerQuery { query := (&MatchPlayerClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { - id := w.ID + id := _m.ID step := sqlgraph.NewStep( sqlgraph.From(weapon.Table, weapon.FieldID, id), sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, weapon.StatTable, weapon.StatColumn), ) - fromV = sqlgraph.Neighbors(w.driver.Dialect(), step) + fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step) return fromV, nil } return query diff --git a/ent/ent.go b/ent/ent.go index 12e1df5..2e364a5 100644 --- a/ent/ent.go +++ b/ent/ent.go @@ -75,8 +75,8 @@ var ( columnCheck sql.ColumnCheck ) -// columnChecker checks if the column exists in the given table. -func checkColumn(table, column string) error { +// checkColumn checks if the column exists in the given table. +func checkColumn(t, c string) error { initCheck.Do(func() { columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ match.Table: match.ValidColumn, @@ -88,7 +88,7 @@ func checkColumn(table, column string) error { weapon.Table: weapon.ValidColumn, }) }) - return columnCheck(table, column) + return columnCheck(t, c) } // Asc applies the given fields in ASC order. diff --git a/ent/match.go b/ent/match.go index 0b93e18..ec108dc 100644 --- a/ent/match.go +++ b/ent/match.go @@ -106,7 +106,7 @@ func (*Match) scanValues(columns []string) ([]any, error) { // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the Match fields. -func (m *Match) assignValues(columns []string, values []any) error { +func (_m *Match) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } @@ -117,93 +117,93 @@ func (m *Match) assignValues(columns []string, values []any) error { if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - m.ID = uint64(value.Int64) + _m.ID = uint64(value.Int64) case match.FieldShareCode: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field share_code", values[i]) } else if value.Valid { - m.ShareCode = value.String + _m.ShareCode = value.String } case match.FieldMap: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field map", values[i]) } else if value.Valid { - m.Map = value.String + _m.Map = value.String } case match.FieldDate: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field date", values[i]) } else if value.Valid { - m.Date = value.Time + _m.Date = value.Time } case match.FieldScoreTeamA: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field score_team_a", values[i]) } else if value.Valid { - m.ScoreTeamA = int(value.Int64) + _m.ScoreTeamA = int(value.Int64) } case match.FieldScoreTeamB: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field score_team_b", values[i]) } else if value.Valid { - m.ScoreTeamB = int(value.Int64) + _m.ScoreTeamB = int(value.Int64) } case match.FieldReplayURL: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field replay_url", values[i]) } else if value.Valid { - m.ReplayURL = value.String + _m.ReplayURL = value.String } case match.FieldDuration: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field duration", values[i]) } else if value.Valid { - m.Duration = int(value.Int64) + _m.Duration = int(value.Int64) } case match.FieldMatchResult: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field match_result", values[i]) } else if value.Valid { - m.MatchResult = int(value.Int64) + _m.MatchResult = int(value.Int64) } case match.FieldMaxRounds: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field max_rounds", values[i]) } else if value.Valid { - m.MaxRounds = int(value.Int64) + _m.MaxRounds = int(value.Int64) } case match.FieldDemoParsed: if value, ok := values[i].(*sql.NullBool); !ok { return fmt.Errorf("unexpected type %T for field demo_parsed", values[i]) } else if value.Valid { - m.DemoParsed = value.Bool + _m.DemoParsed = value.Bool } case match.FieldVacPresent: if value, ok := values[i].(*sql.NullBool); !ok { return fmt.Errorf("unexpected type %T for field vac_present", values[i]) } else if value.Valid { - m.VacPresent = value.Bool + _m.VacPresent = value.Bool } case match.FieldGamebanPresent: if value, ok := values[i].(*sql.NullBool); !ok { return fmt.Errorf("unexpected type %T for field gameban_present", values[i]) } else if value.Valid { - m.GamebanPresent = value.Bool + _m.GamebanPresent = value.Bool } case match.FieldDecryptionKey: if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field decryption_key", values[i]) } else if value != nil { - m.DecryptionKey = *value + _m.DecryptionKey = *value } case match.FieldTickRate: if value, ok := values[i].(*sql.NullFloat64); !ok { return fmt.Errorf("unexpected type %T for field tick_rate", values[i]) } else if value.Valid { - m.TickRate = value.Float64 + _m.TickRate = value.Float64 } default: - m.selectValues.Set(columns[i], values[i]) + _m.selectValues.Set(columns[i], values[i]) } } return nil @@ -211,84 +211,84 @@ func (m *Match) assignValues(columns []string, values []any) error { // Value returns the ent.Value that was dynamically selected and assigned to the Match. // This includes values selected through modifiers, order, etc. -func (m *Match) Value(name string) (ent.Value, error) { - return m.selectValues.Get(name) +func (_m *Match) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) } // QueryStats queries the "stats" edge of the Match entity. -func (m *Match) QueryStats() *MatchPlayerQuery { - return NewMatchClient(m.config).QueryStats(m) +func (_m *Match) QueryStats() *MatchPlayerQuery { + return NewMatchClient(_m.config).QueryStats(_m) } // QueryPlayers queries the "players" edge of the Match entity. -func (m *Match) QueryPlayers() *PlayerQuery { - return NewMatchClient(m.config).QueryPlayers(m) +func (_m *Match) QueryPlayers() *PlayerQuery { + return NewMatchClient(_m.config).QueryPlayers(_m) } // Update returns a builder for updating this Match. // Note that you need to call Match.Unwrap() before calling this method if this Match // was returned from a transaction, and the transaction was committed or rolled back. -func (m *Match) Update() *MatchUpdateOne { - return NewMatchClient(m.config).UpdateOne(m) +func (_m *Match) Update() *MatchUpdateOne { + return NewMatchClient(_m.config).UpdateOne(_m) } // 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) +func (_m *Match) Unwrap() *Match { + _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: Match is not a transactional entity") } - m.config.driver = _tx.drv - return m + _m.config.driver = _tx.drv + return _m } // String implements the fmt.Stringer. -func (m *Match) String() string { +func (_m *Match) String() string { var builder strings.Builder builder.WriteString("Match(") - builder.WriteString(fmt.Sprintf("id=%v, ", m.ID)) + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("share_code=") - builder.WriteString(m.ShareCode) + builder.WriteString(_m.ShareCode) builder.WriteString(", ") builder.WriteString("map=") - builder.WriteString(m.Map) + builder.WriteString(_m.Map) builder.WriteString(", ") builder.WriteString("date=") - builder.WriteString(m.Date.Format(time.ANSIC)) + builder.WriteString(_m.Date.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("score_team_a=") - builder.WriteString(fmt.Sprintf("%v", m.ScoreTeamA)) + builder.WriteString(fmt.Sprintf("%v", _m.ScoreTeamA)) builder.WriteString(", ") builder.WriteString("score_team_b=") - builder.WriteString(fmt.Sprintf("%v", m.ScoreTeamB)) + builder.WriteString(fmt.Sprintf("%v", _m.ScoreTeamB)) builder.WriteString(", ") builder.WriteString("replay_url=") - builder.WriteString(m.ReplayURL) + builder.WriteString(_m.ReplayURL) builder.WriteString(", ") builder.WriteString("duration=") - builder.WriteString(fmt.Sprintf("%v", m.Duration)) + builder.WriteString(fmt.Sprintf("%v", _m.Duration)) builder.WriteString(", ") builder.WriteString("match_result=") - builder.WriteString(fmt.Sprintf("%v", m.MatchResult)) + builder.WriteString(fmt.Sprintf("%v", _m.MatchResult)) builder.WriteString(", ") builder.WriteString("max_rounds=") - builder.WriteString(fmt.Sprintf("%v", m.MaxRounds)) + builder.WriteString(fmt.Sprintf("%v", _m.MaxRounds)) builder.WriteString(", ") builder.WriteString("demo_parsed=") - builder.WriteString(fmt.Sprintf("%v", m.DemoParsed)) + builder.WriteString(fmt.Sprintf("%v", _m.DemoParsed)) builder.WriteString(", ") builder.WriteString("vac_present=") - builder.WriteString(fmt.Sprintf("%v", m.VacPresent)) + builder.WriteString(fmt.Sprintf("%v", _m.VacPresent)) builder.WriteString(", ") builder.WriteString("gameban_present=") - builder.WriteString(fmt.Sprintf("%v", m.GamebanPresent)) + builder.WriteString(fmt.Sprintf("%v", _m.GamebanPresent)) builder.WriteString(", ") builder.WriteString("decryption_key=") - builder.WriteString(fmt.Sprintf("%v", m.DecryptionKey)) + builder.WriteString(fmt.Sprintf("%v", _m.DecryptionKey)) builder.WriteString(", ") builder.WriteString("tick_rate=") - builder.WriteString(fmt.Sprintf("%v", m.TickRate)) + builder.WriteString(fmt.Sprintf("%v", _m.TickRate)) builder.WriteByte(')') return builder.String() } diff --git a/ent/match/where.go b/ent/match/where.go index 6c4d1b7..b952c7f 100644 --- a/ent/match/where.go +++ b/ent/match/where.go @@ -758,32 +758,15 @@ func HasPlayersWith(preds ...predicate.Player) predicate.Match { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Match) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Match(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Match) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Match(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Match) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Match(sql.NotPredicates(p)) } diff --git a/ent/match_create.go b/ent/match_create.go index 5bb90ee..0fc42f3 100644 --- a/ent/match_create.go +++ b/ent/match_create.go @@ -23,187 +23,187 @@ type MatchCreate struct { } // SetShareCode sets the "share_code" field. -func (mc *MatchCreate) SetShareCode(s string) *MatchCreate { - mc.mutation.SetShareCode(s) - return mc +func (_c *MatchCreate) SetShareCode(v string) *MatchCreate { + _c.mutation.SetShareCode(v) + return _c } // SetMap sets the "map" field. -func (mc *MatchCreate) SetMap(s string) *MatchCreate { - mc.mutation.SetMap(s) - return mc +func (_c *MatchCreate) SetMap(v string) *MatchCreate { + _c.mutation.SetMap(v) + return _c } // SetNillableMap sets the "map" field if the given value is not nil. -func (mc *MatchCreate) SetNillableMap(s *string) *MatchCreate { - if s != nil { - mc.SetMap(*s) +func (_c *MatchCreate) SetNillableMap(v *string) *MatchCreate { + if v != nil { + _c.SetMap(*v) } - return mc + return _c } // SetDate sets the "date" field. -func (mc *MatchCreate) SetDate(t time.Time) *MatchCreate { - mc.mutation.SetDate(t) - return mc +func (_c *MatchCreate) SetDate(v time.Time) *MatchCreate { + _c.mutation.SetDate(v) + return _c } // SetScoreTeamA sets the "score_team_a" field. -func (mc *MatchCreate) SetScoreTeamA(i int) *MatchCreate { - mc.mutation.SetScoreTeamA(i) - return mc +func (_c *MatchCreate) SetScoreTeamA(v int) *MatchCreate { + _c.mutation.SetScoreTeamA(v) + return _c } // SetScoreTeamB sets the "score_team_b" field. -func (mc *MatchCreate) SetScoreTeamB(i int) *MatchCreate { - mc.mutation.SetScoreTeamB(i) - return mc +func (_c *MatchCreate) SetScoreTeamB(v int) *MatchCreate { + _c.mutation.SetScoreTeamB(v) + return _c } // SetReplayURL sets the "replay_url" field. -func (mc *MatchCreate) SetReplayURL(s string) *MatchCreate { - mc.mutation.SetReplayURL(s) - return mc +func (_c *MatchCreate) SetReplayURL(v string) *MatchCreate { + _c.mutation.SetReplayURL(v) + return _c } // SetNillableReplayURL sets the "replay_url" field if the given value is not nil. -func (mc *MatchCreate) SetNillableReplayURL(s *string) *MatchCreate { - if s != nil { - mc.SetReplayURL(*s) +func (_c *MatchCreate) SetNillableReplayURL(v *string) *MatchCreate { + if v != nil { + _c.SetReplayURL(*v) } - return mc + return _c } // SetDuration sets the "duration" field. -func (mc *MatchCreate) SetDuration(i int) *MatchCreate { - mc.mutation.SetDuration(i) - return mc +func (_c *MatchCreate) SetDuration(v int) *MatchCreate { + _c.mutation.SetDuration(v) + return _c } // SetMatchResult sets the "match_result" field. -func (mc *MatchCreate) SetMatchResult(i int) *MatchCreate { - mc.mutation.SetMatchResult(i) - return mc +func (_c *MatchCreate) SetMatchResult(v int) *MatchCreate { + _c.mutation.SetMatchResult(v) + return _c } // SetMaxRounds sets the "max_rounds" field. -func (mc *MatchCreate) SetMaxRounds(i int) *MatchCreate { - mc.mutation.SetMaxRounds(i) - return mc +func (_c *MatchCreate) SetMaxRounds(v int) *MatchCreate { + _c.mutation.SetMaxRounds(v) + return _c } // SetDemoParsed sets the "demo_parsed" field. -func (mc *MatchCreate) SetDemoParsed(b bool) *MatchCreate { - mc.mutation.SetDemoParsed(b) - return mc +func (_c *MatchCreate) SetDemoParsed(v bool) *MatchCreate { + _c.mutation.SetDemoParsed(v) + return _c } // SetNillableDemoParsed sets the "demo_parsed" field if the given value is not nil. -func (mc *MatchCreate) SetNillableDemoParsed(b *bool) *MatchCreate { - if b != nil { - mc.SetDemoParsed(*b) +func (_c *MatchCreate) SetNillableDemoParsed(v *bool) *MatchCreate { + if v != nil { + _c.SetDemoParsed(*v) } - return mc + return _c } // SetVacPresent sets the "vac_present" field. -func (mc *MatchCreate) SetVacPresent(b bool) *MatchCreate { - mc.mutation.SetVacPresent(b) - return mc +func (_c *MatchCreate) SetVacPresent(v bool) *MatchCreate { + _c.mutation.SetVacPresent(v) + return _c } // SetNillableVacPresent sets the "vac_present" field if the given value is not nil. -func (mc *MatchCreate) SetNillableVacPresent(b *bool) *MatchCreate { - if b != nil { - mc.SetVacPresent(*b) +func (_c *MatchCreate) SetNillableVacPresent(v *bool) *MatchCreate { + if v != nil { + _c.SetVacPresent(*v) } - return mc + return _c } // SetGamebanPresent sets the "gameban_present" field. -func (mc *MatchCreate) SetGamebanPresent(b bool) *MatchCreate { - mc.mutation.SetGamebanPresent(b) - return mc +func (_c *MatchCreate) SetGamebanPresent(v bool) *MatchCreate { + _c.mutation.SetGamebanPresent(v) + return _c } // SetNillableGamebanPresent sets the "gameban_present" field if the given value is not nil. -func (mc *MatchCreate) SetNillableGamebanPresent(b *bool) *MatchCreate { - if b != nil { - mc.SetGamebanPresent(*b) +func (_c *MatchCreate) SetNillableGamebanPresent(v *bool) *MatchCreate { + if v != nil { + _c.SetGamebanPresent(*v) } - return mc + return _c } // SetDecryptionKey sets the "decryption_key" field. -func (mc *MatchCreate) SetDecryptionKey(b []byte) *MatchCreate { - mc.mutation.SetDecryptionKey(b) - return mc +func (_c *MatchCreate) SetDecryptionKey(v []byte) *MatchCreate { + _c.mutation.SetDecryptionKey(v) + return _c } // SetTickRate sets the "tick_rate" field. -func (mc *MatchCreate) SetTickRate(f float64) *MatchCreate { - mc.mutation.SetTickRate(f) - return mc +func (_c *MatchCreate) SetTickRate(v float64) *MatchCreate { + _c.mutation.SetTickRate(v) + return _c } // SetNillableTickRate sets the "tick_rate" field if the given value is not nil. -func (mc *MatchCreate) SetNillableTickRate(f *float64) *MatchCreate { - if f != nil { - mc.SetTickRate(*f) +func (_c *MatchCreate) SetNillableTickRate(v *float64) *MatchCreate { + if v != nil { + _c.SetTickRate(*v) } - return mc + return _c } // SetID sets the "id" field. -func (mc *MatchCreate) SetID(u uint64) *MatchCreate { - mc.mutation.SetID(u) - return mc +func (_c *MatchCreate) SetID(v uint64) *MatchCreate { + _c.mutation.SetID(v) + return _c } // AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs. -func (mc *MatchCreate) AddStatIDs(ids ...int) *MatchCreate { - mc.mutation.AddStatIDs(ids...) - return mc +func (_c *MatchCreate) AddStatIDs(ids ...int) *MatchCreate { + _c.mutation.AddStatIDs(ids...) + return _c } // AddStats adds the "stats" edges to the MatchPlayer entity. -func (mc *MatchCreate) AddStats(m ...*MatchPlayer) *MatchCreate { - ids := make([]int, len(m)) - for i := range m { - ids[i] = m[i].ID +func (_c *MatchCreate) AddStats(v ...*MatchPlayer) *MatchCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mc.AddStatIDs(ids...) + return _c.AddStatIDs(ids...) } // AddPlayerIDs adds the "players" edge to the Player entity by IDs. -func (mc *MatchCreate) AddPlayerIDs(ids ...uint64) *MatchCreate { - mc.mutation.AddPlayerIDs(ids...) - return mc +func (_c *MatchCreate) AddPlayerIDs(ids ...uint64) *MatchCreate { + _c.mutation.AddPlayerIDs(ids...) + return _c } // AddPlayers adds the "players" edges to the Player entity. -func (mc *MatchCreate) AddPlayers(p ...*Player) *MatchCreate { - ids := make([]uint64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_c *MatchCreate) AddPlayers(v ...*Player) *MatchCreate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mc.AddPlayerIDs(ids...) + return _c.AddPlayerIDs(ids...) } // Mutation returns the MatchMutation object of the builder. -func (mc *MatchCreate) Mutation() *MatchMutation { - return mc.mutation +func (_c *MatchCreate) Mutation() *MatchMutation { + return _c.mutation } // Save creates the Match in the database. -func (mc *MatchCreate) Save(ctx context.Context) (*Match, error) { - mc.defaults() - return withHooks(ctx, mc.sqlSave, mc.mutation, mc.hooks) +func (_c *MatchCreate) Save(ctx context.Context) (*Match, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. -func (mc *MatchCreate) SaveX(ctx context.Context) *Match { - v, err := mc.Save(ctx) +func (_c *MatchCreate) SaveX(ctx context.Context) *Match { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -211,75 +211,75 @@ func (mc *MatchCreate) SaveX(ctx context.Context) *Match { } // Exec executes the query. -func (mc *MatchCreate) Exec(ctx context.Context) error { - _, err := mc.Save(ctx) +func (_c *MatchCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (mc *MatchCreate) ExecX(ctx context.Context) { - if err := mc.Exec(ctx); err != nil { +func (_c *MatchCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (mc *MatchCreate) defaults() { - if _, ok := mc.mutation.DemoParsed(); !ok { +func (_c *MatchCreate) defaults() { + if _, ok := _c.mutation.DemoParsed(); !ok { v := match.DefaultDemoParsed - mc.mutation.SetDemoParsed(v) + _c.mutation.SetDemoParsed(v) } - if _, ok := mc.mutation.VacPresent(); !ok { + if _, ok := _c.mutation.VacPresent(); !ok { v := match.DefaultVacPresent - mc.mutation.SetVacPresent(v) + _c.mutation.SetVacPresent(v) } - if _, ok := mc.mutation.GamebanPresent(); !ok { + if _, ok := _c.mutation.GamebanPresent(); !ok { v := match.DefaultGamebanPresent - mc.mutation.SetGamebanPresent(v) + _c.mutation.SetGamebanPresent(v) } } // check runs all checks and user-defined validators on the builder. -func (mc *MatchCreate) check() error { - if _, ok := mc.mutation.ShareCode(); !ok { +func (_c *MatchCreate) check() error { + if _, ok := _c.mutation.ShareCode(); !ok { return &ValidationError{Name: "share_code", err: errors.New(`ent: missing required field "Match.share_code"`)} } - if _, ok := mc.mutation.Date(); !ok { + if _, ok := _c.mutation.Date(); !ok { return &ValidationError{Name: "date", err: errors.New(`ent: missing required field "Match.date"`)} } - if _, ok := mc.mutation.ScoreTeamA(); !ok { + if _, ok := _c.mutation.ScoreTeamA(); !ok { return &ValidationError{Name: "score_team_a", err: errors.New(`ent: missing required field "Match.score_team_a"`)} } - if _, ok := mc.mutation.ScoreTeamB(); !ok { + if _, ok := _c.mutation.ScoreTeamB(); !ok { return &ValidationError{Name: "score_team_b", err: errors.New(`ent: missing required field "Match.score_team_b"`)} } - if _, ok := mc.mutation.Duration(); !ok { + if _, ok := _c.mutation.Duration(); !ok { return &ValidationError{Name: "duration", err: errors.New(`ent: missing required field "Match.duration"`)} } - if _, ok := mc.mutation.MatchResult(); !ok { + if _, ok := _c.mutation.MatchResult(); !ok { return &ValidationError{Name: "match_result", err: errors.New(`ent: missing required field "Match.match_result"`)} } - if _, ok := mc.mutation.MaxRounds(); !ok { + if _, ok := _c.mutation.MaxRounds(); !ok { return &ValidationError{Name: "max_rounds", err: errors.New(`ent: missing required field "Match.max_rounds"`)} } - if _, ok := mc.mutation.DemoParsed(); !ok { + if _, ok := _c.mutation.DemoParsed(); !ok { return &ValidationError{Name: "demo_parsed", err: errors.New(`ent: missing required field "Match.demo_parsed"`)} } - if _, ok := mc.mutation.VacPresent(); !ok { + if _, ok := _c.mutation.VacPresent(); !ok { return &ValidationError{Name: "vac_present", err: errors.New(`ent: missing required field "Match.vac_present"`)} } - if _, ok := mc.mutation.GamebanPresent(); !ok { + if _, ok := _c.mutation.GamebanPresent(); !ok { return &ValidationError{Name: "gameban_present", err: errors.New(`ent: missing required field "Match.gameban_present"`)} } return nil } -func (mc *MatchCreate) sqlSave(ctx context.Context) (*Match, error) { - if err := mc.check(); err != nil { +func (_c *MatchCreate) sqlSave(ctx context.Context) (*Match, error) { + if err := _c.check(); err != nil { return nil, err } - _node, _spec := mc.createSpec() - if err := sqlgraph.CreateNode(ctx, mc.driver, _spec); err != nil { + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -289,77 +289,77 @@ func (mc *MatchCreate) sqlSave(ctx context.Context) (*Match, error) { id := _spec.ID.Value.(int64) _node.ID = uint64(id) } - mc.mutation.id = &_node.ID - mc.mutation.done = true + _c.mutation.id = &_node.ID + _c.mutation.done = true return _node, nil } -func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) { +func (_c *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) { var ( - _node = &Match{config: mc.config} + _node = &Match{config: _c.config} _spec = sqlgraph.NewCreateSpec(match.Table, sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64)) ) - if id, ok := mc.mutation.ID(); ok { + if id, ok := _c.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id } - if value, ok := mc.mutation.ShareCode(); ok { + if value, ok := _c.mutation.ShareCode(); ok { _spec.SetField(match.FieldShareCode, field.TypeString, value) _node.ShareCode = value } - if value, ok := mc.mutation.Map(); ok { + if value, ok := _c.mutation.Map(); ok { _spec.SetField(match.FieldMap, field.TypeString, value) _node.Map = value } - if value, ok := mc.mutation.Date(); ok { + if value, ok := _c.mutation.Date(); ok { _spec.SetField(match.FieldDate, field.TypeTime, value) _node.Date = value } - if value, ok := mc.mutation.ScoreTeamA(); ok { + if value, ok := _c.mutation.ScoreTeamA(); ok { _spec.SetField(match.FieldScoreTeamA, field.TypeInt, value) _node.ScoreTeamA = value } - if value, ok := mc.mutation.ScoreTeamB(); ok { + if value, ok := _c.mutation.ScoreTeamB(); ok { _spec.SetField(match.FieldScoreTeamB, field.TypeInt, value) _node.ScoreTeamB = value } - if value, ok := mc.mutation.ReplayURL(); ok { + if value, ok := _c.mutation.ReplayURL(); ok { _spec.SetField(match.FieldReplayURL, field.TypeString, value) _node.ReplayURL = value } - if value, ok := mc.mutation.Duration(); ok { + if value, ok := _c.mutation.Duration(); ok { _spec.SetField(match.FieldDuration, field.TypeInt, value) _node.Duration = value } - if value, ok := mc.mutation.MatchResult(); ok { + if value, ok := _c.mutation.MatchResult(); ok { _spec.SetField(match.FieldMatchResult, field.TypeInt, value) _node.MatchResult = value } - if value, ok := mc.mutation.MaxRounds(); ok { + if value, ok := _c.mutation.MaxRounds(); ok { _spec.SetField(match.FieldMaxRounds, field.TypeInt, value) _node.MaxRounds = value } - if value, ok := mc.mutation.DemoParsed(); ok { + if value, ok := _c.mutation.DemoParsed(); ok { _spec.SetField(match.FieldDemoParsed, field.TypeBool, value) _node.DemoParsed = value } - if value, ok := mc.mutation.VacPresent(); ok { + if value, ok := _c.mutation.VacPresent(); ok { _spec.SetField(match.FieldVacPresent, field.TypeBool, value) _node.VacPresent = value } - if value, ok := mc.mutation.GamebanPresent(); ok { + if value, ok := _c.mutation.GamebanPresent(); ok { _spec.SetField(match.FieldGamebanPresent, field.TypeBool, value) _node.GamebanPresent = value } - if value, ok := mc.mutation.DecryptionKey(); ok { + if value, ok := _c.mutation.DecryptionKey(); ok { _spec.SetField(match.FieldDecryptionKey, field.TypeBytes, value) _node.DecryptionKey = value } - if value, ok := mc.mutation.TickRate(); ok { + if value, ok := _c.mutation.TickRate(); ok { _spec.SetField(match.FieldTickRate, field.TypeFloat64, value) _node.TickRate = value } - if nodes := mc.mutation.StatsIDs(); len(nodes) > 0 { + if nodes := _c.mutation.StatsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -375,7 +375,7 @@ func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := mc.mutation.PlayersIDs(); len(nodes) > 0 { + if nodes := _c.mutation.PlayersIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -397,17 +397,21 @@ func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) { // MatchCreateBulk is the builder for creating many Match entities in bulk. type MatchCreateBulk struct { config + err error builders []*MatchCreate } // Save creates the Match entities in the database. -func (mcb *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) { - specs := make([]*sqlgraph.CreateSpec, len(mcb.builders)) - nodes := make([]*Match, len(mcb.builders)) - mutators := make([]Mutator, len(mcb.builders)) - for i := range mcb.builders { +func (_c *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*Match, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { func(i int, root context.Context) { - builder := mcb.builders[i] + builder := _c.builders[i] builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*MatchMutation) @@ -421,11 +425,11 @@ func (mcb *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) { var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, mcb.builders[i+1].mutation) + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, mcb.driver, spec); err != nil { + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -449,7 +453,7 @@ func (mcb *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) { }(i, ctx) } if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, mcb.builders[0].mutation); err != nil { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { return nil, err } } @@ -457,8 +461,8 @@ func (mcb *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) { } // SaveX is like Save, but panics if an error occurs. -func (mcb *MatchCreateBulk) SaveX(ctx context.Context) []*Match { - v, err := mcb.Save(ctx) +func (_c *MatchCreateBulk) SaveX(ctx context.Context) []*Match { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -466,14 +470,14 @@ func (mcb *MatchCreateBulk) SaveX(ctx context.Context) []*Match { } // Exec executes the query. -func (mcb *MatchCreateBulk) Exec(ctx context.Context) error { - _, err := mcb.Save(ctx) +func (_c *MatchCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (mcb *MatchCreateBulk) ExecX(ctx context.Context) { - if err := mcb.Exec(ctx); err != nil { +func (_c *MatchCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } diff --git a/ent/match_delete.go b/ent/match_delete.go index f835307..f784918 100644 --- a/ent/match_delete.go +++ b/ent/match_delete.go @@ -20,56 +20,56 @@ type MatchDelete struct { } // Where appends a list predicates to the MatchDelete builder. -func (md *MatchDelete) Where(ps ...predicate.Match) *MatchDelete { - md.mutation.Where(ps...) - return md +func (_d *MatchDelete) Where(ps ...predicate.Match) *MatchDelete { + _d.mutation.Where(ps...) + return _d } // Exec executes the deletion query and returns how many vertices were deleted. -func (md *MatchDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, md.sqlExec, md.mutation, md.hooks) +func (_d *MatchDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) } // ExecX is like Exec, but panics if an error occurs. -func (md *MatchDelete) ExecX(ctx context.Context) int { - n, err := md.Exec(ctx) +func (_d *MatchDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) if err != nil { panic(err) } return n } -func (md *MatchDelete) sqlExec(ctx context.Context) (int, error) { +func (_d *MatchDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(match.Table, sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64)) - if ps := md.mutation.predicates; len(ps) > 0 { + if ps := _d.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - affected, err := sqlgraph.DeleteNodes(ctx, md.driver, _spec) + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } - md.mutation.done = true + _d.mutation.done = true return affected, err } // MatchDeleteOne is the builder for deleting a single Match entity. type MatchDeleteOne struct { - md *MatchDelete + _d *MatchDelete } // Where appends a list predicates to the MatchDelete builder. -func (mdo *MatchDeleteOne) Where(ps ...predicate.Match) *MatchDeleteOne { - mdo.md.mutation.Where(ps...) - return mdo +func (_d *MatchDeleteOne) Where(ps ...predicate.Match) *MatchDeleteOne { + _d._d.mutation.Where(ps...) + return _d } // Exec executes the deletion query. -func (mdo *MatchDeleteOne) Exec(ctx context.Context) error { - n, err := mdo.md.Exec(ctx) +func (_d *MatchDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) switch { case err != nil: return err @@ -81,8 +81,8 @@ func (mdo *MatchDeleteOne) Exec(ctx context.Context) error { } // ExecX is like Exec, but panics if an error occurs. -func (mdo *MatchDeleteOne) ExecX(ctx context.Context) { - if err := mdo.Exec(ctx); err != nil { +func (_d *MatchDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { panic(err) } } diff --git a/ent/match_query.go b/ent/match_query.go index fc7fa80..0ac2d60 100644 --- a/ent/match_query.go +++ b/ent/match_query.go @@ -8,6 +8,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -33,44 +34,44 @@ type MatchQuery struct { } // Where adds a new predicate for the MatchQuery builder. -func (mq *MatchQuery) Where(ps ...predicate.Match) *MatchQuery { - mq.predicates = append(mq.predicates, ps...) - return mq +func (_q *MatchQuery) Where(ps ...predicate.Match) *MatchQuery { + _q.predicates = append(_q.predicates, ps...) + return _q } // Limit the number of records to be returned by this query. -func (mq *MatchQuery) Limit(limit int) *MatchQuery { - mq.ctx.Limit = &limit - return mq +func (_q *MatchQuery) Limit(limit int) *MatchQuery { + _q.ctx.Limit = &limit + return _q } // Offset to start from. -func (mq *MatchQuery) Offset(offset int) *MatchQuery { - mq.ctx.Offset = &offset - return mq +func (_q *MatchQuery) Offset(offset int) *MatchQuery { + _q.ctx.Offset = &offset + return _q } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. -func (mq *MatchQuery) Unique(unique bool) *MatchQuery { - mq.ctx.Unique = &unique - return mq +func (_q *MatchQuery) Unique(unique bool) *MatchQuery { + _q.ctx.Unique = &unique + return _q } // Order specifies how the records should be ordered. -func (mq *MatchQuery) Order(o ...match.OrderOption) *MatchQuery { - mq.order = append(mq.order, o...) - return mq +func (_q *MatchQuery) Order(o ...match.OrderOption) *MatchQuery { + _q.order = append(_q.order, o...) + return _q } // QueryStats chains the current query on the "stats" edge. -func (mq *MatchQuery) QueryStats() *MatchPlayerQuery { - query := (&MatchPlayerClient{config: mq.config}).Query() +func (_q *MatchQuery) QueryStats() *MatchPlayerQuery { + query := (&MatchPlayerClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := mq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := mq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -79,20 +80,20 @@ func (mq *MatchQuery) QueryStats() *MatchPlayerQuery { sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, match.StatsTable, match.StatsColumn), ) - fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryPlayers chains the current query on the "players" edge. -func (mq *MatchQuery) QueryPlayers() *PlayerQuery { - query := (&PlayerClient{config: mq.config}).Query() +func (_q *MatchQuery) QueryPlayers() *PlayerQuery { + query := (&PlayerClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := mq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := mq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -101,7 +102,7 @@ func (mq *MatchQuery) QueryPlayers() *PlayerQuery { sqlgraph.To(player.Table, player.FieldID), sqlgraph.Edge(sqlgraph.M2M, true, match.PlayersTable, match.PlayersPrimaryKey...), ) - fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query @@ -109,8 +110,8 @@ func (mq *MatchQuery) QueryPlayers() *PlayerQuery { // First returns the first Match entity from the query. // Returns a *NotFoundError when no Match was found. -func (mq *MatchQuery) First(ctx context.Context) (*Match, error) { - nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, "First")) +func (_q *MatchQuery) First(ctx context.Context) (*Match, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -121,8 +122,8 @@ func (mq *MatchQuery) First(ctx context.Context) (*Match, error) { } // FirstX is like First, but panics if an error occurs. -func (mq *MatchQuery) FirstX(ctx context.Context) *Match { - node, err := mq.First(ctx) +func (_q *MatchQuery) FirstX(ctx context.Context) *Match { + node, err := _q.First(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -131,9 +132,9 @@ func (mq *MatchQuery) FirstX(ctx context.Context) *Match { // FirstID returns the first Match ID from the query. // Returns a *NotFoundError when no Match ID was found. -func (mq *MatchQuery) FirstID(ctx context.Context) (id uint64, err error) { +func (_q *MatchQuery) FirstID(ctx context.Context) (id uint64, err error) { var ids []uint64 - if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, "FirstID")); err != nil { + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -144,8 +145,8 @@ func (mq *MatchQuery) FirstID(ctx context.Context) (id uint64, err error) { } // FirstIDX is like FirstID, but panics if an error occurs. -func (mq *MatchQuery) FirstIDX(ctx context.Context) uint64 { - id, err := mq.FirstID(ctx) +func (_q *MatchQuery) FirstIDX(ctx context.Context) uint64 { + id, err := _q.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -155,8 +156,8 @@ func (mq *MatchQuery) FirstIDX(ctx context.Context) uint64 { // Only returns a single Match entity found by the query, ensuring it only returns one. // Returns a *NotSingularError when more than one Match entity is found. // Returns a *NotFoundError when no Match entities are found. -func (mq *MatchQuery) Only(ctx context.Context) (*Match, error) { - nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, "Only")) +func (_q *MatchQuery) Only(ctx context.Context) (*Match, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -171,8 +172,8 @@ func (mq *MatchQuery) Only(ctx context.Context) (*Match, error) { } // OnlyX is like Only, but panics if an error occurs. -func (mq *MatchQuery) OnlyX(ctx context.Context) *Match { - node, err := mq.Only(ctx) +func (_q *MatchQuery) OnlyX(ctx context.Context) *Match { + node, err := _q.Only(ctx) if err != nil { panic(err) } @@ -182,9 +183,9 @@ func (mq *MatchQuery) OnlyX(ctx context.Context) *Match { // OnlyID is like Only, but returns the only Match ID in the query. // Returns a *NotSingularError when more than one Match ID is found. // Returns a *NotFoundError when no entities are found. -func (mq *MatchQuery) OnlyID(ctx context.Context) (id uint64, err error) { +func (_q *MatchQuery) OnlyID(ctx context.Context) (id uint64, err error) { var ids []uint64 - if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, "OnlyID")); err != nil { + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -199,8 +200,8 @@ func (mq *MatchQuery) OnlyID(ctx context.Context) (id uint64, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (mq *MatchQuery) OnlyIDX(ctx context.Context) uint64 { - id, err := mq.OnlyID(ctx) +func (_q *MatchQuery) OnlyIDX(ctx context.Context) uint64 { + id, err := _q.OnlyID(ctx) if err != nil { panic(err) } @@ -208,18 +209,18 @@ func (mq *MatchQuery) OnlyIDX(ctx context.Context) uint64 { } // All executes the query and returns a list of Matches. -func (mq *MatchQuery) All(ctx context.Context) ([]*Match, error) { - ctx = setContextOp(ctx, mq.ctx, "All") - if err := mq.prepareQuery(ctx); err != nil { +func (_q *MatchQuery) All(ctx context.Context) ([]*Match, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { return nil, err } qr := querierAll[[]*Match, *MatchQuery]() - return withInterceptors[[]*Match](ctx, mq, qr, mq.inters) + return withInterceptors[[]*Match](ctx, _q, qr, _q.inters) } // AllX is like All, but panics if an error occurs. -func (mq *MatchQuery) AllX(ctx context.Context) []*Match { - nodes, err := mq.All(ctx) +func (_q *MatchQuery) AllX(ctx context.Context) []*Match { + nodes, err := _q.All(ctx) if err != nil { panic(err) } @@ -227,20 +228,20 @@ func (mq *MatchQuery) AllX(ctx context.Context) []*Match { } // IDs executes the query and returns a list of Match IDs. -func (mq *MatchQuery) IDs(ctx context.Context) (ids []uint64, err error) { - if mq.ctx.Unique == nil && mq.path != nil { - mq.Unique(true) +func (_q *MatchQuery) IDs(ctx context.Context) (ids []uint64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) } - ctx = setContextOp(ctx, mq.ctx, "IDs") - if err = mq.Select(match.FieldID).Scan(ctx, &ids); err != nil { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(match.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. -func (mq *MatchQuery) IDsX(ctx context.Context) []uint64 { - ids, err := mq.IDs(ctx) +func (_q *MatchQuery) IDsX(ctx context.Context) []uint64 { + ids, err := _q.IDs(ctx) if err != nil { panic(err) } @@ -248,17 +249,17 @@ func (mq *MatchQuery) IDsX(ctx context.Context) []uint64 { } // Count returns the count of the given query. -func (mq *MatchQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, mq.ctx, "Count") - if err := mq.prepareQuery(ctx); err != nil { +func (_q *MatchQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { return 0, err } - return withInterceptors[int](ctx, mq, querierCount[*MatchQuery](), mq.inters) + return withInterceptors[int](ctx, _q, querierCount[*MatchQuery](), _q.inters) } // CountX is like Count, but panics if an error occurs. -func (mq *MatchQuery) CountX(ctx context.Context) int { - count, err := mq.Count(ctx) +func (_q *MatchQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) if err != nil { panic(err) } @@ -266,9 +267,9 @@ func (mq *MatchQuery) CountX(ctx context.Context) int { } // Exist returns true if the query has elements in the graph. -func (mq *MatchQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, mq.ctx, "Exist") - switch _, err := mq.FirstID(ctx); { +func (_q *MatchQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { case IsNotFound(err): return false, nil case err != nil: @@ -279,8 +280,8 @@ func (mq *MatchQuery) Exist(ctx context.Context) (bool, error) { } // ExistX is like Exist, but panics if an error occurs. -func (mq *MatchQuery) ExistX(ctx context.Context) bool { - exist, err := mq.Exist(ctx) +func (_q *MatchQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) if err != nil { panic(err) } @@ -289,44 +290,45 @@ func (mq *MatchQuery) ExistX(ctx context.Context) bool { // Clone returns a duplicate of the MatchQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. -func (mq *MatchQuery) Clone() *MatchQuery { - if mq == nil { +func (_q *MatchQuery) Clone() *MatchQuery { + if _q == nil { return nil } return &MatchQuery{ - config: mq.config, - ctx: mq.ctx.Clone(), - order: append([]match.OrderOption{}, mq.order...), - inters: append([]Interceptor{}, mq.inters...), - predicates: append([]predicate.Match{}, mq.predicates...), - withStats: mq.withStats.Clone(), - withPlayers: mq.withPlayers.Clone(), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]match.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.Match{}, _q.predicates...), + withStats: _q.withStats.Clone(), + withPlayers: _q.withPlayers.Clone(), // clone intermediate query. - sql: mq.sql.Clone(), - path: mq.path, + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), } } // WithStats tells the query-builder to eager-load the nodes that are connected to // the "stats" edge. The optional arguments are used to configure the query builder of the edge. -func (mq *MatchQuery) WithStats(opts ...func(*MatchPlayerQuery)) *MatchQuery { - query := (&MatchPlayerClient{config: mq.config}).Query() +func (_q *MatchQuery) WithStats(opts ...func(*MatchPlayerQuery)) *MatchQuery { + query := (&MatchPlayerClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - mq.withStats = query - return mq + _q.withStats = query + return _q } // WithPlayers tells the query-builder to eager-load the nodes that are connected to // the "players" edge. The optional arguments are used to configure the query builder of the edge. -func (mq *MatchQuery) WithPlayers(opts ...func(*PlayerQuery)) *MatchQuery { - query := (&PlayerClient{config: mq.config}).Query() +func (_q *MatchQuery) WithPlayers(opts ...func(*PlayerQuery)) *MatchQuery { + query := (&PlayerClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - mq.withPlayers = query - return mq + _q.withPlayers = query + return _q } // GroupBy is used to group vertices by one or more fields/columns. @@ -343,10 +345,10 @@ 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 { - mq.ctx.Fields = append([]string{field}, fields...) - grbuild := &MatchGroupBy{build: mq} - grbuild.flds = &mq.ctx.Fields +func (_q *MatchQuery) GroupBy(field string, fields ...string) *MatchGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &MatchGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields grbuild.label = match.Label grbuild.scan = grbuild.Scan return grbuild @@ -364,84 +366,84 @@ 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.ctx.Fields = append(mq.ctx.Fields, fields...) - sbuild := &MatchSelect{MatchQuery: mq} +func (_q *MatchQuery) Select(fields ...string) *MatchSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &MatchSelect{MatchQuery: _q} sbuild.label = match.Label - sbuild.flds, sbuild.scan = &mq.ctx.Fields, sbuild.Scan + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan return sbuild } // Aggregate returns a MatchSelect configured with the given aggregations. -func (mq *MatchQuery) Aggregate(fns ...AggregateFunc) *MatchSelect { - return mq.Select().Aggregate(fns...) +func (_q *MatchQuery) Aggregate(fns ...AggregateFunc) *MatchSelect { + return _q.Select().Aggregate(fns...) } -func (mq *MatchQuery) prepareQuery(ctx context.Context) error { - for _, inter := range mq.inters { +func (_q *MatchQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { if inter == nil { return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") } if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, mq); err != nil { + if err := trv.Traverse(ctx, _q); err != nil { return err } } } - for _, f := range mq.ctx.Fields { + for _, f := range _q.ctx.Fields { if !match.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } - if mq.path != nil { - prev, err := mq.path(ctx) + if _q.path != nil { + prev, err := _q.path(ctx) if err != nil { return err } - mq.sql = prev + _q.sql = prev } return nil } -func (mq *MatchQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Match, error) { +func (_q *MatchQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Match, error) { var ( nodes = []*Match{} - _spec = mq.querySpec() + _spec = _q.querySpec() loadedTypes = [2]bool{ - mq.withStats != nil, - mq.withPlayers != nil, + _q.withStats != nil, + _q.withPlayers != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { return (*Match).scanValues(nil, columns) } _spec.Assign = func(columns []string, values []any) error { - node := &Match{config: mq.config} + node := &Match{config: _q.config} nodes = append(nodes, node) node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) } - if len(mq.modifiers) > 0 { - _spec.Modifiers = mq.modifiers + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } for i := range hooks { hooks[i](ctx, _spec) } - if err := sqlgraph.QueryNodes(ctx, mq.driver, _spec); err != nil { + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { return nil, err } if len(nodes) == 0 { return nodes, nil } - if query := mq.withStats; query != nil { - if err := mq.loadStats(ctx, query, nodes, + if query := _q.withStats; query != nil { + if err := _q.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 } } - if query := mq.withPlayers; query != nil { - if err := mq.loadPlayers(ctx, query, nodes, + if query := _q.withPlayers; query != nil { + if err := _q.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 @@ -450,7 +452,7 @@ func (mq *MatchQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Match, return nodes, nil } -func (mq *MatchQuery) loadStats(ctx context.Context, query *MatchPlayerQuery, nodes []*Match, init func(*Match), assign func(*Match, *MatchPlayer)) error { +func (_q *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 { @@ -480,7 +482,7 @@ func (mq *MatchQuery) loadStats(ctx context.Context, query *MatchPlayerQuery, no } return nil } -func (mq *MatchQuery) loadPlayers(ctx context.Context, query *PlayerQuery, nodes []*Match, init func(*Match), assign func(*Match, *Player)) error { +func (_q *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{}) @@ -542,27 +544,27 @@ func (mq *MatchQuery) loadPlayers(ctx context.Context, query *PlayerQuery, nodes return nil } -func (mq *MatchQuery) sqlCount(ctx context.Context) (int, error) { - _spec := mq.querySpec() - if len(mq.modifiers) > 0 { - _spec.Modifiers = mq.modifiers +func (_q *MatchQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } - _spec.Node.Columns = mq.ctx.Fields - if len(mq.ctx.Fields) > 0 { - _spec.Unique = mq.ctx.Unique != nil && *mq.ctx.Unique + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique } - return sqlgraph.CountNodes(ctx, mq.driver, _spec) + return sqlgraph.CountNodes(ctx, _q.driver, _spec) } -func (mq *MatchQuery) querySpec() *sqlgraph.QuerySpec { +func (_q *MatchQuery) querySpec() *sqlgraph.QuerySpec { _spec := sqlgraph.NewQuerySpec(match.Table, match.Columns, sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64)) - _spec.From = mq.sql - if unique := mq.ctx.Unique; unique != nil { + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { _spec.Unique = *unique - } else if mq.path != nil { + } else if _q.path != nil { _spec.Unique = true } - if fields := mq.ctx.Fields; len(fields) > 0 { + if fields := _q.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, match.FieldID) for i := range fields { @@ -571,20 +573,20 @@ func (mq *MatchQuery) querySpec() *sqlgraph.QuerySpec { } } } - if ps := mq.predicates; len(ps) > 0 { + if ps := _q.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if limit := mq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := mq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { _spec.Offset = *offset } - if ps := mq.order; len(ps) > 0 { + if ps := _q.order; len(ps) > 0 { _spec.Order = func(selector *sql.Selector) { for i := range ps { ps[i](selector) @@ -594,45 +596,45 @@ func (mq *MatchQuery) querySpec() *sqlgraph.QuerySpec { return _spec } -func (mq *MatchQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(mq.driver.Dialect()) +func (_q *MatchQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) t1 := builder.Table(match.Table) - columns := mq.ctx.Fields + columns := _q.ctx.Fields if len(columns) == 0 { columns = match.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) - if mq.sql != nil { - selector = mq.sql + if _q.sql != nil { + selector = _q.sql selector.Select(selector.Columns(columns...)...) } - if mq.ctx.Unique != nil && *mq.ctx.Unique { + if _q.ctx.Unique != nil && *_q.ctx.Unique { selector.Distinct() } - for _, m := range mq.modifiers { + for _, m := range _q.modifiers { m(selector) } - for _, p := range mq.predicates { + for _, p := range _q.predicates { p(selector) } - for _, p := range mq.order { + for _, p := range _q.order { p(selector) } - if offset := mq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { // limit is mandatory for offset clause. We start // with default value, and override it below if needed. selector.Offset(*offset).Limit(math.MaxInt32) } - if limit := mq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector } // Modify adds a query modifier for attaching custom logic to queries. -func (mq *MatchQuery) Modify(modifiers ...func(s *sql.Selector)) *MatchSelect { - mq.modifiers = append(mq.modifiers, modifiers...) - return mq.Select() +func (_q *MatchQuery) Modify(modifiers ...func(s *sql.Selector)) *MatchSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() } // MatchGroupBy is the group-by builder for Match entities. @@ -642,41 +644,41 @@ type MatchGroupBy struct { } // Aggregate adds the given aggregation functions to the group-by query. -func (mgb *MatchGroupBy) Aggregate(fns ...AggregateFunc) *MatchGroupBy { - mgb.fns = append(mgb.fns, fns...) - return mgb +func (_g *MatchGroupBy) Aggregate(fns ...AggregateFunc) *MatchGroupBy { + _g.fns = append(_g.fns, fns...) + return _g } // Scan applies the selector query and scans the result into the given value. -func (mgb *MatchGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, mgb.build.ctx, "GroupBy") - if err := mgb.build.prepareQuery(ctx); err != nil { +func (_g *MatchGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*MatchQuery, *MatchGroupBy](ctx, mgb.build, mgb, mgb.build.inters, v) + return scanWithInterceptors[*MatchQuery, *MatchGroupBy](ctx, _g.build, _g, _g.build.inters, v) } -func (mgb *MatchGroupBy) sqlScan(ctx context.Context, root *MatchQuery, v any) error { +func (_g *MatchGroupBy) sqlScan(ctx context.Context, root *MatchQuery, v any) error { selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(mgb.fns)) - for _, fn := range mgb.fns { + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { aggregation = append(aggregation, fn(selector)) } if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*mgb.flds)+len(mgb.fns)) - for _, f := range *mgb.flds { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { columns = append(columns, selector.C(f)) } columns = append(columns, aggregation...) selector.Select(columns...) } - selector.GroupBy(selector.Columns(*mgb.flds...)...) + selector.GroupBy(selector.Columns(*_g.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := mgb.build.driver.Query(ctx, query, args, rows); err != nil { + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -690,27 +692,27 @@ type MatchSelect struct { } // Aggregate adds the given aggregation functions to the selector query. -func (ms *MatchSelect) Aggregate(fns ...AggregateFunc) *MatchSelect { - ms.fns = append(ms.fns, fns...) - return ms +func (_s *MatchSelect) Aggregate(fns ...AggregateFunc) *MatchSelect { + _s.fns = append(_s.fns, fns...) + return _s } // Scan applies the selector query and scans the result into the given value. -func (ms *MatchSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ms.ctx, "Select") - if err := ms.prepareQuery(ctx); err != nil { +func (_s *MatchSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*MatchQuery, *MatchSelect](ctx, ms.MatchQuery, ms, ms.inters, v) + return scanWithInterceptors[*MatchQuery, *MatchSelect](ctx, _s.MatchQuery, _s, _s.inters, v) } -func (ms *MatchSelect) sqlScan(ctx context.Context, root *MatchQuery, v any) error { +func (_s *MatchSelect) sqlScan(ctx context.Context, root *MatchQuery, v any) error { selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(ms.fns)) - for _, fn := range ms.fns { + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { aggregation = append(aggregation, fn(selector)) } - switch n := len(*ms.selector.flds); { + switch n := len(*_s.selector.flds); { case n == 0 && len(aggregation) > 0: selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: @@ -718,7 +720,7 @@ func (ms *MatchSelect) sqlScan(ctx context.Context, root *MatchQuery, v any) err } rows := &sql.Rows{} query, args := selector.Query() - if err := ms.driver.Query(ctx, query, args, rows); err != nil { + if err := _s.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -726,7 +728,7 @@ func (ms *MatchSelect) sqlScan(ctx context.Context, root *MatchQuery, v any) err } // Modify adds a query modifier for attaching custom logic to queries. -func (ms *MatchSelect) Modify(modifiers ...func(s *sql.Selector)) *MatchSelect { - ms.modifiers = append(ms.modifiers, modifiers...) - return ms +func (_s *MatchSelect) Modify(modifiers ...func(s *sql.Selector)) *MatchSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s } diff --git a/ent/match_update.go b/ent/match_update.go index b854f06..53502d5 100644 --- a/ent/match_update.go +++ b/ent/match_update.go @@ -26,294 +26,350 @@ type MatchUpdate struct { } // Where appends a list predicates to the MatchUpdate builder. -func (mu *MatchUpdate) Where(ps ...predicate.Match) *MatchUpdate { - mu.mutation.Where(ps...) - return mu +func (_u *MatchUpdate) Where(ps ...predicate.Match) *MatchUpdate { + _u.mutation.Where(ps...) + return _u } // SetShareCode sets the "share_code" field. -func (mu *MatchUpdate) SetShareCode(s string) *MatchUpdate { - mu.mutation.SetShareCode(s) - return mu +func (_u *MatchUpdate) SetShareCode(v string) *MatchUpdate { + _u.mutation.SetShareCode(v) + return _u +} + +// SetNillableShareCode sets the "share_code" field if the given value is not nil. +func (_u *MatchUpdate) SetNillableShareCode(v *string) *MatchUpdate { + if v != nil { + _u.SetShareCode(*v) + } + return _u } // SetMap sets the "map" field. -func (mu *MatchUpdate) SetMap(s string) *MatchUpdate { - mu.mutation.SetMap(s) - return mu +func (_u *MatchUpdate) SetMap(v string) *MatchUpdate { + _u.mutation.SetMap(v) + return _u } // SetNillableMap sets the "map" field if the given value is not nil. -func (mu *MatchUpdate) SetNillableMap(s *string) *MatchUpdate { - if s != nil { - mu.SetMap(*s) +func (_u *MatchUpdate) SetNillableMap(v *string) *MatchUpdate { + if v != nil { + _u.SetMap(*v) } - return mu + return _u } // ClearMap clears the value of the "map" field. -func (mu *MatchUpdate) ClearMap() *MatchUpdate { - mu.mutation.ClearMap() - return mu +func (_u *MatchUpdate) ClearMap() *MatchUpdate { + _u.mutation.ClearMap() + return _u } // SetDate sets the "date" field. -func (mu *MatchUpdate) SetDate(t time.Time) *MatchUpdate { - mu.mutation.SetDate(t) - return mu +func (_u *MatchUpdate) SetDate(v time.Time) *MatchUpdate { + _u.mutation.SetDate(v) + return _u +} + +// SetNillableDate sets the "date" field if the given value is not nil. +func (_u *MatchUpdate) SetNillableDate(v *time.Time) *MatchUpdate { + if v != nil { + _u.SetDate(*v) + } + return _u } // SetScoreTeamA sets the "score_team_a" field. -func (mu *MatchUpdate) SetScoreTeamA(i int) *MatchUpdate { - mu.mutation.ResetScoreTeamA() - mu.mutation.SetScoreTeamA(i) - return mu +func (_u *MatchUpdate) SetScoreTeamA(v int) *MatchUpdate { + _u.mutation.ResetScoreTeamA() + _u.mutation.SetScoreTeamA(v) + return _u } -// AddScoreTeamA adds i to the "score_team_a" field. -func (mu *MatchUpdate) AddScoreTeamA(i int) *MatchUpdate { - mu.mutation.AddScoreTeamA(i) - return mu +// SetNillableScoreTeamA sets the "score_team_a" field if the given value is not nil. +func (_u *MatchUpdate) SetNillableScoreTeamA(v *int) *MatchUpdate { + if v != nil { + _u.SetScoreTeamA(*v) + } + return _u +} + +// AddScoreTeamA adds value to the "score_team_a" field. +func (_u *MatchUpdate) AddScoreTeamA(v int) *MatchUpdate { + _u.mutation.AddScoreTeamA(v) + return _u } // SetScoreTeamB sets the "score_team_b" field. -func (mu *MatchUpdate) SetScoreTeamB(i int) *MatchUpdate { - mu.mutation.ResetScoreTeamB() - mu.mutation.SetScoreTeamB(i) - return mu +func (_u *MatchUpdate) SetScoreTeamB(v int) *MatchUpdate { + _u.mutation.ResetScoreTeamB() + _u.mutation.SetScoreTeamB(v) + return _u } -// AddScoreTeamB adds i to the "score_team_b" field. -func (mu *MatchUpdate) AddScoreTeamB(i int) *MatchUpdate { - mu.mutation.AddScoreTeamB(i) - return mu +// SetNillableScoreTeamB sets the "score_team_b" field if the given value is not nil. +func (_u *MatchUpdate) SetNillableScoreTeamB(v *int) *MatchUpdate { + if v != nil { + _u.SetScoreTeamB(*v) + } + return _u +} + +// AddScoreTeamB adds value to the "score_team_b" field. +func (_u *MatchUpdate) AddScoreTeamB(v int) *MatchUpdate { + _u.mutation.AddScoreTeamB(v) + return _u } // SetReplayURL sets the "replay_url" field. -func (mu *MatchUpdate) SetReplayURL(s string) *MatchUpdate { - mu.mutation.SetReplayURL(s) - return mu +func (_u *MatchUpdate) SetReplayURL(v string) *MatchUpdate { + _u.mutation.SetReplayURL(v) + return _u } // SetNillableReplayURL sets the "replay_url" field if the given value is not nil. -func (mu *MatchUpdate) SetNillableReplayURL(s *string) *MatchUpdate { - if s != nil { - mu.SetReplayURL(*s) +func (_u *MatchUpdate) SetNillableReplayURL(v *string) *MatchUpdate { + if v != nil { + _u.SetReplayURL(*v) } - return mu + return _u } // ClearReplayURL clears the value of the "replay_url" field. -func (mu *MatchUpdate) ClearReplayURL() *MatchUpdate { - mu.mutation.ClearReplayURL() - return mu +func (_u *MatchUpdate) ClearReplayURL() *MatchUpdate { + _u.mutation.ClearReplayURL() + return _u } // SetDuration sets the "duration" field. -func (mu *MatchUpdate) SetDuration(i int) *MatchUpdate { - mu.mutation.ResetDuration() - mu.mutation.SetDuration(i) - return mu +func (_u *MatchUpdate) SetDuration(v int) *MatchUpdate { + _u.mutation.ResetDuration() + _u.mutation.SetDuration(v) + return _u } -// AddDuration adds i to the "duration" field. -func (mu *MatchUpdate) AddDuration(i int) *MatchUpdate { - mu.mutation.AddDuration(i) - return mu +// SetNillableDuration sets the "duration" field if the given value is not nil. +func (_u *MatchUpdate) SetNillableDuration(v *int) *MatchUpdate { + if v != nil { + _u.SetDuration(*v) + } + return _u +} + +// AddDuration adds value to the "duration" field. +func (_u *MatchUpdate) AddDuration(v int) *MatchUpdate { + _u.mutation.AddDuration(v) + return _u } // SetMatchResult sets the "match_result" field. -func (mu *MatchUpdate) SetMatchResult(i int) *MatchUpdate { - mu.mutation.ResetMatchResult() - mu.mutation.SetMatchResult(i) - return mu +func (_u *MatchUpdate) SetMatchResult(v int) *MatchUpdate { + _u.mutation.ResetMatchResult() + _u.mutation.SetMatchResult(v) + return _u } -// AddMatchResult adds i to the "match_result" field. -func (mu *MatchUpdate) AddMatchResult(i int) *MatchUpdate { - mu.mutation.AddMatchResult(i) - return mu +// SetNillableMatchResult sets the "match_result" field if the given value is not nil. +func (_u *MatchUpdate) SetNillableMatchResult(v *int) *MatchUpdate { + if v != nil { + _u.SetMatchResult(*v) + } + return _u +} + +// AddMatchResult adds value to the "match_result" field. +func (_u *MatchUpdate) AddMatchResult(v int) *MatchUpdate { + _u.mutation.AddMatchResult(v) + return _u } // SetMaxRounds sets the "max_rounds" field. -func (mu *MatchUpdate) SetMaxRounds(i int) *MatchUpdate { - mu.mutation.ResetMaxRounds() - mu.mutation.SetMaxRounds(i) - return mu +func (_u *MatchUpdate) SetMaxRounds(v int) *MatchUpdate { + _u.mutation.ResetMaxRounds() + _u.mutation.SetMaxRounds(v) + return _u } -// AddMaxRounds adds i to the "max_rounds" field. -func (mu *MatchUpdate) AddMaxRounds(i int) *MatchUpdate { - mu.mutation.AddMaxRounds(i) - return mu +// SetNillableMaxRounds sets the "max_rounds" field if the given value is not nil. +func (_u *MatchUpdate) SetNillableMaxRounds(v *int) *MatchUpdate { + if v != nil { + _u.SetMaxRounds(*v) + } + return _u +} + +// AddMaxRounds adds value to the "max_rounds" field. +func (_u *MatchUpdate) AddMaxRounds(v int) *MatchUpdate { + _u.mutation.AddMaxRounds(v) + return _u } // SetDemoParsed sets the "demo_parsed" field. -func (mu *MatchUpdate) SetDemoParsed(b bool) *MatchUpdate { - mu.mutation.SetDemoParsed(b) - return mu +func (_u *MatchUpdate) SetDemoParsed(v bool) *MatchUpdate { + _u.mutation.SetDemoParsed(v) + return _u } // SetNillableDemoParsed sets the "demo_parsed" field if the given value is not nil. -func (mu *MatchUpdate) SetNillableDemoParsed(b *bool) *MatchUpdate { - if b != nil { - mu.SetDemoParsed(*b) +func (_u *MatchUpdate) SetNillableDemoParsed(v *bool) *MatchUpdate { + if v != nil { + _u.SetDemoParsed(*v) } - return mu + return _u } // SetVacPresent sets the "vac_present" field. -func (mu *MatchUpdate) SetVacPresent(b bool) *MatchUpdate { - mu.mutation.SetVacPresent(b) - return mu +func (_u *MatchUpdate) SetVacPresent(v bool) *MatchUpdate { + _u.mutation.SetVacPresent(v) + return _u } // SetNillableVacPresent sets the "vac_present" field if the given value is not nil. -func (mu *MatchUpdate) SetNillableVacPresent(b *bool) *MatchUpdate { - if b != nil { - mu.SetVacPresent(*b) +func (_u *MatchUpdate) SetNillableVacPresent(v *bool) *MatchUpdate { + if v != nil { + _u.SetVacPresent(*v) } - return mu + return _u } // SetGamebanPresent sets the "gameban_present" field. -func (mu *MatchUpdate) SetGamebanPresent(b bool) *MatchUpdate { - mu.mutation.SetGamebanPresent(b) - return mu +func (_u *MatchUpdate) SetGamebanPresent(v bool) *MatchUpdate { + _u.mutation.SetGamebanPresent(v) + return _u } // SetNillableGamebanPresent sets the "gameban_present" field if the given value is not nil. -func (mu *MatchUpdate) SetNillableGamebanPresent(b *bool) *MatchUpdate { - if b != nil { - mu.SetGamebanPresent(*b) +func (_u *MatchUpdate) SetNillableGamebanPresent(v *bool) *MatchUpdate { + if v != nil { + _u.SetGamebanPresent(*v) } - return mu + return _u } // SetDecryptionKey sets the "decryption_key" field. -func (mu *MatchUpdate) SetDecryptionKey(b []byte) *MatchUpdate { - mu.mutation.SetDecryptionKey(b) - return mu +func (_u *MatchUpdate) SetDecryptionKey(v []byte) *MatchUpdate { + _u.mutation.SetDecryptionKey(v) + return _u } // ClearDecryptionKey clears the value of the "decryption_key" field. -func (mu *MatchUpdate) ClearDecryptionKey() *MatchUpdate { - mu.mutation.ClearDecryptionKey() - return mu +func (_u *MatchUpdate) ClearDecryptionKey() *MatchUpdate { + _u.mutation.ClearDecryptionKey() + return _u } // SetTickRate sets the "tick_rate" field. -func (mu *MatchUpdate) SetTickRate(f float64) *MatchUpdate { - mu.mutation.ResetTickRate() - mu.mutation.SetTickRate(f) - return mu +func (_u *MatchUpdate) SetTickRate(v float64) *MatchUpdate { + _u.mutation.ResetTickRate() + _u.mutation.SetTickRate(v) + return _u } // SetNillableTickRate sets the "tick_rate" field if the given value is not nil. -func (mu *MatchUpdate) SetNillableTickRate(f *float64) *MatchUpdate { - if f != nil { - mu.SetTickRate(*f) +func (_u *MatchUpdate) SetNillableTickRate(v *float64) *MatchUpdate { + if v != nil { + _u.SetTickRate(*v) } - return mu + return _u } -// AddTickRate adds f to the "tick_rate" field. -func (mu *MatchUpdate) AddTickRate(f float64) *MatchUpdate { - mu.mutation.AddTickRate(f) - return mu +// AddTickRate adds value to the "tick_rate" field. +func (_u *MatchUpdate) AddTickRate(v float64) *MatchUpdate { + _u.mutation.AddTickRate(v) + return _u } // ClearTickRate clears the value of the "tick_rate" field. -func (mu *MatchUpdate) ClearTickRate() *MatchUpdate { - mu.mutation.ClearTickRate() - return mu +func (_u *MatchUpdate) ClearTickRate() *MatchUpdate { + _u.mutation.ClearTickRate() + return _u } // AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs. -func (mu *MatchUpdate) AddStatIDs(ids ...int) *MatchUpdate { - mu.mutation.AddStatIDs(ids...) - return mu +func (_u *MatchUpdate) AddStatIDs(ids ...int) *MatchUpdate { + _u.mutation.AddStatIDs(ids...) + return _u } // AddStats adds the "stats" edges to the MatchPlayer entity. -func (mu *MatchUpdate) AddStats(m ...*MatchPlayer) *MatchUpdate { - ids := make([]int, len(m)) - for i := range m { - ids[i] = m[i].ID +func (_u *MatchUpdate) AddStats(v ...*MatchPlayer) *MatchUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mu.AddStatIDs(ids...) + return _u.AddStatIDs(ids...) } // AddPlayerIDs adds the "players" edge to the Player entity by IDs. -func (mu *MatchUpdate) AddPlayerIDs(ids ...uint64) *MatchUpdate { - mu.mutation.AddPlayerIDs(ids...) - return mu +func (_u *MatchUpdate) AddPlayerIDs(ids ...uint64) *MatchUpdate { + _u.mutation.AddPlayerIDs(ids...) + return _u } // AddPlayers adds the "players" edges to the Player entity. -func (mu *MatchUpdate) AddPlayers(p ...*Player) *MatchUpdate { - ids := make([]uint64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *MatchUpdate) AddPlayers(v ...*Player) *MatchUpdate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mu.AddPlayerIDs(ids...) + return _u.AddPlayerIDs(ids...) } // Mutation returns the MatchMutation object of the builder. -func (mu *MatchUpdate) Mutation() *MatchMutation { - return mu.mutation +func (_u *MatchUpdate) Mutation() *MatchMutation { + return _u.mutation } // ClearStats clears all "stats" edges to the MatchPlayer entity. -func (mu *MatchUpdate) ClearStats() *MatchUpdate { - mu.mutation.ClearStats() - return mu +func (_u *MatchUpdate) ClearStats() *MatchUpdate { + _u.mutation.ClearStats() + return _u } // RemoveStatIDs removes the "stats" edge to MatchPlayer entities by IDs. -func (mu *MatchUpdate) RemoveStatIDs(ids ...int) *MatchUpdate { - mu.mutation.RemoveStatIDs(ids...) - return mu +func (_u *MatchUpdate) RemoveStatIDs(ids ...int) *MatchUpdate { + _u.mutation.RemoveStatIDs(ids...) + return _u } // RemoveStats removes "stats" edges to MatchPlayer entities. -func (mu *MatchUpdate) RemoveStats(m ...*MatchPlayer) *MatchUpdate { - ids := make([]int, len(m)) - for i := range m { - ids[i] = m[i].ID +func (_u *MatchUpdate) RemoveStats(v ...*MatchPlayer) *MatchUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mu.RemoveStatIDs(ids...) + return _u.RemoveStatIDs(ids...) } // ClearPlayers clears all "players" edges to the Player entity. -func (mu *MatchUpdate) ClearPlayers() *MatchUpdate { - mu.mutation.ClearPlayers() - return mu +func (_u *MatchUpdate) ClearPlayers() *MatchUpdate { + _u.mutation.ClearPlayers() + return _u } // RemovePlayerIDs removes the "players" edge to Player entities by IDs. -func (mu *MatchUpdate) RemovePlayerIDs(ids ...uint64) *MatchUpdate { - mu.mutation.RemovePlayerIDs(ids...) - return mu +func (_u *MatchUpdate) RemovePlayerIDs(ids ...uint64) *MatchUpdate { + _u.mutation.RemovePlayerIDs(ids...) + return _u } // RemovePlayers removes "players" edges to Player entities. -func (mu *MatchUpdate) RemovePlayers(p ...*Player) *MatchUpdate { - ids := make([]uint64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *MatchUpdate) RemovePlayers(v ...*Player) *MatchUpdate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mu.RemovePlayerIDs(ids...) + return _u.RemovePlayerIDs(ids...) } // Save executes the query and returns the number of nodes affected by the update operation. -func (mu *MatchUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, mu.sqlSave, mu.mutation, mu.hooks) +func (_u *MatchUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (mu *MatchUpdate) SaveX(ctx context.Context) int { - affected, err := mu.Save(ctx) +func (_u *MatchUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) if err != nil { panic(err) } @@ -321,106 +377,106 @@ func (mu *MatchUpdate) SaveX(ctx context.Context) int { } // Exec executes the query. -func (mu *MatchUpdate) Exec(ctx context.Context) error { - _, err := mu.Save(ctx) +func (_u *MatchUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (mu *MatchUpdate) ExecX(ctx context.Context) { - if err := mu.Exec(ctx); err != nil { +func (_u *MatchUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // 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 (_u *MatchUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MatchUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) { +func (_u *MatchUpdate) sqlSave(ctx context.Context) (_node int, err error) { _spec := sqlgraph.NewUpdateSpec(match.Table, match.Columns, sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64)) - if ps := mu.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := mu.mutation.ShareCode(); ok { + if value, ok := _u.mutation.ShareCode(); ok { _spec.SetField(match.FieldShareCode, field.TypeString, value) } - if value, ok := mu.mutation.Map(); ok { + if value, ok := _u.mutation.Map(); ok { _spec.SetField(match.FieldMap, field.TypeString, value) } - if mu.mutation.MapCleared() { + if _u.mutation.MapCleared() { _spec.ClearField(match.FieldMap, field.TypeString) } - if value, ok := mu.mutation.Date(); ok { + if value, ok := _u.mutation.Date(); ok { _spec.SetField(match.FieldDate, field.TypeTime, value) } - if value, ok := mu.mutation.ScoreTeamA(); ok { + if value, ok := _u.mutation.ScoreTeamA(); ok { _spec.SetField(match.FieldScoreTeamA, field.TypeInt, value) } - if value, ok := mu.mutation.AddedScoreTeamA(); ok { + if value, ok := _u.mutation.AddedScoreTeamA(); ok { _spec.AddField(match.FieldScoreTeamA, field.TypeInt, value) } - if value, ok := mu.mutation.ScoreTeamB(); ok { + if value, ok := _u.mutation.ScoreTeamB(); ok { _spec.SetField(match.FieldScoreTeamB, field.TypeInt, value) } - if value, ok := mu.mutation.AddedScoreTeamB(); ok { + if value, ok := _u.mutation.AddedScoreTeamB(); ok { _spec.AddField(match.FieldScoreTeamB, field.TypeInt, value) } - if value, ok := mu.mutation.ReplayURL(); ok { + if value, ok := _u.mutation.ReplayURL(); ok { _spec.SetField(match.FieldReplayURL, field.TypeString, value) } - if mu.mutation.ReplayURLCleared() { + if _u.mutation.ReplayURLCleared() { _spec.ClearField(match.FieldReplayURL, field.TypeString) } - if value, ok := mu.mutation.Duration(); ok { + if value, ok := _u.mutation.Duration(); ok { _spec.SetField(match.FieldDuration, field.TypeInt, value) } - if value, ok := mu.mutation.AddedDuration(); ok { + if value, ok := _u.mutation.AddedDuration(); ok { _spec.AddField(match.FieldDuration, field.TypeInt, value) } - if value, ok := mu.mutation.MatchResult(); ok { + if value, ok := _u.mutation.MatchResult(); ok { _spec.SetField(match.FieldMatchResult, field.TypeInt, value) } - if value, ok := mu.mutation.AddedMatchResult(); ok { + if value, ok := _u.mutation.AddedMatchResult(); ok { _spec.AddField(match.FieldMatchResult, field.TypeInt, value) } - if value, ok := mu.mutation.MaxRounds(); ok { + if value, ok := _u.mutation.MaxRounds(); ok { _spec.SetField(match.FieldMaxRounds, field.TypeInt, value) } - if value, ok := mu.mutation.AddedMaxRounds(); ok { + if value, ok := _u.mutation.AddedMaxRounds(); ok { _spec.AddField(match.FieldMaxRounds, field.TypeInt, value) } - if value, ok := mu.mutation.DemoParsed(); ok { + if value, ok := _u.mutation.DemoParsed(); ok { _spec.SetField(match.FieldDemoParsed, field.TypeBool, value) } - if value, ok := mu.mutation.VacPresent(); ok { + if value, ok := _u.mutation.VacPresent(); ok { _spec.SetField(match.FieldVacPresent, field.TypeBool, value) } - if value, ok := mu.mutation.GamebanPresent(); ok { + if value, ok := _u.mutation.GamebanPresent(); ok { _spec.SetField(match.FieldGamebanPresent, field.TypeBool, value) } - if value, ok := mu.mutation.DecryptionKey(); ok { + if value, ok := _u.mutation.DecryptionKey(); ok { _spec.SetField(match.FieldDecryptionKey, field.TypeBytes, value) } - if mu.mutation.DecryptionKeyCleared() { + if _u.mutation.DecryptionKeyCleared() { _spec.ClearField(match.FieldDecryptionKey, field.TypeBytes) } - if value, ok := mu.mutation.TickRate(); ok { + if value, ok := _u.mutation.TickRate(); ok { _spec.SetField(match.FieldTickRate, field.TypeFloat64, value) } - if value, ok := mu.mutation.AddedTickRate(); ok { + if value, ok := _u.mutation.AddedTickRate(); ok { _spec.AddField(match.FieldTickRate, field.TypeFloat64, value) } - if mu.mutation.TickRateCleared() { + if _u.mutation.TickRateCleared() { _spec.ClearField(match.FieldTickRate, field.TypeFloat64) } - if mu.mutation.StatsCleared() { + if _u.mutation.StatsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -433,7 +489,7 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mu.mutation.RemovedStatsIDs(); len(nodes) > 0 && !mu.mutation.StatsCleared() { + if nodes := _u.mutation.RemovedStatsIDs(); len(nodes) > 0 && !_u.mutation.StatsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -449,7 +505,7 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mu.mutation.StatsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.StatsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -465,7 +521,7 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if mu.mutation.PlayersCleared() { + if _u.mutation.PlayersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -478,7 +534,7 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mu.mutation.RemovedPlayersIDs(); len(nodes) > 0 && !mu.mutation.PlayersCleared() { + if nodes := _u.mutation.RemovedPlayersIDs(); len(nodes) > 0 && !_u.mutation.PlayersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -494,7 +550,7 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mu.mutation.PlayersIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PlayersIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -510,8 +566,8 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(mu.modifiers...) - if n, err = sqlgraph.UpdateNodes(ctx, mu.driver, _spec); err != nil { + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{match.Label} } else if sqlgraph.IsConstraintError(err) { @@ -519,8 +575,8 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) { } return 0, err } - mu.mutation.done = true - return n, nil + _u.mutation.done = true + return _node, nil } // MatchUpdateOne is the builder for updating a single Match entity. @@ -533,301 +589,357 @@ type MatchUpdateOne struct { } // SetShareCode sets the "share_code" field. -func (muo *MatchUpdateOne) SetShareCode(s string) *MatchUpdateOne { - muo.mutation.SetShareCode(s) - return muo +func (_u *MatchUpdateOne) SetShareCode(v string) *MatchUpdateOne { + _u.mutation.SetShareCode(v) + return _u +} + +// SetNillableShareCode sets the "share_code" field if the given value is not nil. +func (_u *MatchUpdateOne) SetNillableShareCode(v *string) *MatchUpdateOne { + if v != nil { + _u.SetShareCode(*v) + } + return _u } // SetMap sets the "map" field. -func (muo *MatchUpdateOne) SetMap(s string) *MatchUpdateOne { - muo.mutation.SetMap(s) - return muo +func (_u *MatchUpdateOne) SetMap(v string) *MatchUpdateOne { + _u.mutation.SetMap(v) + return _u } // SetNillableMap sets the "map" field if the given value is not nil. -func (muo *MatchUpdateOne) SetNillableMap(s *string) *MatchUpdateOne { - if s != nil { - muo.SetMap(*s) +func (_u *MatchUpdateOne) SetNillableMap(v *string) *MatchUpdateOne { + if v != nil { + _u.SetMap(*v) } - return muo + return _u } // ClearMap clears the value of the "map" field. -func (muo *MatchUpdateOne) ClearMap() *MatchUpdateOne { - muo.mutation.ClearMap() - return muo +func (_u *MatchUpdateOne) ClearMap() *MatchUpdateOne { + _u.mutation.ClearMap() + return _u } // SetDate sets the "date" field. -func (muo *MatchUpdateOne) SetDate(t time.Time) *MatchUpdateOne { - muo.mutation.SetDate(t) - return muo +func (_u *MatchUpdateOne) SetDate(v time.Time) *MatchUpdateOne { + _u.mutation.SetDate(v) + return _u +} + +// SetNillableDate sets the "date" field if the given value is not nil. +func (_u *MatchUpdateOne) SetNillableDate(v *time.Time) *MatchUpdateOne { + if v != nil { + _u.SetDate(*v) + } + return _u } // SetScoreTeamA sets the "score_team_a" field. -func (muo *MatchUpdateOne) SetScoreTeamA(i int) *MatchUpdateOne { - muo.mutation.ResetScoreTeamA() - muo.mutation.SetScoreTeamA(i) - return muo +func (_u *MatchUpdateOne) SetScoreTeamA(v int) *MatchUpdateOne { + _u.mutation.ResetScoreTeamA() + _u.mutation.SetScoreTeamA(v) + return _u } -// AddScoreTeamA adds i to the "score_team_a" field. -func (muo *MatchUpdateOne) AddScoreTeamA(i int) *MatchUpdateOne { - muo.mutation.AddScoreTeamA(i) - return muo +// SetNillableScoreTeamA sets the "score_team_a" field if the given value is not nil. +func (_u *MatchUpdateOne) SetNillableScoreTeamA(v *int) *MatchUpdateOne { + if v != nil { + _u.SetScoreTeamA(*v) + } + return _u +} + +// AddScoreTeamA adds value to the "score_team_a" field. +func (_u *MatchUpdateOne) AddScoreTeamA(v int) *MatchUpdateOne { + _u.mutation.AddScoreTeamA(v) + return _u } // SetScoreTeamB sets the "score_team_b" field. -func (muo *MatchUpdateOne) SetScoreTeamB(i int) *MatchUpdateOne { - muo.mutation.ResetScoreTeamB() - muo.mutation.SetScoreTeamB(i) - return muo +func (_u *MatchUpdateOne) SetScoreTeamB(v int) *MatchUpdateOne { + _u.mutation.ResetScoreTeamB() + _u.mutation.SetScoreTeamB(v) + return _u } -// AddScoreTeamB adds i to the "score_team_b" field. -func (muo *MatchUpdateOne) AddScoreTeamB(i int) *MatchUpdateOne { - muo.mutation.AddScoreTeamB(i) - return muo +// SetNillableScoreTeamB sets the "score_team_b" field if the given value is not nil. +func (_u *MatchUpdateOne) SetNillableScoreTeamB(v *int) *MatchUpdateOne { + if v != nil { + _u.SetScoreTeamB(*v) + } + return _u +} + +// AddScoreTeamB adds value to the "score_team_b" field. +func (_u *MatchUpdateOne) AddScoreTeamB(v int) *MatchUpdateOne { + _u.mutation.AddScoreTeamB(v) + return _u } // SetReplayURL sets the "replay_url" field. -func (muo *MatchUpdateOne) SetReplayURL(s string) *MatchUpdateOne { - muo.mutation.SetReplayURL(s) - return muo +func (_u *MatchUpdateOne) SetReplayURL(v string) *MatchUpdateOne { + _u.mutation.SetReplayURL(v) + return _u } // SetNillableReplayURL sets the "replay_url" field if the given value is not nil. -func (muo *MatchUpdateOne) SetNillableReplayURL(s *string) *MatchUpdateOne { - if s != nil { - muo.SetReplayURL(*s) +func (_u *MatchUpdateOne) SetNillableReplayURL(v *string) *MatchUpdateOne { + if v != nil { + _u.SetReplayURL(*v) } - return muo + return _u } // ClearReplayURL clears the value of the "replay_url" field. -func (muo *MatchUpdateOne) ClearReplayURL() *MatchUpdateOne { - muo.mutation.ClearReplayURL() - return muo +func (_u *MatchUpdateOne) ClearReplayURL() *MatchUpdateOne { + _u.mutation.ClearReplayURL() + return _u } // SetDuration sets the "duration" field. -func (muo *MatchUpdateOne) SetDuration(i int) *MatchUpdateOne { - muo.mutation.ResetDuration() - muo.mutation.SetDuration(i) - return muo +func (_u *MatchUpdateOne) SetDuration(v int) *MatchUpdateOne { + _u.mutation.ResetDuration() + _u.mutation.SetDuration(v) + return _u } -// AddDuration adds i to the "duration" field. -func (muo *MatchUpdateOne) AddDuration(i int) *MatchUpdateOne { - muo.mutation.AddDuration(i) - return muo +// SetNillableDuration sets the "duration" field if the given value is not nil. +func (_u *MatchUpdateOne) SetNillableDuration(v *int) *MatchUpdateOne { + if v != nil { + _u.SetDuration(*v) + } + return _u +} + +// AddDuration adds value to the "duration" field. +func (_u *MatchUpdateOne) AddDuration(v int) *MatchUpdateOne { + _u.mutation.AddDuration(v) + return _u } // SetMatchResult sets the "match_result" field. -func (muo *MatchUpdateOne) SetMatchResult(i int) *MatchUpdateOne { - muo.mutation.ResetMatchResult() - muo.mutation.SetMatchResult(i) - return muo +func (_u *MatchUpdateOne) SetMatchResult(v int) *MatchUpdateOne { + _u.mutation.ResetMatchResult() + _u.mutation.SetMatchResult(v) + return _u } -// AddMatchResult adds i to the "match_result" field. -func (muo *MatchUpdateOne) AddMatchResult(i int) *MatchUpdateOne { - muo.mutation.AddMatchResult(i) - return muo +// SetNillableMatchResult sets the "match_result" field if the given value is not nil. +func (_u *MatchUpdateOne) SetNillableMatchResult(v *int) *MatchUpdateOne { + if v != nil { + _u.SetMatchResult(*v) + } + return _u +} + +// AddMatchResult adds value to the "match_result" field. +func (_u *MatchUpdateOne) AddMatchResult(v int) *MatchUpdateOne { + _u.mutation.AddMatchResult(v) + return _u } // SetMaxRounds sets the "max_rounds" field. -func (muo *MatchUpdateOne) SetMaxRounds(i int) *MatchUpdateOne { - muo.mutation.ResetMaxRounds() - muo.mutation.SetMaxRounds(i) - return muo +func (_u *MatchUpdateOne) SetMaxRounds(v int) *MatchUpdateOne { + _u.mutation.ResetMaxRounds() + _u.mutation.SetMaxRounds(v) + return _u } -// AddMaxRounds adds i to the "max_rounds" field. -func (muo *MatchUpdateOne) AddMaxRounds(i int) *MatchUpdateOne { - muo.mutation.AddMaxRounds(i) - return muo +// SetNillableMaxRounds sets the "max_rounds" field if the given value is not nil. +func (_u *MatchUpdateOne) SetNillableMaxRounds(v *int) *MatchUpdateOne { + if v != nil { + _u.SetMaxRounds(*v) + } + return _u +} + +// AddMaxRounds adds value to the "max_rounds" field. +func (_u *MatchUpdateOne) AddMaxRounds(v int) *MatchUpdateOne { + _u.mutation.AddMaxRounds(v) + return _u } // SetDemoParsed sets the "demo_parsed" field. -func (muo *MatchUpdateOne) SetDemoParsed(b bool) *MatchUpdateOne { - muo.mutation.SetDemoParsed(b) - return muo +func (_u *MatchUpdateOne) SetDemoParsed(v bool) *MatchUpdateOne { + _u.mutation.SetDemoParsed(v) + return _u } // SetNillableDemoParsed sets the "demo_parsed" field if the given value is not nil. -func (muo *MatchUpdateOne) SetNillableDemoParsed(b *bool) *MatchUpdateOne { - if b != nil { - muo.SetDemoParsed(*b) +func (_u *MatchUpdateOne) SetNillableDemoParsed(v *bool) *MatchUpdateOne { + if v != nil { + _u.SetDemoParsed(*v) } - return muo + return _u } // SetVacPresent sets the "vac_present" field. -func (muo *MatchUpdateOne) SetVacPresent(b bool) *MatchUpdateOne { - muo.mutation.SetVacPresent(b) - return muo +func (_u *MatchUpdateOne) SetVacPresent(v bool) *MatchUpdateOne { + _u.mutation.SetVacPresent(v) + return _u } // SetNillableVacPresent sets the "vac_present" field if the given value is not nil. -func (muo *MatchUpdateOne) SetNillableVacPresent(b *bool) *MatchUpdateOne { - if b != nil { - muo.SetVacPresent(*b) +func (_u *MatchUpdateOne) SetNillableVacPresent(v *bool) *MatchUpdateOne { + if v != nil { + _u.SetVacPresent(*v) } - return muo + return _u } // SetGamebanPresent sets the "gameban_present" field. -func (muo *MatchUpdateOne) SetGamebanPresent(b bool) *MatchUpdateOne { - muo.mutation.SetGamebanPresent(b) - return muo +func (_u *MatchUpdateOne) SetGamebanPresent(v bool) *MatchUpdateOne { + _u.mutation.SetGamebanPresent(v) + return _u } // SetNillableGamebanPresent sets the "gameban_present" field if the given value is not nil. -func (muo *MatchUpdateOne) SetNillableGamebanPresent(b *bool) *MatchUpdateOne { - if b != nil { - muo.SetGamebanPresent(*b) +func (_u *MatchUpdateOne) SetNillableGamebanPresent(v *bool) *MatchUpdateOne { + if v != nil { + _u.SetGamebanPresent(*v) } - return muo + return _u } // SetDecryptionKey sets the "decryption_key" field. -func (muo *MatchUpdateOne) SetDecryptionKey(b []byte) *MatchUpdateOne { - muo.mutation.SetDecryptionKey(b) - return muo +func (_u *MatchUpdateOne) SetDecryptionKey(v []byte) *MatchUpdateOne { + _u.mutation.SetDecryptionKey(v) + return _u } // ClearDecryptionKey clears the value of the "decryption_key" field. -func (muo *MatchUpdateOne) ClearDecryptionKey() *MatchUpdateOne { - muo.mutation.ClearDecryptionKey() - return muo +func (_u *MatchUpdateOne) ClearDecryptionKey() *MatchUpdateOne { + _u.mutation.ClearDecryptionKey() + return _u } // SetTickRate sets the "tick_rate" field. -func (muo *MatchUpdateOne) SetTickRate(f float64) *MatchUpdateOne { - muo.mutation.ResetTickRate() - muo.mutation.SetTickRate(f) - return muo +func (_u *MatchUpdateOne) SetTickRate(v float64) *MatchUpdateOne { + _u.mutation.ResetTickRate() + _u.mutation.SetTickRate(v) + return _u } // SetNillableTickRate sets the "tick_rate" field if the given value is not nil. -func (muo *MatchUpdateOne) SetNillableTickRate(f *float64) *MatchUpdateOne { - if f != nil { - muo.SetTickRate(*f) +func (_u *MatchUpdateOne) SetNillableTickRate(v *float64) *MatchUpdateOne { + if v != nil { + _u.SetTickRate(*v) } - return muo + return _u } -// AddTickRate adds f to the "tick_rate" field. -func (muo *MatchUpdateOne) AddTickRate(f float64) *MatchUpdateOne { - muo.mutation.AddTickRate(f) - return muo +// AddTickRate adds value to the "tick_rate" field. +func (_u *MatchUpdateOne) AddTickRate(v float64) *MatchUpdateOne { + _u.mutation.AddTickRate(v) + return _u } // ClearTickRate clears the value of the "tick_rate" field. -func (muo *MatchUpdateOne) ClearTickRate() *MatchUpdateOne { - muo.mutation.ClearTickRate() - return muo +func (_u *MatchUpdateOne) ClearTickRate() *MatchUpdateOne { + _u.mutation.ClearTickRate() + return _u } // AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs. -func (muo *MatchUpdateOne) AddStatIDs(ids ...int) *MatchUpdateOne { - muo.mutation.AddStatIDs(ids...) - return muo +func (_u *MatchUpdateOne) AddStatIDs(ids ...int) *MatchUpdateOne { + _u.mutation.AddStatIDs(ids...) + return _u } // AddStats adds the "stats" edges to the MatchPlayer entity. -func (muo *MatchUpdateOne) AddStats(m ...*MatchPlayer) *MatchUpdateOne { - ids := make([]int, len(m)) - for i := range m { - ids[i] = m[i].ID +func (_u *MatchUpdateOne) AddStats(v ...*MatchPlayer) *MatchUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return muo.AddStatIDs(ids...) + return _u.AddStatIDs(ids...) } // AddPlayerIDs adds the "players" edge to the Player entity by IDs. -func (muo *MatchUpdateOne) AddPlayerIDs(ids ...uint64) *MatchUpdateOne { - muo.mutation.AddPlayerIDs(ids...) - return muo +func (_u *MatchUpdateOne) AddPlayerIDs(ids ...uint64) *MatchUpdateOne { + _u.mutation.AddPlayerIDs(ids...) + return _u } // AddPlayers adds the "players" edges to the Player entity. -func (muo *MatchUpdateOne) AddPlayers(p ...*Player) *MatchUpdateOne { - ids := make([]uint64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *MatchUpdateOne) AddPlayers(v ...*Player) *MatchUpdateOne { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return muo.AddPlayerIDs(ids...) + return _u.AddPlayerIDs(ids...) } // Mutation returns the MatchMutation object of the builder. -func (muo *MatchUpdateOne) Mutation() *MatchMutation { - return muo.mutation +func (_u *MatchUpdateOne) Mutation() *MatchMutation { + return _u.mutation } // ClearStats clears all "stats" edges to the MatchPlayer entity. -func (muo *MatchUpdateOne) ClearStats() *MatchUpdateOne { - muo.mutation.ClearStats() - return muo +func (_u *MatchUpdateOne) ClearStats() *MatchUpdateOne { + _u.mutation.ClearStats() + return _u } // RemoveStatIDs removes the "stats" edge to MatchPlayer entities by IDs. -func (muo *MatchUpdateOne) RemoveStatIDs(ids ...int) *MatchUpdateOne { - muo.mutation.RemoveStatIDs(ids...) - return muo +func (_u *MatchUpdateOne) RemoveStatIDs(ids ...int) *MatchUpdateOne { + _u.mutation.RemoveStatIDs(ids...) + return _u } // RemoveStats removes "stats" edges to MatchPlayer entities. -func (muo *MatchUpdateOne) RemoveStats(m ...*MatchPlayer) *MatchUpdateOne { - ids := make([]int, len(m)) - for i := range m { - ids[i] = m[i].ID +func (_u *MatchUpdateOne) RemoveStats(v ...*MatchPlayer) *MatchUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return muo.RemoveStatIDs(ids...) + return _u.RemoveStatIDs(ids...) } // ClearPlayers clears all "players" edges to the Player entity. -func (muo *MatchUpdateOne) ClearPlayers() *MatchUpdateOne { - muo.mutation.ClearPlayers() - return muo +func (_u *MatchUpdateOne) ClearPlayers() *MatchUpdateOne { + _u.mutation.ClearPlayers() + return _u } // RemovePlayerIDs removes the "players" edge to Player entities by IDs. -func (muo *MatchUpdateOne) RemovePlayerIDs(ids ...uint64) *MatchUpdateOne { - muo.mutation.RemovePlayerIDs(ids...) - return muo +func (_u *MatchUpdateOne) RemovePlayerIDs(ids ...uint64) *MatchUpdateOne { + _u.mutation.RemovePlayerIDs(ids...) + return _u } // RemovePlayers removes "players" edges to Player entities. -func (muo *MatchUpdateOne) RemovePlayers(p ...*Player) *MatchUpdateOne { - ids := make([]uint64, len(p)) - for i := range p { - ids[i] = p[i].ID +func (_u *MatchUpdateOne) RemovePlayers(v ...*Player) *MatchUpdateOne { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return muo.RemovePlayerIDs(ids...) + return _u.RemovePlayerIDs(ids...) } // Where appends a list predicates to the MatchUpdate builder. -func (muo *MatchUpdateOne) Where(ps ...predicate.Match) *MatchUpdateOne { - muo.mutation.Where(ps...) - return muo +func (_u *MatchUpdateOne) Where(ps ...predicate.Match) *MatchUpdateOne { + _u.mutation.Where(ps...) + return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. -func (muo *MatchUpdateOne) Select(field string, fields ...string) *MatchUpdateOne { - muo.fields = append([]string{field}, fields...) - return muo +func (_u *MatchUpdateOne) Select(field string, fields ...string) *MatchUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u } // Save executes the query and returns the updated Match entity. -func (muo *MatchUpdateOne) Save(ctx context.Context) (*Match, error) { - return withHooks(ctx, muo.sqlSave, muo.mutation, muo.hooks) +func (_u *MatchUpdateOne) Save(ctx context.Context) (*Match, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (muo *MatchUpdateOne) SaveX(ctx context.Context) *Match { - node, err := muo.Save(ctx) +func (_u *MatchUpdateOne) SaveX(ctx context.Context) *Match { + node, err := _u.Save(ctx) if err != nil { panic(err) } @@ -835,32 +947,32 @@ func (muo *MatchUpdateOne) SaveX(ctx context.Context) *Match { } // Exec executes the query on the entity. -func (muo *MatchUpdateOne) Exec(ctx context.Context) error { - _, err := muo.Save(ctx) +func (_u *MatchUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (muo *MatchUpdateOne) ExecX(ctx context.Context) { - if err := muo.Exec(ctx); err != nil { +func (_u *MatchUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // 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 (_u *MatchUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MatchUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error) { +func (_u *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error) { _spec := sqlgraph.NewUpdateSpec(match.Table, match.Columns, sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64)) - id, ok := muo.mutation.ID() + id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Match.id" for update`)} } _spec.Node.ID.Value = id - if fields := muo.fields; len(fields) > 0 { + if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, match.FieldID) for _, f := range fields { @@ -872,86 +984,86 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error } } } - if ps := muo.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := muo.mutation.ShareCode(); ok { + if value, ok := _u.mutation.ShareCode(); ok { _spec.SetField(match.FieldShareCode, field.TypeString, value) } - if value, ok := muo.mutation.Map(); ok { + if value, ok := _u.mutation.Map(); ok { _spec.SetField(match.FieldMap, field.TypeString, value) } - if muo.mutation.MapCleared() { + if _u.mutation.MapCleared() { _spec.ClearField(match.FieldMap, field.TypeString) } - if value, ok := muo.mutation.Date(); ok { + if value, ok := _u.mutation.Date(); ok { _spec.SetField(match.FieldDate, field.TypeTime, value) } - if value, ok := muo.mutation.ScoreTeamA(); ok { + if value, ok := _u.mutation.ScoreTeamA(); ok { _spec.SetField(match.FieldScoreTeamA, field.TypeInt, value) } - if value, ok := muo.mutation.AddedScoreTeamA(); ok { + if value, ok := _u.mutation.AddedScoreTeamA(); ok { _spec.AddField(match.FieldScoreTeamA, field.TypeInt, value) } - if value, ok := muo.mutation.ScoreTeamB(); ok { + if value, ok := _u.mutation.ScoreTeamB(); ok { _spec.SetField(match.FieldScoreTeamB, field.TypeInt, value) } - if value, ok := muo.mutation.AddedScoreTeamB(); ok { + if value, ok := _u.mutation.AddedScoreTeamB(); ok { _spec.AddField(match.FieldScoreTeamB, field.TypeInt, value) } - if value, ok := muo.mutation.ReplayURL(); ok { + if value, ok := _u.mutation.ReplayURL(); ok { _spec.SetField(match.FieldReplayURL, field.TypeString, value) } - if muo.mutation.ReplayURLCleared() { + if _u.mutation.ReplayURLCleared() { _spec.ClearField(match.FieldReplayURL, field.TypeString) } - if value, ok := muo.mutation.Duration(); ok { + if value, ok := _u.mutation.Duration(); ok { _spec.SetField(match.FieldDuration, field.TypeInt, value) } - if value, ok := muo.mutation.AddedDuration(); ok { + if value, ok := _u.mutation.AddedDuration(); ok { _spec.AddField(match.FieldDuration, field.TypeInt, value) } - if value, ok := muo.mutation.MatchResult(); ok { + if value, ok := _u.mutation.MatchResult(); ok { _spec.SetField(match.FieldMatchResult, field.TypeInt, value) } - if value, ok := muo.mutation.AddedMatchResult(); ok { + if value, ok := _u.mutation.AddedMatchResult(); ok { _spec.AddField(match.FieldMatchResult, field.TypeInt, value) } - if value, ok := muo.mutation.MaxRounds(); ok { + if value, ok := _u.mutation.MaxRounds(); ok { _spec.SetField(match.FieldMaxRounds, field.TypeInt, value) } - if value, ok := muo.mutation.AddedMaxRounds(); ok { + if value, ok := _u.mutation.AddedMaxRounds(); ok { _spec.AddField(match.FieldMaxRounds, field.TypeInt, value) } - if value, ok := muo.mutation.DemoParsed(); ok { + if value, ok := _u.mutation.DemoParsed(); ok { _spec.SetField(match.FieldDemoParsed, field.TypeBool, value) } - if value, ok := muo.mutation.VacPresent(); ok { + if value, ok := _u.mutation.VacPresent(); ok { _spec.SetField(match.FieldVacPresent, field.TypeBool, value) } - if value, ok := muo.mutation.GamebanPresent(); ok { + if value, ok := _u.mutation.GamebanPresent(); ok { _spec.SetField(match.FieldGamebanPresent, field.TypeBool, value) } - if value, ok := muo.mutation.DecryptionKey(); ok { + if value, ok := _u.mutation.DecryptionKey(); ok { _spec.SetField(match.FieldDecryptionKey, field.TypeBytes, value) } - if muo.mutation.DecryptionKeyCleared() { + if _u.mutation.DecryptionKeyCleared() { _spec.ClearField(match.FieldDecryptionKey, field.TypeBytes) } - if value, ok := muo.mutation.TickRate(); ok { + if value, ok := _u.mutation.TickRate(); ok { _spec.SetField(match.FieldTickRate, field.TypeFloat64, value) } - if value, ok := muo.mutation.AddedTickRate(); ok { + if value, ok := _u.mutation.AddedTickRate(); ok { _spec.AddField(match.FieldTickRate, field.TypeFloat64, value) } - if muo.mutation.TickRateCleared() { + if _u.mutation.TickRateCleared() { _spec.ClearField(match.FieldTickRate, field.TypeFloat64) } - if muo.mutation.StatsCleared() { + if _u.mutation.StatsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -964,7 +1076,7 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := muo.mutation.RemovedStatsIDs(); len(nodes) > 0 && !muo.mutation.StatsCleared() { + if nodes := _u.mutation.RemovedStatsIDs(); len(nodes) > 0 && !_u.mutation.StatsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -980,7 +1092,7 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := muo.mutation.StatsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.StatsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -996,7 +1108,7 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if muo.mutation.PlayersCleared() { + if _u.mutation.PlayersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -1009,7 +1121,7 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := muo.mutation.RemovedPlayersIDs(); len(nodes) > 0 && !muo.mutation.PlayersCleared() { + if nodes := _u.mutation.RemovedPlayersIDs(); len(nodes) > 0 && !_u.mutation.PlayersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -1025,7 +1137,7 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := muo.mutation.PlayersIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PlayersIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: true, @@ -1041,11 +1153,11 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(muo.modifiers...) - _node = &Match{config: muo.config} + _spec.AddModifiers(_u.modifiers...) + _node = &Match{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, muo.driver, _spec); err != nil { + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{match.Label} } else if sqlgraph.IsConstraintError(err) { @@ -1053,6 +1165,6 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error } return nil, err } - muo.mutation.done = true + _u.mutation.done = true return _node, nil } diff --git a/ent/matchplayer.go b/ent/matchplayer.go index f16b811..520e2ba 100644 --- a/ent/matchplayer.go +++ b/ent/matchplayer.go @@ -112,12 +112,10 @@ type MatchPlayerEdges struct { // MatchesOrErr returns the Matches value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e MatchPlayerEdges) MatchesOrErr() (*Match, error) { - if e.loadedTypes[0] { - if e.Matches == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: match.Label} - } + if e.Matches != nil { return e.Matches, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: match.Label} } return nil, &NotLoadedError{edge: "matches"} } @@ -125,12 +123,10 @@ func (e MatchPlayerEdges) MatchesOrErr() (*Match, error) { // PlayersOrErr returns the Players value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e MatchPlayerEdges) PlayersOrErr() (*Player, error) { - if e.loadedTypes[1] { - if e.Players == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: player.Label} - } + if e.Players != nil { return e.Players, nil + } else if e.loadedTypes[1] { + return nil, &NotFoundError{label: player.Label} } return nil, &NotLoadedError{edge: "players"} } @@ -191,7 +187,7 @@ func (*MatchPlayer) scanValues(columns []string) ([]any, error) { // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the MatchPlayer fields. -func (mp *MatchPlayer) assignValues(columns []string, values []any) error { +func (_m *MatchPlayer) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } @@ -202,207 +198,207 @@ func (mp *MatchPlayer) assignValues(columns []string, values []any) error { if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - mp.ID = int(value.Int64) + _m.ID = int(value.Int64) case matchplayer.FieldTeamID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field team_id", values[i]) } else if value.Valid { - mp.TeamID = int(value.Int64) + _m.TeamID = int(value.Int64) } case matchplayer.FieldKills: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field kills", values[i]) } else if value.Valid { - mp.Kills = int(value.Int64) + _m.Kills = int(value.Int64) } case matchplayer.FieldDeaths: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field deaths", values[i]) } else if value.Valid { - mp.Deaths = int(value.Int64) + _m.Deaths = int(value.Int64) } case matchplayer.FieldAssists: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field assists", values[i]) } else if value.Valid { - mp.Assists = int(value.Int64) + _m.Assists = int(value.Int64) } case matchplayer.FieldHeadshot: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field headshot", values[i]) } else if value.Valid { - mp.Headshot = int(value.Int64) + _m.Headshot = int(value.Int64) } case matchplayer.FieldMvp: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field mvp", values[i]) } else if value.Valid { - mp.Mvp = uint(value.Int64) + _m.Mvp = uint(value.Int64) } case matchplayer.FieldScore: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field score", values[i]) } else if value.Valid { - mp.Score = int(value.Int64) + _m.Score = int(value.Int64) } case matchplayer.FieldRankNew: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field rank_new", values[i]) } else if value.Valid { - mp.RankNew = int(value.Int64) + _m.RankNew = int(value.Int64) } case matchplayer.FieldRankOld: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field rank_old", values[i]) } else if value.Valid { - mp.RankOld = int(value.Int64) + _m.RankOld = int(value.Int64) } case matchplayer.FieldMk2: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field mk_2", values[i]) } else if value.Valid { - mp.Mk2 = uint(value.Int64) + _m.Mk2 = uint(value.Int64) } case matchplayer.FieldMk3: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field mk_3", values[i]) } else if value.Valid { - mp.Mk3 = uint(value.Int64) + _m.Mk3 = uint(value.Int64) } case matchplayer.FieldMk4: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field mk_4", values[i]) } else if value.Valid { - mp.Mk4 = uint(value.Int64) + _m.Mk4 = uint(value.Int64) } case matchplayer.FieldMk5: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field mk_5", values[i]) } else if value.Valid { - mp.Mk5 = uint(value.Int64) + _m.Mk5 = uint(value.Int64) } case matchplayer.FieldDmgEnemy: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field dmg_enemy", values[i]) } else if value.Valid { - mp.DmgEnemy = uint(value.Int64) + _m.DmgEnemy = uint(value.Int64) } case matchplayer.FieldDmgTeam: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field dmg_team", values[i]) } else if value.Valid { - mp.DmgTeam = uint(value.Int64) + _m.DmgTeam = uint(value.Int64) } case matchplayer.FieldUdHe: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field ud_he", values[i]) } else if value.Valid { - mp.UdHe = uint(value.Int64) + _m.UdHe = uint(value.Int64) } case matchplayer.FieldUdFlames: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field ud_flames", values[i]) } else if value.Valid { - mp.UdFlames = uint(value.Int64) + _m.UdFlames = uint(value.Int64) } case matchplayer.FieldUdFlash: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field ud_flash", values[i]) } else if value.Valid { - mp.UdFlash = uint(value.Int64) + _m.UdFlash = uint(value.Int64) } case matchplayer.FieldUdDecoy: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field ud_decoy", values[i]) } else if value.Valid { - mp.UdDecoy = uint(value.Int64) + _m.UdDecoy = uint(value.Int64) } case matchplayer.FieldUdSmoke: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field ud_smoke", values[i]) } else if value.Valid { - mp.UdSmoke = uint(value.Int64) + _m.UdSmoke = uint(value.Int64) } case matchplayer.FieldCrosshair: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field crosshair", values[i]) } else if value.Valid { - mp.Crosshair = value.String + _m.Crosshair = value.String } case matchplayer.FieldColor: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field color", values[i]) } else if value.Valid { - mp.Color = matchplayer.Color(value.String) + _m.Color = matchplayer.Color(value.String) } case matchplayer.FieldKast: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field kast", values[i]) } else if value.Valid { - mp.Kast = int(value.Int64) + _m.Kast = int(value.Int64) } case matchplayer.FieldFlashDurationSelf: if value, ok := values[i].(*sql.NullFloat64); !ok { return fmt.Errorf("unexpected type %T for field flash_duration_self", values[i]) } else if value.Valid { - mp.FlashDurationSelf = float32(value.Float64) + _m.FlashDurationSelf = float32(value.Float64) } case matchplayer.FieldFlashDurationTeam: if value, ok := values[i].(*sql.NullFloat64); !ok { return fmt.Errorf("unexpected type %T for field flash_duration_team", values[i]) } else if value.Valid { - mp.FlashDurationTeam = float32(value.Float64) + _m.FlashDurationTeam = float32(value.Float64) } case matchplayer.FieldFlashDurationEnemy: if value, ok := values[i].(*sql.NullFloat64); !ok { return fmt.Errorf("unexpected type %T for field flash_duration_enemy", values[i]) } else if value.Valid { - mp.FlashDurationEnemy = float32(value.Float64) + _m.FlashDurationEnemy = float32(value.Float64) } case matchplayer.FieldFlashTotalSelf: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field flash_total_self", values[i]) } else if value.Valid { - mp.FlashTotalSelf = uint(value.Int64) + _m.FlashTotalSelf = uint(value.Int64) } case matchplayer.FieldFlashTotalTeam: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field flash_total_team", values[i]) } else if value.Valid { - mp.FlashTotalTeam = uint(value.Int64) + _m.FlashTotalTeam = uint(value.Int64) } case matchplayer.FieldFlashTotalEnemy: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field flash_total_enemy", values[i]) } else if value.Valid { - mp.FlashTotalEnemy = uint(value.Int64) + _m.FlashTotalEnemy = uint(value.Int64) } case matchplayer.FieldMatchStats: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field match_stats", values[i]) } else if value.Valid { - mp.MatchStats = uint64(value.Int64) + _m.MatchStats = uint64(value.Int64) } case matchplayer.FieldPlayerStats: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field player_stats", values[i]) } else if value.Valid { - mp.PlayerStats = uint64(value.Int64) + _m.PlayerStats = uint64(value.Int64) } case matchplayer.FieldFlashAssists: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field flash_assists", values[i]) } else if value.Valid { - mp.FlashAssists = int(value.Int64) + _m.FlashAssists = int(value.Int64) } case matchplayer.FieldAvgPing: if value, ok := values[i].(*sql.NullFloat64); !ok { return fmt.Errorf("unexpected type %T for field avg_ping", values[i]) } else if value.Valid { - mp.AvgPing = value.Float64 + _m.AvgPing = value.Float64 } default: - mp.selectValues.Set(columns[i], values[i]) + _m.selectValues.Set(columns[i], values[i]) } } return nil @@ -410,161 +406,161 @@ func (mp *MatchPlayer) assignValues(columns []string, values []any) error { // Value returns the ent.Value that was dynamically selected and assigned to the MatchPlayer. // This includes values selected through modifiers, order, etc. -func (mp *MatchPlayer) Value(name string) (ent.Value, error) { - return mp.selectValues.Get(name) +func (_m *MatchPlayer) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) } // QueryMatches queries the "matches" edge of the MatchPlayer entity. -func (mp *MatchPlayer) QueryMatches() *MatchQuery { - return NewMatchPlayerClient(mp.config).QueryMatches(mp) +func (_m *MatchPlayer) QueryMatches() *MatchQuery { + return NewMatchPlayerClient(_m.config).QueryMatches(_m) } // QueryPlayers queries the "players" edge of the MatchPlayer entity. -func (mp *MatchPlayer) QueryPlayers() *PlayerQuery { - return NewMatchPlayerClient(mp.config).QueryPlayers(mp) +func (_m *MatchPlayer) QueryPlayers() *PlayerQuery { + return NewMatchPlayerClient(_m.config).QueryPlayers(_m) } // QueryWeaponStats queries the "weapon_stats" edge of the MatchPlayer entity. -func (mp *MatchPlayer) QueryWeaponStats() *WeaponQuery { - return NewMatchPlayerClient(mp.config).QueryWeaponStats(mp) +func (_m *MatchPlayer) QueryWeaponStats() *WeaponQuery { + return NewMatchPlayerClient(_m.config).QueryWeaponStats(_m) } // QueryRoundStats queries the "round_stats" edge of the MatchPlayer entity. -func (mp *MatchPlayer) QueryRoundStats() *RoundStatsQuery { - return NewMatchPlayerClient(mp.config).QueryRoundStats(mp) +func (_m *MatchPlayer) QueryRoundStats() *RoundStatsQuery { + return NewMatchPlayerClient(_m.config).QueryRoundStats(_m) } // QuerySpray queries the "spray" edge of the MatchPlayer entity. -func (mp *MatchPlayer) QuerySpray() *SprayQuery { - return NewMatchPlayerClient(mp.config).QuerySpray(mp) +func (_m *MatchPlayer) QuerySpray() *SprayQuery { + return NewMatchPlayerClient(_m.config).QuerySpray(_m) } // QueryMessages queries the "messages" edge of the MatchPlayer entity. -func (mp *MatchPlayer) QueryMessages() *MessagesQuery { - return NewMatchPlayerClient(mp.config).QueryMessages(mp) +func (_m *MatchPlayer) QueryMessages() *MessagesQuery { + return NewMatchPlayerClient(_m.config).QueryMessages(_m) } // Update returns a builder for updating this MatchPlayer. // Note that you need to call MatchPlayer.Unwrap() before calling this method if this MatchPlayer // was returned from a transaction, and the transaction was committed or rolled back. -func (mp *MatchPlayer) Update() *MatchPlayerUpdateOne { - return NewMatchPlayerClient(mp.config).UpdateOne(mp) +func (_m *MatchPlayer) Update() *MatchPlayerUpdateOne { + return NewMatchPlayerClient(_m.config).UpdateOne(_m) } // 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) +func (_m *MatchPlayer) Unwrap() *MatchPlayer { + _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: MatchPlayer is not a transactional entity") } - mp.config.driver = _tx.drv - return mp + _m.config.driver = _tx.drv + return _m } // String implements the fmt.Stringer. -func (mp *MatchPlayer) String() string { +func (_m *MatchPlayer) String() string { var builder strings.Builder builder.WriteString("MatchPlayer(") - builder.WriteString(fmt.Sprintf("id=%v, ", mp.ID)) + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("team_id=") - builder.WriteString(fmt.Sprintf("%v", mp.TeamID)) + builder.WriteString(fmt.Sprintf("%v", _m.TeamID)) builder.WriteString(", ") builder.WriteString("kills=") - builder.WriteString(fmt.Sprintf("%v", mp.Kills)) + builder.WriteString(fmt.Sprintf("%v", _m.Kills)) builder.WriteString(", ") builder.WriteString("deaths=") - builder.WriteString(fmt.Sprintf("%v", mp.Deaths)) + builder.WriteString(fmt.Sprintf("%v", _m.Deaths)) builder.WriteString(", ") builder.WriteString("assists=") - builder.WriteString(fmt.Sprintf("%v", mp.Assists)) + builder.WriteString(fmt.Sprintf("%v", _m.Assists)) builder.WriteString(", ") builder.WriteString("headshot=") - builder.WriteString(fmt.Sprintf("%v", mp.Headshot)) + builder.WriteString(fmt.Sprintf("%v", _m.Headshot)) builder.WriteString(", ") builder.WriteString("mvp=") - builder.WriteString(fmt.Sprintf("%v", mp.Mvp)) + builder.WriteString(fmt.Sprintf("%v", _m.Mvp)) builder.WriteString(", ") builder.WriteString("score=") - builder.WriteString(fmt.Sprintf("%v", mp.Score)) + builder.WriteString(fmt.Sprintf("%v", _m.Score)) builder.WriteString(", ") builder.WriteString("rank_new=") - builder.WriteString(fmt.Sprintf("%v", mp.RankNew)) + builder.WriteString(fmt.Sprintf("%v", _m.RankNew)) builder.WriteString(", ") builder.WriteString("rank_old=") - builder.WriteString(fmt.Sprintf("%v", mp.RankOld)) + builder.WriteString(fmt.Sprintf("%v", _m.RankOld)) builder.WriteString(", ") builder.WriteString("mk_2=") - builder.WriteString(fmt.Sprintf("%v", mp.Mk2)) + builder.WriteString(fmt.Sprintf("%v", _m.Mk2)) builder.WriteString(", ") builder.WriteString("mk_3=") - builder.WriteString(fmt.Sprintf("%v", mp.Mk3)) + builder.WriteString(fmt.Sprintf("%v", _m.Mk3)) builder.WriteString(", ") builder.WriteString("mk_4=") - builder.WriteString(fmt.Sprintf("%v", mp.Mk4)) + builder.WriteString(fmt.Sprintf("%v", _m.Mk4)) builder.WriteString(", ") builder.WriteString("mk_5=") - builder.WriteString(fmt.Sprintf("%v", mp.Mk5)) + builder.WriteString(fmt.Sprintf("%v", _m.Mk5)) builder.WriteString(", ") builder.WriteString("dmg_enemy=") - builder.WriteString(fmt.Sprintf("%v", mp.DmgEnemy)) + builder.WriteString(fmt.Sprintf("%v", _m.DmgEnemy)) builder.WriteString(", ") builder.WriteString("dmg_team=") - builder.WriteString(fmt.Sprintf("%v", mp.DmgTeam)) + builder.WriteString(fmt.Sprintf("%v", _m.DmgTeam)) builder.WriteString(", ") builder.WriteString("ud_he=") - builder.WriteString(fmt.Sprintf("%v", mp.UdHe)) + builder.WriteString(fmt.Sprintf("%v", _m.UdHe)) builder.WriteString(", ") builder.WriteString("ud_flames=") - builder.WriteString(fmt.Sprintf("%v", mp.UdFlames)) + builder.WriteString(fmt.Sprintf("%v", _m.UdFlames)) builder.WriteString(", ") builder.WriteString("ud_flash=") - builder.WriteString(fmt.Sprintf("%v", mp.UdFlash)) + builder.WriteString(fmt.Sprintf("%v", _m.UdFlash)) builder.WriteString(", ") builder.WriteString("ud_decoy=") - builder.WriteString(fmt.Sprintf("%v", mp.UdDecoy)) + builder.WriteString(fmt.Sprintf("%v", _m.UdDecoy)) builder.WriteString(", ") builder.WriteString("ud_smoke=") - builder.WriteString(fmt.Sprintf("%v", mp.UdSmoke)) + builder.WriteString(fmt.Sprintf("%v", _m.UdSmoke)) builder.WriteString(", ") builder.WriteString("crosshair=") - builder.WriteString(mp.Crosshair) + builder.WriteString(_m.Crosshair) builder.WriteString(", ") builder.WriteString("color=") - builder.WriteString(fmt.Sprintf("%v", mp.Color)) + builder.WriteString(fmt.Sprintf("%v", _m.Color)) builder.WriteString(", ") builder.WriteString("kast=") - builder.WriteString(fmt.Sprintf("%v", mp.Kast)) + builder.WriteString(fmt.Sprintf("%v", _m.Kast)) builder.WriteString(", ") builder.WriteString("flash_duration_self=") - builder.WriteString(fmt.Sprintf("%v", mp.FlashDurationSelf)) + builder.WriteString(fmt.Sprintf("%v", _m.FlashDurationSelf)) builder.WriteString(", ") builder.WriteString("flash_duration_team=") - builder.WriteString(fmt.Sprintf("%v", mp.FlashDurationTeam)) + builder.WriteString(fmt.Sprintf("%v", _m.FlashDurationTeam)) builder.WriteString(", ") builder.WriteString("flash_duration_enemy=") - builder.WriteString(fmt.Sprintf("%v", mp.FlashDurationEnemy)) + builder.WriteString(fmt.Sprintf("%v", _m.FlashDurationEnemy)) builder.WriteString(", ") builder.WriteString("flash_total_self=") - builder.WriteString(fmt.Sprintf("%v", mp.FlashTotalSelf)) + builder.WriteString(fmt.Sprintf("%v", _m.FlashTotalSelf)) builder.WriteString(", ") builder.WriteString("flash_total_team=") - builder.WriteString(fmt.Sprintf("%v", mp.FlashTotalTeam)) + builder.WriteString(fmt.Sprintf("%v", _m.FlashTotalTeam)) builder.WriteString(", ") builder.WriteString("flash_total_enemy=") - builder.WriteString(fmt.Sprintf("%v", mp.FlashTotalEnemy)) + builder.WriteString(fmt.Sprintf("%v", _m.FlashTotalEnemy)) builder.WriteString(", ") builder.WriteString("match_stats=") - builder.WriteString(fmt.Sprintf("%v", mp.MatchStats)) + builder.WriteString(fmt.Sprintf("%v", _m.MatchStats)) builder.WriteString(", ") builder.WriteString("player_stats=") - builder.WriteString(fmt.Sprintf("%v", mp.PlayerStats)) + builder.WriteString(fmt.Sprintf("%v", _m.PlayerStats)) builder.WriteString(", ") builder.WriteString("flash_assists=") - builder.WriteString(fmt.Sprintf("%v", mp.FlashAssists)) + builder.WriteString(fmt.Sprintf("%v", _m.FlashAssists)) builder.WriteString(", ") builder.WriteString("avg_ping=") - builder.WriteString(fmt.Sprintf("%v", mp.AvgPing)) + builder.WriteString(fmt.Sprintf("%v", _m.AvgPing)) builder.WriteByte(')') return builder.String() } diff --git a/ent/matchplayer/where.go b/ent/matchplayer/where.go index 2d3e99c..71afad0 100644 --- a/ent/matchplayer/where.go +++ b/ent/matchplayer/where.go @@ -1898,32 +1898,15 @@ func HasMessagesWith(preds ...predicate.Messages) predicate.MatchPlayer { // And groups predicates with the AND operator between them. func And(predicates ...predicate.MatchPlayer) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.MatchPlayer(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.MatchPlayer) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.MatchPlayer(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.MatchPlayer) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.MatchPlayer(sql.NotPredicates(p)) } diff --git a/ent/matchplayer_create.go b/ent/matchplayer_create.go index 5c134c8..7306cf8 100644 --- a/ent/matchplayer_create.go +++ b/ent/matchplayer_create.go @@ -26,522 +26,522 @@ type MatchPlayerCreate struct { } // SetTeamID sets the "team_id" field. -func (mpc *MatchPlayerCreate) SetTeamID(i int) *MatchPlayerCreate { - mpc.mutation.SetTeamID(i) - return mpc +func (_c *MatchPlayerCreate) SetTeamID(v int) *MatchPlayerCreate { + _c.mutation.SetTeamID(v) + return _c } // SetKills sets the "kills" field. -func (mpc *MatchPlayerCreate) SetKills(i int) *MatchPlayerCreate { - mpc.mutation.SetKills(i) - return mpc +func (_c *MatchPlayerCreate) SetKills(v int) *MatchPlayerCreate { + _c.mutation.SetKills(v) + return _c } // SetDeaths sets the "deaths" field. -func (mpc *MatchPlayerCreate) SetDeaths(i int) *MatchPlayerCreate { - mpc.mutation.SetDeaths(i) - return mpc +func (_c *MatchPlayerCreate) SetDeaths(v int) *MatchPlayerCreate { + _c.mutation.SetDeaths(v) + return _c } // SetAssists sets the "assists" field. -func (mpc *MatchPlayerCreate) SetAssists(i int) *MatchPlayerCreate { - mpc.mutation.SetAssists(i) - return mpc +func (_c *MatchPlayerCreate) SetAssists(v int) *MatchPlayerCreate { + _c.mutation.SetAssists(v) + return _c } // SetHeadshot sets the "headshot" field. -func (mpc *MatchPlayerCreate) SetHeadshot(i int) *MatchPlayerCreate { - mpc.mutation.SetHeadshot(i) - return mpc +func (_c *MatchPlayerCreate) SetHeadshot(v int) *MatchPlayerCreate { + _c.mutation.SetHeadshot(v) + return _c } // SetMvp sets the "mvp" field. -func (mpc *MatchPlayerCreate) SetMvp(u uint) *MatchPlayerCreate { - mpc.mutation.SetMvp(u) - return mpc +func (_c *MatchPlayerCreate) SetMvp(v uint) *MatchPlayerCreate { + _c.mutation.SetMvp(v) + return _c } // SetScore sets the "score" field. -func (mpc *MatchPlayerCreate) SetScore(i int) *MatchPlayerCreate { - mpc.mutation.SetScore(i) - return mpc +func (_c *MatchPlayerCreate) SetScore(v int) *MatchPlayerCreate { + _c.mutation.SetScore(v) + return _c } // SetRankNew sets the "rank_new" field. -func (mpc *MatchPlayerCreate) SetRankNew(i int) *MatchPlayerCreate { - mpc.mutation.SetRankNew(i) - return mpc +func (_c *MatchPlayerCreate) SetRankNew(v int) *MatchPlayerCreate { + _c.mutation.SetRankNew(v) + return _c } // SetNillableRankNew sets the "rank_new" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableRankNew(i *int) *MatchPlayerCreate { - if i != nil { - mpc.SetRankNew(*i) +func (_c *MatchPlayerCreate) SetNillableRankNew(v *int) *MatchPlayerCreate { + if v != nil { + _c.SetRankNew(*v) } - return mpc + return _c } // SetRankOld sets the "rank_old" field. -func (mpc *MatchPlayerCreate) SetRankOld(i int) *MatchPlayerCreate { - mpc.mutation.SetRankOld(i) - return mpc +func (_c *MatchPlayerCreate) SetRankOld(v int) *MatchPlayerCreate { + _c.mutation.SetRankOld(v) + return _c } // SetNillableRankOld sets the "rank_old" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableRankOld(i *int) *MatchPlayerCreate { - if i != nil { - mpc.SetRankOld(*i) +func (_c *MatchPlayerCreate) SetNillableRankOld(v *int) *MatchPlayerCreate { + if v != nil { + _c.SetRankOld(*v) } - return mpc + return _c } // SetMk2 sets the "mk_2" field. -func (mpc *MatchPlayerCreate) SetMk2(u uint) *MatchPlayerCreate { - mpc.mutation.SetMk2(u) - return mpc +func (_c *MatchPlayerCreate) SetMk2(v uint) *MatchPlayerCreate { + _c.mutation.SetMk2(v) + return _c } // SetNillableMk2 sets the "mk_2" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableMk2(u *uint) *MatchPlayerCreate { - if u != nil { - mpc.SetMk2(*u) +func (_c *MatchPlayerCreate) SetNillableMk2(v *uint) *MatchPlayerCreate { + if v != nil { + _c.SetMk2(*v) } - return mpc + return _c } // SetMk3 sets the "mk_3" field. -func (mpc *MatchPlayerCreate) SetMk3(u uint) *MatchPlayerCreate { - mpc.mutation.SetMk3(u) - return mpc +func (_c *MatchPlayerCreate) SetMk3(v uint) *MatchPlayerCreate { + _c.mutation.SetMk3(v) + return _c } // SetNillableMk3 sets the "mk_3" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableMk3(u *uint) *MatchPlayerCreate { - if u != nil { - mpc.SetMk3(*u) +func (_c *MatchPlayerCreate) SetNillableMk3(v *uint) *MatchPlayerCreate { + if v != nil { + _c.SetMk3(*v) } - return mpc + return _c } // SetMk4 sets the "mk_4" field. -func (mpc *MatchPlayerCreate) SetMk4(u uint) *MatchPlayerCreate { - mpc.mutation.SetMk4(u) - return mpc +func (_c *MatchPlayerCreate) SetMk4(v uint) *MatchPlayerCreate { + _c.mutation.SetMk4(v) + return _c } // SetNillableMk4 sets the "mk_4" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableMk4(u *uint) *MatchPlayerCreate { - if u != nil { - mpc.SetMk4(*u) +func (_c *MatchPlayerCreate) SetNillableMk4(v *uint) *MatchPlayerCreate { + if v != nil { + _c.SetMk4(*v) } - return mpc + return _c } // SetMk5 sets the "mk_5" field. -func (mpc *MatchPlayerCreate) SetMk5(u uint) *MatchPlayerCreate { - mpc.mutation.SetMk5(u) - return mpc +func (_c *MatchPlayerCreate) SetMk5(v uint) *MatchPlayerCreate { + _c.mutation.SetMk5(v) + return _c } // SetNillableMk5 sets the "mk_5" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableMk5(u *uint) *MatchPlayerCreate { - if u != nil { - mpc.SetMk5(*u) +func (_c *MatchPlayerCreate) SetNillableMk5(v *uint) *MatchPlayerCreate { + if v != nil { + _c.SetMk5(*v) } - return mpc + return _c } // SetDmgEnemy sets the "dmg_enemy" field. -func (mpc *MatchPlayerCreate) SetDmgEnemy(u uint) *MatchPlayerCreate { - mpc.mutation.SetDmgEnemy(u) - return mpc +func (_c *MatchPlayerCreate) SetDmgEnemy(v uint) *MatchPlayerCreate { + _c.mutation.SetDmgEnemy(v) + return _c } // SetNillableDmgEnemy sets the "dmg_enemy" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableDmgEnemy(u *uint) *MatchPlayerCreate { - if u != nil { - mpc.SetDmgEnemy(*u) +func (_c *MatchPlayerCreate) SetNillableDmgEnemy(v *uint) *MatchPlayerCreate { + if v != nil { + _c.SetDmgEnemy(*v) } - return mpc + return _c } // SetDmgTeam sets the "dmg_team" field. -func (mpc *MatchPlayerCreate) SetDmgTeam(u uint) *MatchPlayerCreate { - mpc.mutation.SetDmgTeam(u) - return mpc +func (_c *MatchPlayerCreate) SetDmgTeam(v uint) *MatchPlayerCreate { + _c.mutation.SetDmgTeam(v) + return _c } // SetNillableDmgTeam sets the "dmg_team" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableDmgTeam(u *uint) *MatchPlayerCreate { - if u != nil { - mpc.SetDmgTeam(*u) +func (_c *MatchPlayerCreate) SetNillableDmgTeam(v *uint) *MatchPlayerCreate { + if v != nil { + _c.SetDmgTeam(*v) } - return mpc + return _c } // SetUdHe sets the "ud_he" field. -func (mpc *MatchPlayerCreate) SetUdHe(u uint) *MatchPlayerCreate { - mpc.mutation.SetUdHe(u) - return mpc +func (_c *MatchPlayerCreate) SetUdHe(v uint) *MatchPlayerCreate { + _c.mutation.SetUdHe(v) + return _c } // SetNillableUdHe sets the "ud_he" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableUdHe(u *uint) *MatchPlayerCreate { - if u != nil { - mpc.SetUdHe(*u) +func (_c *MatchPlayerCreate) SetNillableUdHe(v *uint) *MatchPlayerCreate { + if v != nil { + _c.SetUdHe(*v) } - return mpc + return _c } // SetUdFlames sets the "ud_flames" field. -func (mpc *MatchPlayerCreate) SetUdFlames(u uint) *MatchPlayerCreate { - mpc.mutation.SetUdFlames(u) - return mpc +func (_c *MatchPlayerCreate) SetUdFlames(v uint) *MatchPlayerCreate { + _c.mutation.SetUdFlames(v) + return _c } // SetNillableUdFlames sets the "ud_flames" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableUdFlames(u *uint) *MatchPlayerCreate { - if u != nil { - mpc.SetUdFlames(*u) +func (_c *MatchPlayerCreate) SetNillableUdFlames(v *uint) *MatchPlayerCreate { + if v != nil { + _c.SetUdFlames(*v) } - return mpc + return _c } // SetUdFlash sets the "ud_flash" field. -func (mpc *MatchPlayerCreate) SetUdFlash(u uint) *MatchPlayerCreate { - mpc.mutation.SetUdFlash(u) - return mpc +func (_c *MatchPlayerCreate) SetUdFlash(v uint) *MatchPlayerCreate { + _c.mutation.SetUdFlash(v) + return _c } // SetNillableUdFlash sets the "ud_flash" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableUdFlash(u *uint) *MatchPlayerCreate { - if u != nil { - mpc.SetUdFlash(*u) +func (_c *MatchPlayerCreate) SetNillableUdFlash(v *uint) *MatchPlayerCreate { + if v != nil { + _c.SetUdFlash(*v) } - return mpc + return _c } // SetUdDecoy sets the "ud_decoy" field. -func (mpc *MatchPlayerCreate) SetUdDecoy(u uint) *MatchPlayerCreate { - mpc.mutation.SetUdDecoy(u) - return mpc +func (_c *MatchPlayerCreate) SetUdDecoy(v uint) *MatchPlayerCreate { + _c.mutation.SetUdDecoy(v) + return _c } // SetNillableUdDecoy sets the "ud_decoy" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableUdDecoy(u *uint) *MatchPlayerCreate { - if u != nil { - mpc.SetUdDecoy(*u) +func (_c *MatchPlayerCreate) SetNillableUdDecoy(v *uint) *MatchPlayerCreate { + if v != nil { + _c.SetUdDecoy(*v) } - return mpc + return _c } // SetUdSmoke sets the "ud_smoke" field. -func (mpc *MatchPlayerCreate) SetUdSmoke(u uint) *MatchPlayerCreate { - mpc.mutation.SetUdSmoke(u) - return mpc +func (_c *MatchPlayerCreate) SetUdSmoke(v uint) *MatchPlayerCreate { + _c.mutation.SetUdSmoke(v) + return _c } // SetNillableUdSmoke sets the "ud_smoke" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableUdSmoke(u *uint) *MatchPlayerCreate { - if u != nil { - mpc.SetUdSmoke(*u) +func (_c *MatchPlayerCreate) SetNillableUdSmoke(v *uint) *MatchPlayerCreate { + if v != nil { + _c.SetUdSmoke(*v) } - return mpc + return _c } // SetCrosshair sets the "crosshair" field. -func (mpc *MatchPlayerCreate) SetCrosshair(s string) *MatchPlayerCreate { - mpc.mutation.SetCrosshair(s) - return mpc +func (_c *MatchPlayerCreate) SetCrosshair(v string) *MatchPlayerCreate { + _c.mutation.SetCrosshair(v) + return _c } // SetNillableCrosshair sets the "crosshair" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableCrosshair(s *string) *MatchPlayerCreate { - if s != nil { - mpc.SetCrosshair(*s) +func (_c *MatchPlayerCreate) SetNillableCrosshair(v *string) *MatchPlayerCreate { + if v != nil { + _c.SetCrosshair(*v) } - return mpc + return _c } // SetColor sets the "color" field. -func (mpc *MatchPlayerCreate) SetColor(m matchplayer.Color) *MatchPlayerCreate { - mpc.mutation.SetColor(m) - return mpc +func (_c *MatchPlayerCreate) SetColor(v matchplayer.Color) *MatchPlayerCreate { + _c.mutation.SetColor(v) + return _c } // SetNillableColor sets the "color" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableColor(m *matchplayer.Color) *MatchPlayerCreate { - if m != nil { - mpc.SetColor(*m) +func (_c *MatchPlayerCreate) SetNillableColor(v *matchplayer.Color) *MatchPlayerCreate { + if v != nil { + _c.SetColor(*v) } - return mpc + return _c } // SetKast sets the "kast" field. -func (mpc *MatchPlayerCreate) SetKast(i int) *MatchPlayerCreate { - mpc.mutation.SetKast(i) - return mpc +func (_c *MatchPlayerCreate) SetKast(v int) *MatchPlayerCreate { + _c.mutation.SetKast(v) + return _c } // SetNillableKast sets the "kast" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableKast(i *int) *MatchPlayerCreate { - if i != nil { - mpc.SetKast(*i) +func (_c *MatchPlayerCreate) SetNillableKast(v *int) *MatchPlayerCreate { + if v != nil { + _c.SetKast(*v) } - return mpc + return _c } // SetFlashDurationSelf sets the "flash_duration_self" field. -func (mpc *MatchPlayerCreate) SetFlashDurationSelf(f float32) *MatchPlayerCreate { - mpc.mutation.SetFlashDurationSelf(f) - return mpc +func (_c *MatchPlayerCreate) SetFlashDurationSelf(v float32) *MatchPlayerCreate { + _c.mutation.SetFlashDurationSelf(v) + return _c } // SetNillableFlashDurationSelf sets the "flash_duration_self" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableFlashDurationSelf(f *float32) *MatchPlayerCreate { - if f != nil { - mpc.SetFlashDurationSelf(*f) +func (_c *MatchPlayerCreate) SetNillableFlashDurationSelf(v *float32) *MatchPlayerCreate { + if v != nil { + _c.SetFlashDurationSelf(*v) } - return mpc + return _c } // SetFlashDurationTeam sets the "flash_duration_team" field. -func (mpc *MatchPlayerCreate) SetFlashDurationTeam(f float32) *MatchPlayerCreate { - mpc.mutation.SetFlashDurationTeam(f) - return mpc +func (_c *MatchPlayerCreate) SetFlashDurationTeam(v float32) *MatchPlayerCreate { + _c.mutation.SetFlashDurationTeam(v) + return _c } // SetNillableFlashDurationTeam sets the "flash_duration_team" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableFlashDurationTeam(f *float32) *MatchPlayerCreate { - if f != nil { - mpc.SetFlashDurationTeam(*f) +func (_c *MatchPlayerCreate) SetNillableFlashDurationTeam(v *float32) *MatchPlayerCreate { + if v != nil { + _c.SetFlashDurationTeam(*v) } - return mpc + return _c } // SetFlashDurationEnemy sets the "flash_duration_enemy" field. -func (mpc *MatchPlayerCreate) SetFlashDurationEnemy(f float32) *MatchPlayerCreate { - mpc.mutation.SetFlashDurationEnemy(f) - return mpc +func (_c *MatchPlayerCreate) SetFlashDurationEnemy(v float32) *MatchPlayerCreate { + _c.mutation.SetFlashDurationEnemy(v) + return _c } // SetNillableFlashDurationEnemy sets the "flash_duration_enemy" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableFlashDurationEnemy(f *float32) *MatchPlayerCreate { - if f != nil { - mpc.SetFlashDurationEnemy(*f) +func (_c *MatchPlayerCreate) SetNillableFlashDurationEnemy(v *float32) *MatchPlayerCreate { + if v != nil { + _c.SetFlashDurationEnemy(*v) } - return mpc + return _c } // SetFlashTotalSelf sets the "flash_total_self" field. -func (mpc *MatchPlayerCreate) SetFlashTotalSelf(u uint) *MatchPlayerCreate { - mpc.mutation.SetFlashTotalSelf(u) - return mpc +func (_c *MatchPlayerCreate) SetFlashTotalSelf(v uint) *MatchPlayerCreate { + _c.mutation.SetFlashTotalSelf(v) + return _c } // SetNillableFlashTotalSelf sets the "flash_total_self" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableFlashTotalSelf(u *uint) *MatchPlayerCreate { - if u != nil { - mpc.SetFlashTotalSelf(*u) +func (_c *MatchPlayerCreate) SetNillableFlashTotalSelf(v *uint) *MatchPlayerCreate { + if v != nil { + _c.SetFlashTotalSelf(*v) } - return mpc + return _c } // SetFlashTotalTeam sets the "flash_total_team" field. -func (mpc *MatchPlayerCreate) SetFlashTotalTeam(u uint) *MatchPlayerCreate { - mpc.mutation.SetFlashTotalTeam(u) - return mpc +func (_c *MatchPlayerCreate) SetFlashTotalTeam(v uint) *MatchPlayerCreate { + _c.mutation.SetFlashTotalTeam(v) + return _c } // SetNillableFlashTotalTeam sets the "flash_total_team" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableFlashTotalTeam(u *uint) *MatchPlayerCreate { - if u != nil { - mpc.SetFlashTotalTeam(*u) +func (_c *MatchPlayerCreate) SetNillableFlashTotalTeam(v *uint) *MatchPlayerCreate { + if v != nil { + _c.SetFlashTotalTeam(*v) } - return mpc + return _c } // SetFlashTotalEnemy sets the "flash_total_enemy" field. -func (mpc *MatchPlayerCreate) SetFlashTotalEnemy(u uint) *MatchPlayerCreate { - mpc.mutation.SetFlashTotalEnemy(u) - return mpc +func (_c *MatchPlayerCreate) SetFlashTotalEnemy(v uint) *MatchPlayerCreate { + _c.mutation.SetFlashTotalEnemy(v) + return _c } // SetNillableFlashTotalEnemy sets the "flash_total_enemy" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableFlashTotalEnemy(u *uint) *MatchPlayerCreate { - if u != nil { - mpc.SetFlashTotalEnemy(*u) +func (_c *MatchPlayerCreate) SetNillableFlashTotalEnemy(v *uint) *MatchPlayerCreate { + if v != nil { + _c.SetFlashTotalEnemy(*v) } - return mpc + return _c } // SetMatchStats sets the "match_stats" field. -func (mpc *MatchPlayerCreate) SetMatchStats(u uint64) *MatchPlayerCreate { - mpc.mutation.SetMatchStats(u) - return mpc +func (_c *MatchPlayerCreate) SetMatchStats(v uint64) *MatchPlayerCreate { + _c.mutation.SetMatchStats(v) + return _c } // SetNillableMatchStats sets the "match_stats" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableMatchStats(u *uint64) *MatchPlayerCreate { - if u != nil { - mpc.SetMatchStats(*u) +func (_c *MatchPlayerCreate) SetNillableMatchStats(v *uint64) *MatchPlayerCreate { + if v != nil { + _c.SetMatchStats(*v) } - return mpc + return _c } // SetPlayerStats sets the "player_stats" field. -func (mpc *MatchPlayerCreate) SetPlayerStats(u uint64) *MatchPlayerCreate { - mpc.mutation.SetPlayerStats(u) - return mpc +func (_c *MatchPlayerCreate) SetPlayerStats(v uint64) *MatchPlayerCreate { + _c.mutation.SetPlayerStats(v) + return _c } // SetNillablePlayerStats sets the "player_stats" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillablePlayerStats(u *uint64) *MatchPlayerCreate { - if u != nil { - mpc.SetPlayerStats(*u) +func (_c *MatchPlayerCreate) SetNillablePlayerStats(v *uint64) *MatchPlayerCreate { + if v != nil { + _c.SetPlayerStats(*v) } - return mpc + return _c } // SetFlashAssists sets the "flash_assists" field. -func (mpc *MatchPlayerCreate) SetFlashAssists(i int) *MatchPlayerCreate { - mpc.mutation.SetFlashAssists(i) - return mpc +func (_c *MatchPlayerCreate) SetFlashAssists(v int) *MatchPlayerCreate { + _c.mutation.SetFlashAssists(v) + return _c } // SetNillableFlashAssists sets the "flash_assists" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableFlashAssists(i *int) *MatchPlayerCreate { - if i != nil { - mpc.SetFlashAssists(*i) +func (_c *MatchPlayerCreate) SetNillableFlashAssists(v *int) *MatchPlayerCreate { + if v != nil { + _c.SetFlashAssists(*v) } - return mpc + return _c } // SetAvgPing sets the "avg_ping" field. -func (mpc *MatchPlayerCreate) SetAvgPing(f float64) *MatchPlayerCreate { - mpc.mutation.SetAvgPing(f) - return mpc +func (_c *MatchPlayerCreate) SetAvgPing(v float64) *MatchPlayerCreate { + _c.mutation.SetAvgPing(v) + return _c } // SetNillableAvgPing sets the "avg_ping" field if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableAvgPing(f *float64) *MatchPlayerCreate { - if f != nil { - mpc.SetAvgPing(*f) +func (_c *MatchPlayerCreate) SetNillableAvgPing(v *float64) *MatchPlayerCreate { + if v != nil { + _c.SetAvgPing(*v) } - return mpc + return _c } // SetMatchesID sets the "matches" edge to the Match entity by ID. -func (mpc *MatchPlayerCreate) SetMatchesID(id uint64) *MatchPlayerCreate { - mpc.mutation.SetMatchesID(id) - return mpc +func (_c *MatchPlayerCreate) SetMatchesID(id uint64) *MatchPlayerCreate { + _c.mutation.SetMatchesID(id) + return _c } // SetNillableMatchesID sets the "matches" edge to the Match entity by ID if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillableMatchesID(id *uint64) *MatchPlayerCreate { +func (_c *MatchPlayerCreate) SetNillableMatchesID(id *uint64) *MatchPlayerCreate { if id != nil { - mpc = mpc.SetMatchesID(*id) + _c = _c.SetMatchesID(*id) } - return mpc + return _c } // SetMatches sets the "matches" edge to the Match entity. -func (mpc *MatchPlayerCreate) SetMatches(m *Match) *MatchPlayerCreate { - return mpc.SetMatchesID(m.ID) +func (_c *MatchPlayerCreate) SetMatches(v *Match) *MatchPlayerCreate { + return _c.SetMatchesID(v.ID) } // SetPlayersID sets the "players" edge to the Player entity by ID. -func (mpc *MatchPlayerCreate) SetPlayersID(id uint64) *MatchPlayerCreate { - mpc.mutation.SetPlayersID(id) - return mpc +func (_c *MatchPlayerCreate) SetPlayersID(id uint64) *MatchPlayerCreate { + _c.mutation.SetPlayersID(id) + return _c } // SetNillablePlayersID sets the "players" edge to the Player entity by ID if the given value is not nil. -func (mpc *MatchPlayerCreate) SetNillablePlayersID(id *uint64) *MatchPlayerCreate { +func (_c *MatchPlayerCreate) SetNillablePlayersID(id *uint64) *MatchPlayerCreate { if id != nil { - mpc = mpc.SetPlayersID(*id) + _c = _c.SetPlayersID(*id) } - return mpc + return _c } // SetPlayers sets the "players" edge to the Player entity. -func (mpc *MatchPlayerCreate) SetPlayers(p *Player) *MatchPlayerCreate { - return mpc.SetPlayersID(p.ID) +func (_c *MatchPlayerCreate) SetPlayers(v *Player) *MatchPlayerCreate { + return _c.SetPlayersID(v.ID) } // AddWeaponStatIDs adds the "weapon_stats" edge to the Weapon entity by IDs. -func (mpc *MatchPlayerCreate) AddWeaponStatIDs(ids ...int) *MatchPlayerCreate { - mpc.mutation.AddWeaponStatIDs(ids...) - return mpc +func (_c *MatchPlayerCreate) AddWeaponStatIDs(ids ...int) *MatchPlayerCreate { + _c.mutation.AddWeaponStatIDs(ids...) + return _c } // AddWeaponStats adds the "weapon_stats" edges to the Weapon entity. -func (mpc *MatchPlayerCreate) AddWeaponStats(w ...*Weapon) *MatchPlayerCreate { - ids := make([]int, len(w)) - for i := range w { - ids[i] = w[i].ID +func (_c *MatchPlayerCreate) AddWeaponStats(v ...*Weapon) *MatchPlayerCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mpc.AddWeaponStatIDs(ids...) + return _c.AddWeaponStatIDs(ids...) } // AddRoundStatIDs adds the "round_stats" edge to the RoundStats entity by IDs. -func (mpc *MatchPlayerCreate) AddRoundStatIDs(ids ...int) *MatchPlayerCreate { - mpc.mutation.AddRoundStatIDs(ids...) - return mpc +func (_c *MatchPlayerCreate) AddRoundStatIDs(ids ...int) *MatchPlayerCreate { + _c.mutation.AddRoundStatIDs(ids...) + return _c } // AddRoundStats adds the "round_stats" edges to the RoundStats entity. -func (mpc *MatchPlayerCreate) AddRoundStats(r ...*RoundStats) *MatchPlayerCreate { - ids := make([]int, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_c *MatchPlayerCreate) AddRoundStats(v ...*RoundStats) *MatchPlayerCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mpc.AddRoundStatIDs(ids...) + return _c.AddRoundStatIDs(ids...) } // AddSprayIDs adds the "spray" edge to the Spray entity by IDs. -func (mpc *MatchPlayerCreate) AddSprayIDs(ids ...int) *MatchPlayerCreate { - mpc.mutation.AddSprayIDs(ids...) - return mpc +func (_c *MatchPlayerCreate) AddSprayIDs(ids ...int) *MatchPlayerCreate { + _c.mutation.AddSprayIDs(ids...) + return _c } // AddSpray adds the "spray" edges to the Spray entity. -func (mpc *MatchPlayerCreate) AddSpray(s ...*Spray) *MatchPlayerCreate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID +func (_c *MatchPlayerCreate) AddSpray(v ...*Spray) *MatchPlayerCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mpc.AddSprayIDs(ids...) + return _c.AddSprayIDs(ids...) } // AddMessageIDs adds the "messages" edge to the Messages entity by IDs. -func (mpc *MatchPlayerCreate) AddMessageIDs(ids ...int) *MatchPlayerCreate { - mpc.mutation.AddMessageIDs(ids...) - return mpc +func (_c *MatchPlayerCreate) AddMessageIDs(ids ...int) *MatchPlayerCreate { + _c.mutation.AddMessageIDs(ids...) + return _c } // AddMessages adds the "messages" edges to the Messages entity. -func (mpc *MatchPlayerCreate) AddMessages(m ...*Messages) *MatchPlayerCreate { - ids := make([]int, len(m)) - for i := range m { - ids[i] = m[i].ID +func (_c *MatchPlayerCreate) AddMessages(v ...*Messages) *MatchPlayerCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mpc.AddMessageIDs(ids...) + return _c.AddMessageIDs(ids...) } // Mutation returns the MatchPlayerMutation object of the builder. -func (mpc *MatchPlayerCreate) Mutation() *MatchPlayerMutation { - return mpc.mutation +func (_c *MatchPlayerCreate) Mutation() *MatchPlayerMutation { + return _c.mutation } // Save creates the MatchPlayer in the database. -func (mpc *MatchPlayerCreate) Save(ctx context.Context) (*MatchPlayer, error) { - return withHooks(ctx, mpc.sqlSave, mpc.mutation, mpc.hooks) +func (_c *MatchPlayerCreate) Save(ctx context.Context) (*MatchPlayer, error) { + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. -func (mpc *MatchPlayerCreate) SaveX(ctx context.Context) *MatchPlayer { - v, err := mpc.Save(ctx) +func (_c *MatchPlayerCreate) SaveX(ctx context.Context) *MatchPlayer { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -549,42 +549,42 @@ func (mpc *MatchPlayerCreate) SaveX(ctx context.Context) *MatchPlayer { } // Exec executes the query. -func (mpc *MatchPlayerCreate) Exec(ctx context.Context) error { - _, err := mpc.Save(ctx) +func (_c *MatchPlayerCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (mpc *MatchPlayerCreate) ExecX(ctx context.Context) { - if err := mpc.Exec(ctx); err != nil { +func (_c *MatchPlayerCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (mpc *MatchPlayerCreate) check() error { - if _, ok := mpc.mutation.TeamID(); !ok { +func (_c *MatchPlayerCreate) check() error { + if _, ok := _c.mutation.TeamID(); !ok { return &ValidationError{Name: "team_id", err: errors.New(`ent: missing required field "MatchPlayer.team_id"`)} } - if _, ok := mpc.mutation.Kills(); !ok { + if _, ok := _c.mutation.Kills(); !ok { return &ValidationError{Name: "kills", err: errors.New(`ent: missing required field "MatchPlayer.kills"`)} } - if _, ok := mpc.mutation.Deaths(); !ok { + if _, ok := _c.mutation.Deaths(); !ok { return &ValidationError{Name: "deaths", err: errors.New(`ent: missing required field "MatchPlayer.deaths"`)} } - if _, ok := mpc.mutation.Assists(); !ok { + if _, ok := _c.mutation.Assists(); !ok { return &ValidationError{Name: "assists", err: errors.New(`ent: missing required field "MatchPlayer.assists"`)} } - if _, ok := mpc.mutation.Headshot(); !ok { + if _, ok := _c.mutation.Headshot(); !ok { return &ValidationError{Name: "headshot", err: errors.New(`ent: missing required field "MatchPlayer.headshot"`)} } - if _, ok := mpc.mutation.Mvp(); !ok { + if _, ok := _c.mutation.Mvp(); !ok { return &ValidationError{Name: "mvp", err: errors.New(`ent: missing required field "MatchPlayer.mvp"`)} } - if _, ok := mpc.mutation.Score(); !ok { + if _, ok := _c.mutation.Score(); !ok { return &ValidationError{Name: "score", err: errors.New(`ent: missing required field "MatchPlayer.score"`)} } - if v, ok := mpc.mutation.Color(); ok { + if v, ok := _c.mutation.Color(); ok { if err := matchplayer.ColorValidator(v); err != nil { return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "MatchPlayer.color": %w`, err)} } @@ -592,12 +592,12 @@ func (mpc *MatchPlayerCreate) check() error { return nil } -func (mpc *MatchPlayerCreate) sqlSave(ctx context.Context) (*MatchPlayer, error) { - if err := mpc.check(); err != nil { +func (_c *MatchPlayerCreate) sqlSave(ctx context.Context) (*MatchPlayer, error) { + if err := _c.check(); err != nil { return nil, err } - _node, _spec := mpc.createSpec() - if err := sqlgraph.CreateNode(ctx, mpc.driver, _spec); err != nil { + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -605,141 +605,141 @@ func (mpc *MatchPlayerCreate) sqlSave(ctx context.Context) (*MatchPlayer, error) } id := _spec.ID.Value.(int64) _node.ID = int(id) - mpc.mutation.id = &_node.ID - mpc.mutation.done = true + _c.mutation.id = &_node.ID + _c.mutation.done = true return _node, nil } -func (mpc *MatchPlayerCreate) createSpec() (*MatchPlayer, *sqlgraph.CreateSpec) { +func (_c *MatchPlayerCreate) createSpec() (*MatchPlayer, *sqlgraph.CreateSpec) { var ( - _node = &MatchPlayer{config: mpc.config} + _node = &MatchPlayer{config: _c.config} _spec = sqlgraph.NewCreateSpec(matchplayer.Table, sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt)) ) - if value, ok := mpc.mutation.TeamID(); ok { + if value, ok := _c.mutation.TeamID(); ok { _spec.SetField(matchplayer.FieldTeamID, field.TypeInt, value) _node.TeamID = value } - if value, ok := mpc.mutation.Kills(); ok { + if value, ok := _c.mutation.Kills(); ok { _spec.SetField(matchplayer.FieldKills, field.TypeInt, value) _node.Kills = value } - if value, ok := mpc.mutation.Deaths(); ok { + if value, ok := _c.mutation.Deaths(); ok { _spec.SetField(matchplayer.FieldDeaths, field.TypeInt, value) _node.Deaths = value } - if value, ok := mpc.mutation.Assists(); ok { + if value, ok := _c.mutation.Assists(); ok { _spec.SetField(matchplayer.FieldAssists, field.TypeInt, value) _node.Assists = value } - if value, ok := mpc.mutation.Headshot(); ok { + if value, ok := _c.mutation.Headshot(); ok { _spec.SetField(matchplayer.FieldHeadshot, field.TypeInt, value) _node.Headshot = value } - if value, ok := mpc.mutation.Mvp(); ok { + if value, ok := _c.mutation.Mvp(); ok { _spec.SetField(matchplayer.FieldMvp, field.TypeUint, value) _node.Mvp = value } - if value, ok := mpc.mutation.Score(); ok { + if value, ok := _c.mutation.Score(); ok { _spec.SetField(matchplayer.FieldScore, field.TypeInt, value) _node.Score = value } - if value, ok := mpc.mutation.RankNew(); ok { + if value, ok := _c.mutation.RankNew(); ok { _spec.SetField(matchplayer.FieldRankNew, field.TypeInt, value) _node.RankNew = value } - if value, ok := mpc.mutation.RankOld(); ok { + if value, ok := _c.mutation.RankOld(); ok { _spec.SetField(matchplayer.FieldRankOld, field.TypeInt, value) _node.RankOld = value } - if value, ok := mpc.mutation.Mk2(); ok { + if value, ok := _c.mutation.Mk2(); ok { _spec.SetField(matchplayer.FieldMk2, field.TypeUint, value) _node.Mk2 = value } - if value, ok := mpc.mutation.Mk3(); ok { + if value, ok := _c.mutation.Mk3(); ok { _spec.SetField(matchplayer.FieldMk3, field.TypeUint, value) _node.Mk3 = value } - if value, ok := mpc.mutation.Mk4(); ok { + if value, ok := _c.mutation.Mk4(); ok { _spec.SetField(matchplayer.FieldMk4, field.TypeUint, value) _node.Mk4 = value } - if value, ok := mpc.mutation.Mk5(); ok { + if value, ok := _c.mutation.Mk5(); ok { _spec.SetField(matchplayer.FieldMk5, field.TypeUint, value) _node.Mk5 = value } - if value, ok := mpc.mutation.DmgEnemy(); ok { + if value, ok := _c.mutation.DmgEnemy(); ok { _spec.SetField(matchplayer.FieldDmgEnemy, field.TypeUint, value) _node.DmgEnemy = value } - if value, ok := mpc.mutation.DmgTeam(); ok { + if value, ok := _c.mutation.DmgTeam(); ok { _spec.SetField(matchplayer.FieldDmgTeam, field.TypeUint, value) _node.DmgTeam = value } - if value, ok := mpc.mutation.UdHe(); ok { + if value, ok := _c.mutation.UdHe(); ok { _spec.SetField(matchplayer.FieldUdHe, field.TypeUint, value) _node.UdHe = value } - if value, ok := mpc.mutation.UdFlames(); ok { + if value, ok := _c.mutation.UdFlames(); ok { _spec.SetField(matchplayer.FieldUdFlames, field.TypeUint, value) _node.UdFlames = value } - if value, ok := mpc.mutation.UdFlash(); ok { + if value, ok := _c.mutation.UdFlash(); ok { _spec.SetField(matchplayer.FieldUdFlash, field.TypeUint, value) _node.UdFlash = value } - if value, ok := mpc.mutation.UdDecoy(); ok { + if value, ok := _c.mutation.UdDecoy(); ok { _spec.SetField(matchplayer.FieldUdDecoy, field.TypeUint, value) _node.UdDecoy = value } - if value, ok := mpc.mutation.UdSmoke(); ok { + if value, ok := _c.mutation.UdSmoke(); ok { _spec.SetField(matchplayer.FieldUdSmoke, field.TypeUint, value) _node.UdSmoke = value } - if value, ok := mpc.mutation.Crosshair(); ok { + if value, ok := _c.mutation.Crosshair(); ok { _spec.SetField(matchplayer.FieldCrosshair, field.TypeString, value) _node.Crosshair = value } - if value, ok := mpc.mutation.Color(); ok { + if value, ok := _c.mutation.Color(); ok { _spec.SetField(matchplayer.FieldColor, field.TypeEnum, value) _node.Color = value } - if value, ok := mpc.mutation.Kast(); ok { + if value, ok := _c.mutation.Kast(); ok { _spec.SetField(matchplayer.FieldKast, field.TypeInt, value) _node.Kast = value } - if value, ok := mpc.mutation.FlashDurationSelf(); ok { + if value, ok := _c.mutation.FlashDurationSelf(); ok { _spec.SetField(matchplayer.FieldFlashDurationSelf, field.TypeFloat32, value) _node.FlashDurationSelf = value } - if value, ok := mpc.mutation.FlashDurationTeam(); ok { + if value, ok := _c.mutation.FlashDurationTeam(); ok { _spec.SetField(matchplayer.FieldFlashDurationTeam, field.TypeFloat32, value) _node.FlashDurationTeam = value } - if value, ok := mpc.mutation.FlashDurationEnemy(); ok { + if value, ok := _c.mutation.FlashDurationEnemy(); ok { _spec.SetField(matchplayer.FieldFlashDurationEnemy, field.TypeFloat32, value) _node.FlashDurationEnemy = value } - if value, ok := mpc.mutation.FlashTotalSelf(); ok { + if value, ok := _c.mutation.FlashTotalSelf(); ok { _spec.SetField(matchplayer.FieldFlashTotalSelf, field.TypeUint, value) _node.FlashTotalSelf = value } - if value, ok := mpc.mutation.FlashTotalTeam(); ok { + if value, ok := _c.mutation.FlashTotalTeam(); ok { _spec.SetField(matchplayer.FieldFlashTotalTeam, field.TypeUint, value) _node.FlashTotalTeam = value } - if value, ok := mpc.mutation.FlashTotalEnemy(); ok { + if value, ok := _c.mutation.FlashTotalEnemy(); ok { _spec.SetField(matchplayer.FieldFlashTotalEnemy, field.TypeUint, value) _node.FlashTotalEnemy = value } - if value, ok := mpc.mutation.FlashAssists(); ok { + if value, ok := _c.mutation.FlashAssists(); ok { _spec.SetField(matchplayer.FieldFlashAssists, field.TypeInt, value) _node.FlashAssists = value } - if value, ok := mpc.mutation.AvgPing(); ok { + if value, ok := _c.mutation.AvgPing(); ok { _spec.SetField(matchplayer.FieldAvgPing, field.TypeFloat64, value) _node.AvgPing = value } - if nodes := mpc.mutation.MatchesIDs(); len(nodes) > 0 { + if nodes := _c.mutation.MatchesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -756,7 +756,7 @@ func (mpc *MatchPlayerCreate) createSpec() (*MatchPlayer, *sqlgraph.CreateSpec) _node.MatchStats = nodes[0] _spec.Edges = append(_spec.Edges, edge) } - if nodes := mpc.mutation.PlayersIDs(); len(nodes) > 0 { + if nodes := _c.mutation.PlayersIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -773,7 +773,7 @@ func (mpc *MatchPlayerCreate) createSpec() (*MatchPlayer, *sqlgraph.CreateSpec) _node.PlayerStats = nodes[0] _spec.Edges = append(_spec.Edges, edge) } - if nodes := mpc.mutation.WeaponStatsIDs(); len(nodes) > 0 { + if nodes := _c.mutation.WeaponStatsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -789,7 +789,7 @@ func (mpc *MatchPlayerCreate) createSpec() (*MatchPlayer, *sqlgraph.CreateSpec) } _spec.Edges = append(_spec.Edges, edge) } - if nodes := mpc.mutation.RoundStatsIDs(); len(nodes) > 0 { + if nodes := _c.mutation.RoundStatsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -805,7 +805,7 @@ func (mpc *MatchPlayerCreate) createSpec() (*MatchPlayer, *sqlgraph.CreateSpec) } _spec.Edges = append(_spec.Edges, edge) } - if nodes := mpc.mutation.SprayIDs(); len(nodes) > 0 { + if nodes := _c.mutation.SprayIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -821,7 +821,7 @@ func (mpc *MatchPlayerCreate) createSpec() (*MatchPlayer, *sqlgraph.CreateSpec) } _spec.Edges = append(_spec.Edges, edge) } - if nodes := mpc.mutation.MessagesIDs(); len(nodes) > 0 { + if nodes := _c.mutation.MessagesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -843,17 +843,21 @@ func (mpc *MatchPlayerCreate) createSpec() (*MatchPlayer, *sqlgraph.CreateSpec) // MatchPlayerCreateBulk is the builder for creating many MatchPlayer entities in bulk. type MatchPlayerCreateBulk struct { config + err error builders []*MatchPlayerCreate } // Save creates the MatchPlayer entities in the database. -func (mpcb *MatchPlayerCreateBulk) Save(ctx context.Context) ([]*MatchPlayer, error) { - specs := make([]*sqlgraph.CreateSpec, len(mpcb.builders)) - nodes := make([]*MatchPlayer, len(mpcb.builders)) - mutators := make([]Mutator, len(mpcb.builders)) - for i := range mpcb.builders { +func (_c *MatchPlayerCreateBulk) Save(ctx context.Context) ([]*MatchPlayer, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*MatchPlayer, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { func(i int, root context.Context) { - builder := mpcb.builders[i] + builder := _c.builders[i] var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*MatchPlayerMutation) if !ok { @@ -866,11 +870,11 @@ func (mpcb *MatchPlayerCreateBulk) Save(ctx context.Context) ([]*MatchPlayer, er var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, mpcb.builders[i+1].mutation) + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, mpcb.driver, spec); err != nil { + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -894,7 +898,7 @@ func (mpcb *MatchPlayerCreateBulk) Save(ctx context.Context) ([]*MatchPlayer, er }(i, ctx) } if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, mpcb.builders[0].mutation); err != nil { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { return nil, err } } @@ -902,8 +906,8 @@ func (mpcb *MatchPlayerCreateBulk) Save(ctx context.Context) ([]*MatchPlayer, er } // SaveX is like Save, but panics if an error occurs. -func (mpcb *MatchPlayerCreateBulk) SaveX(ctx context.Context) []*MatchPlayer { - v, err := mpcb.Save(ctx) +func (_c *MatchPlayerCreateBulk) SaveX(ctx context.Context) []*MatchPlayer { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -911,14 +915,14 @@ func (mpcb *MatchPlayerCreateBulk) SaveX(ctx context.Context) []*MatchPlayer { } // Exec executes the query. -func (mpcb *MatchPlayerCreateBulk) Exec(ctx context.Context) error { - _, err := mpcb.Save(ctx) +func (_c *MatchPlayerCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (mpcb *MatchPlayerCreateBulk) ExecX(ctx context.Context) { - if err := mpcb.Exec(ctx); err != nil { +func (_c *MatchPlayerCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } diff --git a/ent/matchplayer_delete.go b/ent/matchplayer_delete.go index a70ae8f..269b3a0 100644 --- a/ent/matchplayer_delete.go +++ b/ent/matchplayer_delete.go @@ -20,56 +20,56 @@ type MatchPlayerDelete struct { } // Where appends a list predicates to the MatchPlayerDelete builder. -func (mpd *MatchPlayerDelete) Where(ps ...predicate.MatchPlayer) *MatchPlayerDelete { - mpd.mutation.Where(ps...) - return mpd +func (_d *MatchPlayerDelete) Where(ps ...predicate.MatchPlayer) *MatchPlayerDelete { + _d.mutation.Where(ps...) + return _d } // Exec executes the deletion query and returns how many vertices were deleted. -func (mpd *MatchPlayerDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, mpd.sqlExec, mpd.mutation, mpd.hooks) +func (_d *MatchPlayerDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) } // ExecX is like Exec, but panics if an error occurs. -func (mpd *MatchPlayerDelete) ExecX(ctx context.Context) int { - n, err := mpd.Exec(ctx) +func (_d *MatchPlayerDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) if err != nil { panic(err) } return n } -func (mpd *MatchPlayerDelete) sqlExec(ctx context.Context) (int, error) { +func (_d *MatchPlayerDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(matchplayer.Table, sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt)) - if ps := mpd.mutation.predicates; len(ps) > 0 { + if ps := _d.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - affected, err := sqlgraph.DeleteNodes(ctx, mpd.driver, _spec) + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } - mpd.mutation.done = true + _d.mutation.done = true return affected, err } // MatchPlayerDeleteOne is the builder for deleting a single MatchPlayer entity. type MatchPlayerDeleteOne struct { - mpd *MatchPlayerDelete + _d *MatchPlayerDelete } // Where appends a list predicates to the MatchPlayerDelete builder. -func (mpdo *MatchPlayerDeleteOne) Where(ps ...predicate.MatchPlayer) *MatchPlayerDeleteOne { - mpdo.mpd.mutation.Where(ps...) - return mpdo +func (_d *MatchPlayerDeleteOne) Where(ps ...predicate.MatchPlayer) *MatchPlayerDeleteOne { + _d._d.mutation.Where(ps...) + return _d } // Exec executes the deletion query. -func (mpdo *MatchPlayerDeleteOne) Exec(ctx context.Context) error { - n, err := mpdo.mpd.Exec(ctx) +func (_d *MatchPlayerDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) switch { case err != nil: return err @@ -81,8 +81,8 @@ func (mpdo *MatchPlayerDeleteOne) Exec(ctx context.Context) error { } // ExecX is like Exec, but panics if an error occurs. -func (mpdo *MatchPlayerDeleteOne) ExecX(ctx context.Context) { - if err := mpdo.Exec(ctx); err != nil { +func (_d *MatchPlayerDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { panic(err) } } diff --git a/ent/matchplayer_query.go b/ent/matchplayer_query.go index 537abdd..26fbce3 100644 --- a/ent/matchplayer_query.go +++ b/ent/matchplayer_query.go @@ -8,6 +8,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -41,44 +42,44 @@ type MatchPlayerQuery struct { } // Where adds a new predicate for the MatchPlayerQuery builder. -func (mpq *MatchPlayerQuery) Where(ps ...predicate.MatchPlayer) *MatchPlayerQuery { - mpq.predicates = append(mpq.predicates, ps...) - return mpq +func (_q *MatchPlayerQuery) Where(ps ...predicate.MatchPlayer) *MatchPlayerQuery { + _q.predicates = append(_q.predicates, ps...) + return _q } // Limit the number of records to be returned by this query. -func (mpq *MatchPlayerQuery) Limit(limit int) *MatchPlayerQuery { - mpq.ctx.Limit = &limit - return mpq +func (_q *MatchPlayerQuery) Limit(limit int) *MatchPlayerQuery { + _q.ctx.Limit = &limit + return _q } // Offset to start from. -func (mpq *MatchPlayerQuery) Offset(offset int) *MatchPlayerQuery { - mpq.ctx.Offset = &offset - return mpq +func (_q *MatchPlayerQuery) Offset(offset int) *MatchPlayerQuery { + _q.ctx.Offset = &offset + return _q } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. -func (mpq *MatchPlayerQuery) Unique(unique bool) *MatchPlayerQuery { - mpq.ctx.Unique = &unique - return mpq +func (_q *MatchPlayerQuery) Unique(unique bool) *MatchPlayerQuery { + _q.ctx.Unique = &unique + return _q } // Order specifies how the records should be ordered. -func (mpq *MatchPlayerQuery) Order(o ...matchplayer.OrderOption) *MatchPlayerQuery { - mpq.order = append(mpq.order, o...) - return mpq +func (_q *MatchPlayerQuery) Order(o ...matchplayer.OrderOption) *MatchPlayerQuery { + _q.order = append(_q.order, o...) + return _q } // QueryMatches chains the current query on the "matches" edge. -func (mpq *MatchPlayerQuery) QueryMatches() *MatchQuery { - query := (&MatchClient{config: mpq.config}).Query() +func (_q *MatchPlayerQuery) QueryMatches() *MatchQuery { + query := (&MatchClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := mpq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := mpq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -87,20 +88,20 @@ func (mpq *MatchPlayerQuery) QueryMatches() *MatchQuery { sqlgraph.To(match.Table, match.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, matchplayer.MatchesTable, matchplayer.MatchesColumn), ) - fromU = sqlgraph.SetNeighbors(mpq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryPlayers chains the current query on the "players" edge. -func (mpq *MatchPlayerQuery) QueryPlayers() *PlayerQuery { - query := (&PlayerClient{config: mpq.config}).Query() +func (_q *MatchPlayerQuery) QueryPlayers() *PlayerQuery { + query := (&PlayerClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := mpq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := mpq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -109,20 +110,20 @@ func (mpq *MatchPlayerQuery) QueryPlayers() *PlayerQuery { sqlgraph.To(player.Table, player.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, matchplayer.PlayersTable, matchplayer.PlayersColumn), ) - fromU = sqlgraph.SetNeighbors(mpq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryWeaponStats chains the current query on the "weapon_stats" edge. -func (mpq *MatchPlayerQuery) QueryWeaponStats() *WeaponQuery { - query := (&WeaponClient{config: mpq.config}).Query() +func (_q *MatchPlayerQuery) QueryWeaponStats() *WeaponQuery { + query := (&WeaponClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := mpq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := mpq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -131,20 +132,20 @@ func (mpq *MatchPlayerQuery) QueryWeaponStats() *WeaponQuery { sqlgraph.To(weapon.Table, weapon.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.WeaponStatsTable, matchplayer.WeaponStatsColumn), ) - fromU = sqlgraph.SetNeighbors(mpq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryRoundStats chains the current query on the "round_stats" edge. -func (mpq *MatchPlayerQuery) QueryRoundStats() *RoundStatsQuery { - query := (&RoundStatsClient{config: mpq.config}).Query() +func (_q *MatchPlayerQuery) QueryRoundStats() *RoundStatsQuery { + query := (&RoundStatsClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := mpq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := mpq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -153,20 +154,20 @@ func (mpq *MatchPlayerQuery) QueryRoundStats() *RoundStatsQuery { sqlgraph.To(roundstats.Table, roundstats.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.RoundStatsTable, matchplayer.RoundStatsColumn), ) - fromU = sqlgraph.SetNeighbors(mpq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QuerySpray chains the current query on the "spray" edge. -func (mpq *MatchPlayerQuery) QuerySpray() *SprayQuery { - query := (&SprayClient{config: mpq.config}).Query() +func (_q *MatchPlayerQuery) QuerySpray() *SprayQuery { + query := (&SprayClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := mpq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := mpq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -175,20 +176,20 @@ func (mpq *MatchPlayerQuery) QuerySpray() *SprayQuery { sqlgraph.To(spray.Table, spray.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.SprayTable, matchplayer.SprayColumn), ) - fromU = sqlgraph.SetNeighbors(mpq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryMessages chains the current query on the "messages" edge. -func (mpq *MatchPlayerQuery) QueryMessages() *MessagesQuery { - query := (&MessagesClient{config: mpq.config}).Query() +func (_q *MatchPlayerQuery) QueryMessages() *MessagesQuery { + query := (&MessagesClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := mpq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := mpq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -197,7 +198,7 @@ func (mpq *MatchPlayerQuery) QueryMessages() *MessagesQuery { sqlgraph.To(messages.Table, messages.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.MessagesTable, matchplayer.MessagesColumn), ) - fromU = sqlgraph.SetNeighbors(mpq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query @@ -205,8 +206,8 @@ func (mpq *MatchPlayerQuery) QueryMessages() *MessagesQuery { // First returns the first MatchPlayer entity from the query. // Returns a *NotFoundError when no MatchPlayer was found. -func (mpq *MatchPlayerQuery) First(ctx context.Context) (*MatchPlayer, error) { - nodes, err := mpq.Limit(1).All(setContextOp(ctx, mpq.ctx, "First")) +func (_q *MatchPlayerQuery) First(ctx context.Context) (*MatchPlayer, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -217,8 +218,8 @@ func (mpq *MatchPlayerQuery) First(ctx context.Context) (*MatchPlayer, error) { } // FirstX is like First, but panics if an error occurs. -func (mpq *MatchPlayerQuery) FirstX(ctx context.Context) *MatchPlayer { - node, err := mpq.First(ctx) +func (_q *MatchPlayerQuery) FirstX(ctx context.Context) *MatchPlayer { + node, err := _q.First(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -227,9 +228,9 @@ func (mpq *MatchPlayerQuery) FirstX(ctx context.Context) *MatchPlayer { // FirstID returns the first MatchPlayer ID from the query. // Returns a *NotFoundError when no MatchPlayer ID was found. -func (mpq *MatchPlayerQuery) FirstID(ctx context.Context) (id int, err error) { +func (_q *MatchPlayerQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = mpq.Limit(1).IDs(setContextOp(ctx, mpq.ctx, "FirstID")); err != nil { + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -240,8 +241,8 @@ func (mpq *MatchPlayerQuery) FirstID(ctx context.Context) (id int, err error) { } // FirstIDX is like FirstID, but panics if an error occurs. -func (mpq *MatchPlayerQuery) FirstIDX(ctx context.Context) int { - id, err := mpq.FirstID(ctx) +func (_q *MatchPlayerQuery) FirstIDX(ctx context.Context) int { + id, err := _q.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -251,8 +252,8 @@ func (mpq *MatchPlayerQuery) FirstIDX(ctx context.Context) int { // Only returns a single MatchPlayer entity found by the query, ensuring it only returns one. // Returns a *NotSingularError when more than one MatchPlayer entity is found. // Returns a *NotFoundError when no MatchPlayer entities are found. -func (mpq *MatchPlayerQuery) Only(ctx context.Context) (*MatchPlayer, error) { - nodes, err := mpq.Limit(2).All(setContextOp(ctx, mpq.ctx, "Only")) +func (_q *MatchPlayerQuery) Only(ctx context.Context) (*MatchPlayer, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -267,8 +268,8 @@ func (mpq *MatchPlayerQuery) Only(ctx context.Context) (*MatchPlayer, error) { } // OnlyX is like Only, but panics if an error occurs. -func (mpq *MatchPlayerQuery) OnlyX(ctx context.Context) *MatchPlayer { - node, err := mpq.Only(ctx) +func (_q *MatchPlayerQuery) OnlyX(ctx context.Context) *MatchPlayer { + node, err := _q.Only(ctx) if err != nil { panic(err) } @@ -278,9 +279,9 @@ func (mpq *MatchPlayerQuery) OnlyX(ctx context.Context) *MatchPlayer { // OnlyID is like Only, but returns the only MatchPlayer ID in the query. // Returns a *NotSingularError when more than one MatchPlayer ID is found. // Returns a *NotFoundError when no entities are found. -func (mpq *MatchPlayerQuery) OnlyID(ctx context.Context) (id int, err error) { +func (_q *MatchPlayerQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = mpq.Limit(2).IDs(setContextOp(ctx, mpq.ctx, "OnlyID")); err != nil { + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -295,8 +296,8 @@ func (mpq *MatchPlayerQuery) OnlyID(ctx context.Context) (id int, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (mpq *MatchPlayerQuery) OnlyIDX(ctx context.Context) int { - id, err := mpq.OnlyID(ctx) +func (_q *MatchPlayerQuery) OnlyIDX(ctx context.Context) int { + id, err := _q.OnlyID(ctx) if err != nil { panic(err) } @@ -304,18 +305,18 @@ func (mpq *MatchPlayerQuery) OnlyIDX(ctx context.Context) int { } // All executes the query and returns a list of MatchPlayers. -func (mpq *MatchPlayerQuery) All(ctx context.Context) ([]*MatchPlayer, error) { - ctx = setContextOp(ctx, mpq.ctx, "All") - if err := mpq.prepareQuery(ctx); err != nil { +func (_q *MatchPlayerQuery) All(ctx context.Context) ([]*MatchPlayer, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { return nil, err } qr := querierAll[[]*MatchPlayer, *MatchPlayerQuery]() - return withInterceptors[[]*MatchPlayer](ctx, mpq, qr, mpq.inters) + return withInterceptors[[]*MatchPlayer](ctx, _q, qr, _q.inters) } // AllX is like All, but panics if an error occurs. -func (mpq *MatchPlayerQuery) AllX(ctx context.Context) []*MatchPlayer { - nodes, err := mpq.All(ctx) +func (_q *MatchPlayerQuery) AllX(ctx context.Context) []*MatchPlayer { + nodes, err := _q.All(ctx) if err != nil { panic(err) } @@ -323,20 +324,20 @@ func (mpq *MatchPlayerQuery) AllX(ctx context.Context) []*MatchPlayer { } // IDs executes the query and returns a list of MatchPlayer IDs. -func (mpq *MatchPlayerQuery) IDs(ctx context.Context) (ids []int, err error) { - if mpq.ctx.Unique == nil && mpq.path != nil { - mpq.Unique(true) +func (_q *MatchPlayerQuery) IDs(ctx context.Context) (ids []int, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) } - ctx = setContextOp(ctx, mpq.ctx, "IDs") - if err = mpq.Select(matchplayer.FieldID).Scan(ctx, &ids); err != nil { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(matchplayer.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. -func (mpq *MatchPlayerQuery) IDsX(ctx context.Context) []int { - ids, err := mpq.IDs(ctx) +func (_q *MatchPlayerQuery) IDsX(ctx context.Context) []int { + ids, err := _q.IDs(ctx) if err != nil { panic(err) } @@ -344,17 +345,17 @@ func (mpq *MatchPlayerQuery) IDsX(ctx context.Context) []int { } // Count returns the count of the given query. -func (mpq *MatchPlayerQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, mpq.ctx, "Count") - if err := mpq.prepareQuery(ctx); err != nil { +func (_q *MatchPlayerQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { return 0, err } - return withInterceptors[int](ctx, mpq, querierCount[*MatchPlayerQuery](), mpq.inters) + return withInterceptors[int](ctx, _q, querierCount[*MatchPlayerQuery](), _q.inters) } // CountX is like Count, but panics if an error occurs. -func (mpq *MatchPlayerQuery) CountX(ctx context.Context) int { - count, err := mpq.Count(ctx) +func (_q *MatchPlayerQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) if err != nil { panic(err) } @@ -362,9 +363,9 @@ func (mpq *MatchPlayerQuery) CountX(ctx context.Context) int { } // Exist returns true if the query has elements in the graph. -func (mpq *MatchPlayerQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, mpq.ctx, "Exist") - switch _, err := mpq.FirstID(ctx); { +func (_q *MatchPlayerQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { case IsNotFound(err): return false, nil case err != nil: @@ -375,8 +376,8 @@ func (mpq *MatchPlayerQuery) Exist(ctx context.Context) (bool, error) { } // ExistX is like Exist, but panics if an error occurs. -func (mpq *MatchPlayerQuery) ExistX(ctx context.Context) bool { - exist, err := mpq.Exist(ctx) +func (_q *MatchPlayerQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) if err != nil { panic(err) } @@ -385,92 +386,93 @@ func (mpq *MatchPlayerQuery) ExistX(ctx context.Context) bool { // Clone returns a duplicate of the MatchPlayerQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. -func (mpq *MatchPlayerQuery) Clone() *MatchPlayerQuery { - if mpq == nil { +func (_q *MatchPlayerQuery) Clone() *MatchPlayerQuery { + if _q == nil { return nil } return &MatchPlayerQuery{ - config: mpq.config, - ctx: mpq.ctx.Clone(), - order: append([]matchplayer.OrderOption{}, mpq.order...), - inters: append([]Interceptor{}, mpq.inters...), - predicates: append([]predicate.MatchPlayer{}, mpq.predicates...), - withMatches: mpq.withMatches.Clone(), - withPlayers: mpq.withPlayers.Clone(), - withWeaponStats: mpq.withWeaponStats.Clone(), - withRoundStats: mpq.withRoundStats.Clone(), - withSpray: mpq.withSpray.Clone(), - withMessages: mpq.withMessages.Clone(), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]matchplayer.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.MatchPlayer{}, _q.predicates...), + withMatches: _q.withMatches.Clone(), + withPlayers: _q.withPlayers.Clone(), + withWeaponStats: _q.withWeaponStats.Clone(), + withRoundStats: _q.withRoundStats.Clone(), + withSpray: _q.withSpray.Clone(), + withMessages: _q.withMessages.Clone(), // clone intermediate query. - sql: mpq.sql.Clone(), - path: mpq.path, + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), } } // WithMatches tells the query-builder to eager-load the nodes that are connected to // the "matches" edge. The optional arguments are used to configure the query builder of the edge. -func (mpq *MatchPlayerQuery) WithMatches(opts ...func(*MatchQuery)) *MatchPlayerQuery { - query := (&MatchClient{config: mpq.config}).Query() +func (_q *MatchPlayerQuery) WithMatches(opts ...func(*MatchQuery)) *MatchPlayerQuery { + query := (&MatchClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - mpq.withMatches = query - return mpq + _q.withMatches = query + return _q } // WithPlayers tells the query-builder to eager-load the nodes that are connected to // the "players" edge. The optional arguments are used to configure the query builder of the edge. -func (mpq *MatchPlayerQuery) WithPlayers(opts ...func(*PlayerQuery)) *MatchPlayerQuery { - query := (&PlayerClient{config: mpq.config}).Query() +func (_q *MatchPlayerQuery) WithPlayers(opts ...func(*PlayerQuery)) *MatchPlayerQuery { + query := (&PlayerClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - mpq.withPlayers = query - return mpq + _q.withPlayers = query + return _q } // WithWeaponStats tells the query-builder to eager-load the nodes that are connected to // the "weapon_stats" edge. The optional arguments are used to configure the query builder of the edge. -func (mpq *MatchPlayerQuery) WithWeaponStats(opts ...func(*WeaponQuery)) *MatchPlayerQuery { - query := (&WeaponClient{config: mpq.config}).Query() +func (_q *MatchPlayerQuery) WithWeaponStats(opts ...func(*WeaponQuery)) *MatchPlayerQuery { + query := (&WeaponClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - mpq.withWeaponStats = query - return mpq + _q.withWeaponStats = query + return _q } // WithRoundStats tells the query-builder to eager-load the nodes that are connected to // the "round_stats" edge. The optional arguments are used to configure the query builder of the edge. -func (mpq *MatchPlayerQuery) WithRoundStats(opts ...func(*RoundStatsQuery)) *MatchPlayerQuery { - query := (&RoundStatsClient{config: mpq.config}).Query() +func (_q *MatchPlayerQuery) WithRoundStats(opts ...func(*RoundStatsQuery)) *MatchPlayerQuery { + query := (&RoundStatsClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - mpq.withRoundStats = query - return mpq + _q.withRoundStats = query + return _q } // WithSpray tells the query-builder to eager-load the nodes that are connected to // the "spray" edge. The optional arguments are used to configure the query builder of the edge. -func (mpq *MatchPlayerQuery) WithSpray(opts ...func(*SprayQuery)) *MatchPlayerQuery { - query := (&SprayClient{config: mpq.config}).Query() +func (_q *MatchPlayerQuery) WithSpray(opts ...func(*SprayQuery)) *MatchPlayerQuery { + query := (&SprayClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - mpq.withSpray = query - return mpq + _q.withSpray = query + return _q } // WithMessages tells the query-builder to eager-load the nodes that are connected to // the "messages" edge. The optional arguments are used to configure the query builder of the edge. -func (mpq *MatchPlayerQuery) WithMessages(opts ...func(*MessagesQuery)) *MatchPlayerQuery { - query := (&MessagesClient{config: mpq.config}).Query() +func (_q *MatchPlayerQuery) WithMessages(opts ...func(*MessagesQuery)) *MatchPlayerQuery { + query := (&MessagesClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - mpq.withMessages = query - return mpq + _q.withMessages = query + return _q } // GroupBy is used to group vertices by one or more fields/columns. @@ -487,10 +489,10 @@ 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 { - mpq.ctx.Fields = append([]string{field}, fields...) - grbuild := &MatchPlayerGroupBy{build: mpq} - grbuild.flds = &mpq.ctx.Fields +func (_q *MatchPlayerQuery) GroupBy(field string, fields ...string) *MatchPlayerGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &MatchPlayerGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields grbuild.label = matchplayer.Label grbuild.scan = grbuild.Scan return grbuild @@ -508,114 +510,114 @@ 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.ctx.Fields = append(mpq.ctx.Fields, fields...) - sbuild := &MatchPlayerSelect{MatchPlayerQuery: mpq} +func (_q *MatchPlayerQuery) Select(fields ...string) *MatchPlayerSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &MatchPlayerSelect{MatchPlayerQuery: _q} sbuild.label = matchplayer.Label - sbuild.flds, sbuild.scan = &mpq.ctx.Fields, sbuild.Scan + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan return sbuild } // Aggregate returns a MatchPlayerSelect configured with the given aggregations. -func (mpq *MatchPlayerQuery) Aggregate(fns ...AggregateFunc) *MatchPlayerSelect { - return mpq.Select().Aggregate(fns...) +func (_q *MatchPlayerQuery) Aggregate(fns ...AggregateFunc) *MatchPlayerSelect { + return _q.Select().Aggregate(fns...) } -func (mpq *MatchPlayerQuery) prepareQuery(ctx context.Context) error { - for _, inter := range mpq.inters { +func (_q *MatchPlayerQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { if inter == nil { return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") } if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, mpq); err != nil { + if err := trv.Traverse(ctx, _q); err != nil { return err } } } - for _, f := range mpq.ctx.Fields { + for _, f := range _q.ctx.Fields { if !matchplayer.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } - if mpq.path != nil { - prev, err := mpq.path(ctx) + if _q.path != nil { + prev, err := _q.path(ctx) if err != nil { return err } - mpq.sql = prev + _q.sql = prev } return nil } -func (mpq *MatchPlayerQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*MatchPlayer, error) { +func (_q *MatchPlayerQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*MatchPlayer, error) { var ( nodes = []*MatchPlayer{} - _spec = mpq.querySpec() + _spec = _q.querySpec() loadedTypes = [6]bool{ - mpq.withMatches != nil, - mpq.withPlayers != nil, - mpq.withWeaponStats != nil, - mpq.withRoundStats != nil, - mpq.withSpray != nil, - mpq.withMessages != nil, + _q.withMatches != nil, + _q.withPlayers != nil, + _q.withWeaponStats != nil, + _q.withRoundStats != nil, + _q.withSpray != nil, + _q.withMessages != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { return (*MatchPlayer).scanValues(nil, columns) } _spec.Assign = func(columns []string, values []any) error { - node := &MatchPlayer{config: mpq.config} + node := &MatchPlayer{config: _q.config} nodes = append(nodes, node) node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) } - if len(mpq.modifiers) > 0 { - _spec.Modifiers = mpq.modifiers + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } for i := range hooks { hooks[i](ctx, _spec) } - if err := sqlgraph.QueryNodes(ctx, mpq.driver, _spec); err != nil { + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { return nil, err } if len(nodes) == 0 { return nodes, nil } - if query := mpq.withMatches; query != nil { - if err := mpq.loadMatches(ctx, query, nodes, nil, + if query := _q.withMatches; query != nil { + if err := _q.loadMatches(ctx, query, nodes, nil, func(n *MatchPlayer, e *Match) { n.Edges.Matches = e }); err != nil { return nil, err } } - if query := mpq.withPlayers; query != nil { - if err := mpq.loadPlayers(ctx, query, nodes, nil, + if query := _q.withPlayers; query != nil { + if err := _q.loadPlayers(ctx, query, nodes, nil, func(n *MatchPlayer, e *Player) { n.Edges.Players = e }); err != nil { return nil, err } } - if query := mpq.withWeaponStats; query != nil { - if err := mpq.loadWeaponStats(ctx, query, nodes, + if query := _q.withWeaponStats; query != nil { + if err := _q.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 } } - if query := mpq.withRoundStats; query != nil { - if err := mpq.loadRoundStats(ctx, query, nodes, + if query := _q.withRoundStats; query != nil { + if err := _q.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 } } - if query := mpq.withSpray; query != nil { - if err := mpq.loadSpray(ctx, query, nodes, + if query := _q.withSpray; query != nil { + if err := _q.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 } } - if query := mpq.withMessages; query != nil { - if err := mpq.loadMessages(ctx, query, nodes, + if query := _q.withMessages; query != nil { + if err := _q.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 @@ -624,7 +626,7 @@ func (mpq *MatchPlayerQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([] return nodes, nil } -func (mpq *MatchPlayerQuery) loadMatches(ctx context.Context, query *MatchQuery, nodes []*MatchPlayer, init func(*MatchPlayer), assign func(*MatchPlayer, *Match)) error { +func (_q *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 { @@ -653,7 +655,7 @@ func (mpq *MatchPlayerQuery) loadMatches(ctx context.Context, query *MatchQuery, } return nil } -func (mpq *MatchPlayerQuery) loadPlayers(ctx context.Context, query *PlayerQuery, nodes []*MatchPlayer, init func(*MatchPlayer), assign func(*MatchPlayer, *Player)) error { +func (_q *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 { @@ -682,7 +684,7 @@ func (mpq *MatchPlayerQuery) loadPlayers(ctx context.Context, query *PlayerQuery } return nil } -func (mpq *MatchPlayerQuery) loadWeaponStats(ctx context.Context, query *WeaponQuery, nodes []*MatchPlayer, init func(*MatchPlayer), assign func(*MatchPlayer, *Weapon)) error { +func (_q *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 { @@ -713,7 +715,7 @@ func (mpq *MatchPlayerQuery) loadWeaponStats(ctx context.Context, query *WeaponQ } return nil } -func (mpq *MatchPlayerQuery) loadRoundStats(ctx context.Context, query *RoundStatsQuery, nodes []*MatchPlayer, init func(*MatchPlayer), assign func(*MatchPlayer, *RoundStats)) error { +func (_q *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 { @@ -744,7 +746,7 @@ func (mpq *MatchPlayerQuery) loadRoundStats(ctx context.Context, query *RoundSta } return nil } -func (mpq *MatchPlayerQuery) loadSpray(ctx context.Context, query *SprayQuery, nodes []*MatchPlayer, init func(*MatchPlayer), assign func(*MatchPlayer, *Spray)) error { +func (_q *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 { @@ -775,7 +777,7 @@ func (mpq *MatchPlayerQuery) loadSpray(ctx context.Context, query *SprayQuery, n } return nil } -func (mpq *MatchPlayerQuery) loadMessages(ctx context.Context, query *MessagesQuery, nodes []*MatchPlayer, init func(*MatchPlayer), assign func(*MatchPlayer, *Messages)) error { +func (_q *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 { @@ -807,27 +809,27 @@ func (mpq *MatchPlayerQuery) loadMessages(ctx context.Context, query *MessagesQu return nil } -func (mpq *MatchPlayerQuery) sqlCount(ctx context.Context) (int, error) { - _spec := mpq.querySpec() - if len(mpq.modifiers) > 0 { - _spec.Modifiers = mpq.modifiers +func (_q *MatchPlayerQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } - _spec.Node.Columns = mpq.ctx.Fields - if len(mpq.ctx.Fields) > 0 { - _spec.Unique = mpq.ctx.Unique != nil && *mpq.ctx.Unique + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique } - return sqlgraph.CountNodes(ctx, mpq.driver, _spec) + return sqlgraph.CountNodes(ctx, _q.driver, _spec) } -func (mpq *MatchPlayerQuery) querySpec() *sqlgraph.QuerySpec { +func (_q *MatchPlayerQuery) querySpec() *sqlgraph.QuerySpec { _spec := sqlgraph.NewQuerySpec(matchplayer.Table, matchplayer.Columns, sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt)) - _spec.From = mpq.sql - if unique := mpq.ctx.Unique; unique != nil { + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { _spec.Unique = *unique - } else if mpq.path != nil { + } else if _q.path != nil { _spec.Unique = true } - if fields := mpq.ctx.Fields; len(fields) > 0 { + if fields := _q.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, matchplayer.FieldID) for i := range fields { @@ -835,27 +837,27 @@ func (mpq *MatchPlayerQuery) querySpec() *sqlgraph.QuerySpec { _spec.Node.Columns = append(_spec.Node.Columns, fields[i]) } } - if mpq.withMatches != nil { + if _q.withMatches != nil { _spec.Node.AddColumnOnce(matchplayer.FieldMatchStats) } - if mpq.withPlayers != nil { + if _q.withPlayers != nil { _spec.Node.AddColumnOnce(matchplayer.FieldPlayerStats) } } - if ps := mpq.predicates; len(ps) > 0 { + if ps := _q.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if limit := mpq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := mpq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { _spec.Offset = *offset } - if ps := mpq.order; len(ps) > 0 { + if ps := _q.order; len(ps) > 0 { _spec.Order = func(selector *sql.Selector) { for i := range ps { ps[i](selector) @@ -865,45 +867,45 @@ func (mpq *MatchPlayerQuery) querySpec() *sqlgraph.QuerySpec { return _spec } -func (mpq *MatchPlayerQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(mpq.driver.Dialect()) +func (_q *MatchPlayerQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) t1 := builder.Table(matchplayer.Table) - columns := mpq.ctx.Fields + columns := _q.ctx.Fields if len(columns) == 0 { columns = matchplayer.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) - if mpq.sql != nil { - selector = mpq.sql + if _q.sql != nil { + selector = _q.sql selector.Select(selector.Columns(columns...)...) } - if mpq.ctx.Unique != nil && *mpq.ctx.Unique { + if _q.ctx.Unique != nil && *_q.ctx.Unique { selector.Distinct() } - for _, m := range mpq.modifiers { + for _, m := range _q.modifiers { m(selector) } - for _, p := range mpq.predicates { + for _, p := range _q.predicates { p(selector) } - for _, p := range mpq.order { + for _, p := range _q.order { p(selector) } - if offset := mpq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { // limit is mandatory for offset clause. We start // with default value, and override it below if needed. selector.Offset(*offset).Limit(math.MaxInt32) } - if limit := mpq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector } // Modify adds a query modifier for attaching custom logic to queries. -func (mpq *MatchPlayerQuery) Modify(modifiers ...func(s *sql.Selector)) *MatchPlayerSelect { - mpq.modifiers = append(mpq.modifiers, modifiers...) - return mpq.Select() +func (_q *MatchPlayerQuery) Modify(modifiers ...func(s *sql.Selector)) *MatchPlayerSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() } // MatchPlayerGroupBy is the group-by builder for MatchPlayer entities. @@ -913,41 +915,41 @@ type MatchPlayerGroupBy struct { } // Aggregate adds the given aggregation functions to the group-by query. -func (mpgb *MatchPlayerGroupBy) Aggregate(fns ...AggregateFunc) *MatchPlayerGroupBy { - mpgb.fns = append(mpgb.fns, fns...) - return mpgb +func (_g *MatchPlayerGroupBy) Aggregate(fns ...AggregateFunc) *MatchPlayerGroupBy { + _g.fns = append(_g.fns, fns...) + return _g } // Scan applies the selector query and scans the result into the given value. -func (mpgb *MatchPlayerGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, mpgb.build.ctx, "GroupBy") - if err := mpgb.build.prepareQuery(ctx); err != nil { +func (_g *MatchPlayerGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*MatchPlayerQuery, *MatchPlayerGroupBy](ctx, mpgb.build, mpgb, mpgb.build.inters, v) + return scanWithInterceptors[*MatchPlayerQuery, *MatchPlayerGroupBy](ctx, _g.build, _g, _g.build.inters, v) } -func (mpgb *MatchPlayerGroupBy) sqlScan(ctx context.Context, root *MatchPlayerQuery, v any) error { +func (_g *MatchPlayerGroupBy) sqlScan(ctx context.Context, root *MatchPlayerQuery, v any) error { selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(mpgb.fns)) - for _, fn := range mpgb.fns { + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { aggregation = append(aggregation, fn(selector)) } if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*mpgb.flds)+len(mpgb.fns)) - for _, f := range *mpgb.flds { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { columns = append(columns, selector.C(f)) } columns = append(columns, aggregation...) selector.Select(columns...) } - selector.GroupBy(selector.Columns(*mpgb.flds...)...) + selector.GroupBy(selector.Columns(*_g.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := mpgb.build.driver.Query(ctx, query, args, rows); err != nil { + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -961,27 +963,27 @@ type MatchPlayerSelect struct { } // Aggregate adds the given aggregation functions to the selector query. -func (mps *MatchPlayerSelect) Aggregate(fns ...AggregateFunc) *MatchPlayerSelect { - mps.fns = append(mps.fns, fns...) - return mps +func (_s *MatchPlayerSelect) Aggregate(fns ...AggregateFunc) *MatchPlayerSelect { + _s.fns = append(_s.fns, fns...) + return _s } // Scan applies the selector query and scans the result into the given value. -func (mps *MatchPlayerSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, mps.ctx, "Select") - if err := mps.prepareQuery(ctx); err != nil { +func (_s *MatchPlayerSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*MatchPlayerQuery, *MatchPlayerSelect](ctx, mps.MatchPlayerQuery, mps, mps.inters, v) + return scanWithInterceptors[*MatchPlayerQuery, *MatchPlayerSelect](ctx, _s.MatchPlayerQuery, _s, _s.inters, v) } -func (mps *MatchPlayerSelect) sqlScan(ctx context.Context, root *MatchPlayerQuery, v any) error { +func (_s *MatchPlayerSelect) sqlScan(ctx context.Context, root *MatchPlayerQuery, v any) error { selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(mps.fns)) - for _, fn := range mps.fns { + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { aggregation = append(aggregation, fn(selector)) } - switch n := len(*mps.selector.flds); { + switch n := len(*_s.selector.flds); { case n == 0 && len(aggregation) > 0: selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: @@ -989,7 +991,7 @@ func (mps *MatchPlayerSelect) sqlScan(ctx context.Context, root *MatchPlayerQuer } rows := &sql.Rows{} query, args := selector.Query() - if err := mps.driver.Query(ctx, query, args, rows); err != nil { + if err := _s.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -997,7 +999,7 @@ func (mps *MatchPlayerSelect) sqlScan(ctx context.Context, root *MatchPlayerQuer } // Modify adds a query modifier for attaching custom logic to queries. -func (mps *MatchPlayerSelect) Modify(modifiers ...func(s *sql.Selector)) *MatchPlayerSelect { - mps.modifiers = append(mps.modifiers, modifiers...) - return mps +func (_s *MatchPlayerSelect) Modify(modifiers ...func(s *sql.Selector)) *MatchPlayerSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s } diff --git a/ent/matchplayer_update.go b/ent/matchplayer_update.go index e31f014..85f5a37 100644 --- a/ent/matchplayer_update.go +++ b/ent/matchplayer_update.go @@ -29,983 +29,1039 @@ type MatchPlayerUpdate struct { } // Where appends a list predicates to the MatchPlayerUpdate builder. -func (mpu *MatchPlayerUpdate) Where(ps ...predicate.MatchPlayer) *MatchPlayerUpdate { - mpu.mutation.Where(ps...) - return mpu +func (_u *MatchPlayerUpdate) Where(ps ...predicate.MatchPlayer) *MatchPlayerUpdate { + _u.mutation.Where(ps...) + return _u } // SetTeamID sets the "team_id" field. -func (mpu *MatchPlayerUpdate) SetTeamID(i int) *MatchPlayerUpdate { - mpu.mutation.ResetTeamID() - mpu.mutation.SetTeamID(i) - return mpu +func (_u *MatchPlayerUpdate) SetTeamID(v int) *MatchPlayerUpdate { + _u.mutation.ResetTeamID() + _u.mutation.SetTeamID(v) + return _u } -// AddTeamID adds i to the "team_id" field. -func (mpu *MatchPlayerUpdate) AddTeamID(i int) *MatchPlayerUpdate { - mpu.mutation.AddTeamID(i) - return mpu +// SetNillableTeamID sets the "team_id" field if the given value is not nil. +func (_u *MatchPlayerUpdate) SetNillableTeamID(v *int) *MatchPlayerUpdate { + if v != nil { + _u.SetTeamID(*v) + } + return _u +} + +// AddTeamID adds value to the "team_id" field. +func (_u *MatchPlayerUpdate) AddTeamID(v int) *MatchPlayerUpdate { + _u.mutation.AddTeamID(v) + return _u } // SetKills sets the "kills" field. -func (mpu *MatchPlayerUpdate) SetKills(i int) *MatchPlayerUpdate { - mpu.mutation.ResetKills() - mpu.mutation.SetKills(i) - return mpu +func (_u *MatchPlayerUpdate) SetKills(v int) *MatchPlayerUpdate { + _u.mutation.ResetKills() + _u.mutation.SetKills(v) + return _u } -// AddKills adds i to the "kills" field. -func (mpu *MatchPlayerUpdate) AddKills(i int) *MatchPlayerUpdate { - mpu.mutation.AddKills(i) - return mpu +// SetNillableKills sets the "kills" field if the given value is not nil. +func (_u *MatchPlayerUpdate) SetNillableKills(v *int) *MatchPlayerUpdate { + if v != nil { + _u.SetKills(*v) + } + return _u +} + +// AddKills adds value to the "kills" field. +func (_u *MatchPlayerUpdate) AddKills(v int) *MatchPlayerUpdate { + _u.mutation.AddKills(v) + return _u } // SetDeaths sets the "deaths" field. -func (mpu *MatchPlayerUpdate) SetDeaths(i int) *MatchPlayerUpdate { - mpu.mutation.ResetDeaths() - mpu.mutation.SetDeaths(i) - return mpu +func (_u *MatchPlayerUpdate) SetDeaths(v int) *MatchPlayerUpdate { + _u.mutation.ResetDeaths() + _u.mutation.SetDeaths(v) + return _u } -// AddDeaths adds i to the "deaths" field. -func (mpu *MatchPlayerUpdate) AddDeaths(i int) *MatchPlayerUpdate { - mpu.mutation.AddDeaths(i) - return mpu +// SetNillableDeaths sets the "deaths" field if the given value is not nil. +func (_u *MatchPlayerUpdate) SetNillableDeaths(v *int) *MatchPlayerUpdate { + if v != nil { + _u.SetDeaths(*v) + } + return _u +} + +// AddDeaths adds value to the "deaths" field. +func (_u *MatchPlayerUpdate) AddDeaths(v int) *MatchPlayerUpdate { + _u.mutation.AddDeaths(v) + return _u } // SetAssists sets the "assists" field. -func (mpu *MatchPlayerUpdate) SetAssists(i int) *MatchPlayerUpdate { - mpu.mutation.ResetAssists() - mpu.mutation.SetAssists(i) - return mpu +func (_u *MatchPlayerUpdate) SetAssists(v int) *MatchPlayerUpdate { + _u.mutation.ResetAssists() + _u.mutation.SetAssists(v) + return _u } -// AddAssists adds i to the "assists" field. -func (mpu *MatchPlayerUpdate) AddAssists(i int) *MatchPlayerUpdate { - mpu.mutation.AddAssists(i) - return mpu +// SetNillableAssists sets the "assists" field if the given value is not nil. +func (_u *MatchPlayerUpdate) SetNillableAssists(v *int) *MatchPlayerUpdate { + if v != nil { + _u.SetAssists(*v) + } + return _u +} + +// AddAssists adds value to the "assists" field. +func (_u *MatchPlayerUpdate) AddAssists(v int) *MatchPlayerUpdate { + _u.mutation.AddAssists(v) + return _u } // SetHeadshot sets the "headshot" field. -func (mpu *MatchPlayerUpdate) SetHeadshot(i int) *MatchPlayerUpdate { - mpu.mutation.ResetHeadshot() - mpu.mutation.SetHeadshot(i) - return mpu +func (_u *MatchPlayerUpdate) SetHeadshot(v int) *MatchPlayerUpdate { + _u.mutation.ResetHeadshot() + _u.mutation.SetHeadshot(v) + return _u } -// AddHeadshot adds i to the "headshot" field. -func (mpu *MatchPlayerUpdate) AddHeadshot(i int) *MatchPlayerUpdate { - mpu.mutation.AddHeadshot(i) - return mpu +// SetNillableHeadshot sets the "headshot" field if the given value is not nil. +func (_u *MatchPlayerUpdate) SetNillableHeadshot(v *int) *MatchPlayerUpdate { + if v != nil { + _u.SetHeadshot(*v) + } + return _u +} + +// AddHeadshot adds value to the "headshot" field. +func (_u *MatchPlayerUpdate) AddHeadshot(v int) *MatchPlayerUpdate { + _u.mutation.AddHeadshot(v) + return _u } // SetMvp sets the "mvp" field. -func (mpu *MatchPlayerUpdate) SetMvp(u uint) *MatchPlayerUpdate { - mpu.mutation.ResetMvp() - mpu.mutation.SetMvp(u) - return mpu +func (_u *MatchPlayerUpdate) SetMvp(v uint) *MatchPlayerUpdate { + _u.mutation.ResetMvp() + _u.mutation.SetMvp(v) + return _u } -// AddMvp adds u to the "mvp" field. -func (mpu *MatchPlayerUpdate) AddMvp(u int) *MatchPlayerUpdate { - mpu.mutation.AddMvp(u) - return mpu +// SetNillableMvp sets the "mvp" field if the given value is not nil. +func (_u *MatchPlayerUpdate) SetNillableMvp(v *uint) *MatchPlayerUpdate { + if v != nil { + _u.SetMvp(*v) + } + return _u +} + +// AddMvp adds value to the "mvp" field. +func (_u *MatchPlayerUpdate) AddMvp(v int) *MatchPlayerUpdate { + _u.mutation.AddMvp(v) + return _u } // SetScore sets the "score" field. -func (mpu *MatchPlayerUpdate) SetScore(i int) *MatchPlayerUpdate { - mpu.mutation.ResetScore() - mpu.mutation.SetScore(i) - return mpu +func (_u *MatchPlayerUpdate) SetScore(v int) *MatchPlayerUpdate { + _u.mutation.ResetScore() + _u.mutation.SetScore(v) + return _u } -// AddScore adds i to the "score" field. -func (mpu *MatchPlayerUpdate) AddScore(i int) *MatchPlayerUpdate { - mpu.mutation.AddScore(i) - return mpu +// SetNillableScore sets the "score" field if the given value is not nil. +func (_u *MatchPlayerUpdate) SetNillableScore(v *int) *MatchPlayerUpdate { + if v != nil { + _u.SetScore(*v) + } + return _u +} + +// AddScore adds value to the "score" field. +func (_u *MatchPlayerUpdate) AddScore(v int) *MatchPlayerUpdate { + _u.mutation.AddScore(v) + return _u } // SetRankNew sets the "rank_new" field. -func (mpu *MatchPlayerUpdate) SetRankNew(i int) *MatchPlayerUpdate { - mpu.mutation.ResetRankNew() - mpu.mutation.SetRankNew(i) - return mpu +func (_u *MatchPlayerUpdate) SetRankNew(v int) *MatchPlayerUpdate { + _u.mutation.ResetRankNew() + _u.mutation.SetRankNew(v) + return _u } // SetNillableRankNew sets the "rank_new" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableRankNew(i *int) *MatchPlayerUpdate { - if i != nil { - mpu.SetRankNew(*i) +func (_u *MatchPlayerUpdate) SetNillableRankNew(v *int) *MatchPlayerUpdate { + if v != nil { + _u.SetRankNew(*v) } - return mpu + return _u } -// AddRankNew adds i to the "rank_new" field. -func (mpu *MatchPlayerUpdate) AddRankNew(i int) *MatchPlayerUpdate { - mpu.mutation.AddRankNew(i) - return mpu +// AddRankNew adds value to the "rank_new" field. +func (_u *MatchPlayerUpdate) AddRankNew(v int) *MatchPlayerUpdate { + _u.mutation.AddRankNew(v) + return _u } // ClearRankNew clears the value of the "rank_new" field. -func (mpu *MatchPlayerUpdate) ClearRankNew() *MatchPlayerUpdate { - mpu.mutation.ClearRankNew() - return mpu +func (_u *MatchPlayerUpdate) ClearRankNew() *MatchPlayerUpdate { + _u.mutation.ClearRankNew() + return _u } // SetRankOld sets the "rank_old" field. -func (mpu *MatchPlayerUpdate) SetRankOld(i int) *MatchPlayerUpdate { - mpu.mutation.ResetRankOld() - mpu.mutation.SetRankOld(i) - return mpu +func (_u *MatchPlayerUpdate) SetRankOld(v int) *MatchPlayerUpdate { + _u.mutation.ResetRankOld() + _u.mutation.SetRankOld(v) + return _u } // SetNillableRankOld sets the "rank_old" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableRankOld(i *int) *MatchPlayerUpdate { - if i != nil { - mpu.SetRankOld(*i) +func (_u *MatchPlayerUpdate) SetNillableRankOld(v *int) *MatchPlayerUpdate { + if v != nil { + _u.SetRankOld(*v) } - return mpu + return _u } -// AddRankOld adds i to the "rank_old" field. -func (mpu *MatchPlayerUpdate) AddRankOld(i int) *MatchPlayerUpdate { - mpu.mutation.AddRankOld(i) - return mpu +// AddRankOld adds value to the "rank_old" field. +func (_u *MatchPlayerUpdate) AddRankOld(v int) *MatchPlayerUpdate { + _u.mutation.AddRankOld(v) + return _u } // ClearRankOld clears the value of the "rank_old" field. -func (mpu *MatchPlayerUpdate) ClearRankOld() *MatchPlayerUpdate { - mpu.mutation.ClearRankOld() - return mpu +func (_u *MatchPlayerUpdate) ClearRankOld() *MatchPlayerUpdate { + _u.mutation.ClearRankOld() + return _u } // SetMk2 sets the "mk_2" field. -func (mpu *MatchPlayerUpdate) SetMk2(u uint) *MatchPlayerUpdate { - mpu.mutation.ResetMk2() - mpu.mutation.SetMk2(u) - return mpu +func (_u *MatchPlayerUpdate) SetMk2(v uint) *MatchPlayerUpdate { + _u.mutation.ResetMk2() + _u.mutation.SetMk2(v) + return _u } // SetNillableMk2 sets the "mk_2" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableMk2(u *uint) *MatchPlayerUpdate { - if u != nil { - mpu.SetMk2(*u) +func (_u *MatchPlayerUpdate) SetNillableMk2(v *uint) *MatchPlayerUpdate { + if v != nil { + _u.SetMk2(*v) } - return mpu + return _u } -// AddMk2 adds u to the "mk_2" field. -func (mpu *MatchPlayerUpdate) AddMk2(u int) *MatchPlayerUpdate { - mpu.mutation.AddMk2(u) - return mpu +// AddMk2 adds value to the "mk_2" field. +func (_u *MatchPlayerUpdate) AddMk2(v int) *MatchPlayerUpdate { + _u.mutation.AddMk2(v) + return _u } // ClearMk2 clears the value of the "mk_2" field. -func (mpu *MatchPlayerUpdate) ClearMk2() *MatchPlayerUpdate { - mpu.mutation.ClearMk2() - return mpu +func (_u *MatchPlayerUpdate) ClearMk2() *MatchPlayerUpdate { + _u.mutation.ClearMk2() + return _u } // SetMk3 sets the "mk_3" field. -func (mpu *MatchPlayerUpdate) SetMk3(u uint) *MatchPlayerUpdate { - mpu.mutation.ResetMk3() - mpu.mutation.SetMk3(u) - return mpu +func (_u *MatchPlayerUpdate) SetMk3(v uint) *MatchPlayerUpdate { + _u.mutation.ResetMk3() + _u.mutation.SetMk3(v) + return _u } // SetNillableMk3 sets the "mk_3" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableMk3(u *uint) *MatchPlayerUpdate { - if u != nil { - mpu.SetMk3(*u) +func (_u *MatchPlayerUpdate) SetNillableMk3(v *uint) *MatchPlayerUpdate { + if v != nil { + _u.SetMk3(*v) } - return mpu + return _u } -// AddMk3 adds u to the "mk_3" field. -func (mpu *MatchPlayerUpdate) AddMk3(u int) *MatchPlayerUpdate { - mpu.mutation.AddMk3(u) - return mpu +// AddMk3 adds value to the "mk_3" field. +func (_u *MatchPlayerUpdate) AddMk3(v int) *MatchPlayerUpdate { + _u.mutation.AddMk3(v) + return _u } // ClearMk3 clears the value of the "mk_3" field. -func (mpu *MatchPlayerUpdate) ClearMk3() *MatchPlayerUpdate { - mpu.mutation.ClearMk3() - return mpu +func (_u *MatchPlayerUpdate) ClearMk3() *MatchPlayerUpdate { + _u.mutation.ClearMk3() + return _u } // SetMk4 sets the "mk_4" field. -func (mpu *MatchPlayerUpdate) SetMk4(u uint) *MatchPlayerUpdate { - mpu.mutation.ResetMk4() - mpu.mutation.SetMk4(u) - return mpu +func (_u *MatchPlayerUpdate) SetMk4(v uint) *MatchPlayerUpdate { + _u.mutation.ResetMk4() + _u.mutation.SetMk4(v) + return _u } // SetNillableMk4 sets the "mk_4" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableMk4(u *uint) *MatchPlayerUpdate { - if u != nil { - mpu.SetMk4(*u) +func (_u *MatchPlayerUpdate) SetNillableMk4(v *uint) *MatchPlayerUpdate { + if v != nil { + _u.SetMk4(*v) } - return mpu + return _u } -// AddMk4 adds u to the "mk_4" field. -func (mpu *MatchPlayerUpdate) AddMk4(u int) *MatchPlayerUpdate { - mpu.mutation.AddMk4(u) - return mpu +// AddMk4 adds value to the "mk_4" field. +func (_u *MatchPlayerUpdate) AddMk4(v int) *MatchPlayerUpdate { + _u.mutation.AddMk4(v) + return _u } // ClearMk4 clears the value of the "mk_4" field. -func (mpu *MatchPlayerUpdate) ClearMk4() *MatchPlayerUpdate { - mpu.mutation.ClearMk4() - return mpu +func (_u *MatchPlayerUpdate) ClearMk4() *MatchPlayerUpdate { + _u.mutation.ClearMk4() + return _u } // SetMk5 sets the "mk_5" field. -func (mpu *MatchPlayerUpdate) SetMk5(u uint) *MatchPlayerUpdate { - mpu.mutation.ResetMk5() - mpu.mutation.SetMk5(u) - return mpu +func (_u *MatchPlayerUpdate) SetMk5(v uint) *MatchPlayerUpdate { + _u.mutation.ResetMk5() + _u.mutation.SetMk5(v) + return _u } // SetNillableMk5 sets the "mk_5" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableMk5(u *uint) *MatchPlayerUpdate { - if u != nil { - mpu.SetMk5(*u) +func (_u *MatchPlayerUpdate) SetNillableMk5(v *uint) *MatchPlayerUpdate { + if v != nil { + _u.SetMk5(*v) } - return mpu + return _u } -// AddMk5 adds u to the "mk_5" field. -func (mpu *MatchPlayerUpdate) AddMk5(u int) *MatchPlayerUpdate { - mpu.mutation.AddMk5(u) - return mpu +// AddMk5 adds value to the "mk_5" field. +func (_u *MatchPlayerUpdate) AddMk5(v int) *MatchPlayerUpdate { + _u.mutation.AddMk5(v) + return _u } // ClearMk5 clears the value of the "mk_5" field. -func (mpu *MatchPlayerUpdate) ClearMk5() *MatchPlayerUpdate { - mpu.mutation.ClearMk5() - return mpu +func (_u *MatchPlayerUpdate) ClearMk5() *MatchPlayerUpdate { + _u.mutation.ClearMk5() + return _u } // SetDmgEnemy sets the "dmg_enemy" field. -func (mpu *MatchPlayerUpdate) SetDmgEnemy(u uint) *MatchPlayerUpdate { - mpu.mutation.ResetDmgEnemy() - mpu.mutation.SetDmgEnemy(u) - return mpu +func (_u *MatchPlayerUpdate) SetDmgEnemy(v uint) *MatchPlayerUpdate { + _u.mutation.ResetDmgEnemy() + _u.mutation.SetDmgEnemy(v) + return _u } // SetNillableDmgEnemy sets the "dmg_enemy" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableDmgEnemy(u *uint) *MatchPlayerUpdate { - if u != nil { - mpu.SetDmgEnemy(*u) +func (_u *MatchPlayerUpdate) SetNillableDmgEnemy(v *uint) *MatchPlayerUpdate { + if v != nil { + _u.SetDmgEnemy(*v) } - return mpu + return _u } -// AddDmgEnemy adds u to the "dmg_enemy" field. -func (mpu *MatchPlayerUpdate) AddDmgEnemy(u int) *MatchPlayerUpdate { - mpu.mutation.AddDmgEnemy(u) - return mpu +// AddDmgEnemy adds value to the "dmg_enemy" field. +func (_u *MatchPlayerUpdate) AddDmgEnemy(v int) *MatchPlayerUpdate { + _u.mutation.AddDmgEnemy(v) + return _u } // ClearDmgEnemy clears the value of the "dmg_enemy" field. -func (mpu *MatchPlayerUpdate) ClearDmgEnemy() *MatchPlayerUpdate { - mpu.mutation.ClearDmgEnemy() - return mpu +func (_u *MatchPlayerUpdate) ClearDmgEnemy() *MatchPlayerUpdate { + _u.mutation.ClearDmgEnemy() + return _u } // SetDmgTeam sets the "dmg_team" field. -func (mpu *MatchPlayerUpdate) SetDmgTeam(u uint) *MatchPlayerUpdate { - mpu.mutation.ResetDmgTeam() - mpu.mutation.SetDmgTeam(u) - return mpu +func (_u *MatchPlayerUpdate) SetDmgTeam(v uint) *MatchPlayerUpdate { + _u.mutation.ResetDmgTeam() + _u.mutation.SetDmgTeam(v) + return _u } // SetNillableDmgTeam sets the "dmg_team" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableDmgTeam(u *uint) *MatchPlayerUpdate { - if u != nil { - mpu.SetDmgTeam(*u) +func (_u *MatchPlayerUpdate) SetNillableDmgTeam(v *uint) *MatchPlayerUpdate { + if v != nil { + _u.SetDmgTeam(*v) } - return mpu + return _u } -// AddDmgTeam adds u to the "dmg_team" field. -func (mpu *MatchPlayerUpdate) AddDmgTeam(u int) *MatchPlayerUpdate { - mpu.mutation.AddDmgTeam(u) - return mpu +// AddDmgTeam adds value to the "dmg_team" field. +func (_u *MatchPlayerUpdate) AddDmgTeam(v int) *MatchPlayerUpdate { + _u.mutation.AddDmgTeam(v) + return _u } // ClearDmgTeam clears the value of the "dmg_team" field. -func (mpu *MatchPlayerUpdate) ClearDmgTeam() *MatchPlayerUpdate { - mpu.mutation.ClearDmgTeam() - return mpu +func (_u *MatchPlayerUpdate) ClearDmgTeam() *MatchPlayerUpdate { + _u.mutation.ClearDmgTeam() + return _u } // SetUdHe sets the "ud_he" field. -func (mpu *MatchPlayerUpdate) SetUdHe(u uint) *MatchPlayerUpdate { - mpu.mutation.ResetUdHe() - mpu.mutation.SetUdHe(u) - return mpu +func (_u *MatchPlayerUpdate) SetUdHe(v uint) *MatchPlayerUpdate { + _u.mutation.ResetUdHe() + _u.mutation.SetUdHe(v) + return _u } // SetNillableUdHe sets the "ud_he" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableUdHe(u *uint) *MatchPlayerUpdate { - if u != nil { - mpu.SetUdHe(*u) +func (_u *MatchPlayerUpdate) SetNillableUdHe(v *uint) *MatchPlayerUpdate { + if v != nil { + _u.SetUdHe(*v) } - return mpu + return _u } -// AddUdHe adds u to the "ud_he" field. -func (mpu *MatchPlayerUpdate) AddUdHe(u int) *MatchPlayerUpdate { - mpu.mutation.AddUdHe(u) - return mpu +// AddUdHe adds value to the "ud_he" field. +func (_u *MatchPlayerUpdate) AddUdHe(v int) *MatchPlayerUpdate { + _u.mutation.AddUdHe(v) + return _u } // ClearUdHe clears the value of the "ud_he" field. -func (mpu *MatchPlayerUpdate) ClearUdHe() *MatchPlayerUpdate { - mpu.mutation.ClearUdHe() - return mpu +func (_u *MatchPlayerUpdate) ClearUdHe() *MatchPlayerUpdate { + _u.mutation.ClearUdHe() + return _u } // SetUdFlames sets the "ud_flames" field. -func (mpu *MatchPlayerUpdate) SetUdFlames(u uint) *MatchPlayerUpdate { - mpu.mutation.ResetUdFlames() - mpu.mutation.SetUdFlames(u) - return mpu +func (_u *MatchPlayerUpdate) SetUdFlames(v uint) *MatchPlayerUpdate { + _u.mutation.ResetUdFlames() + _u.mutation.SetUdFlames(v) + return _u } // SetNillableUdFlames sets the "ud_flames" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableUdFlames(u *uint) *MatchPlayerUpdate { - if u != nil { - mpu.SetUdFlames(*u) +func (_u *MatchPlayerUpdate) SetNillableUdFlames(v *uint) *MatchPlayerUpdate { + if v != nil { + _u.SetUdFlames(*v) } - return mpu + return _u } -// AddUdFlames adds u to the "ud_flames" field. -func (mpu *MatchPlayerUpdate) AddUdFlames(u int) *MatchPlayerUpdate { - mpu.mutation.AddUdFlames(u) - return mpu +// AddUdFlames adds value to the "ud_flames" field. +func (_u *MatchPlayerUpdate) AddUdFlames(v int) *MatchPlayerUpdate { + _u.mutation.AddUdFlames(v) + return _u } // ClearUdFlames clears the value of the "ud_flames" field. -func (mpu *MatchPlayerUpdate) ClearUdFlames() *MatchPlayerUpdate { - mpu.mutation.ClearUdFlames() - return mpu +func (_u *MatchPlayerUpdate) ClearUdFlames() *MatchPlayerUpdate { + _u.mutation.ClearUdFlames() + return _u } // SetUdFlash sets the "ud_flash" field. -func (mpu *MatchPlayerUpdate) SetUdFlash(u uint) *MatchPlayerUpdate { - mpu.mutation.ResetUdFlash() - mpu.mutation.SetUdFlash(u) - return mpu +func (_u *MatchPlayerUpdate) SetUdFlash(v uint) *MatchPlayerUpdate { + _u.mutation.ResetUdFlash() + _u.mutation.SetUdFlash(v) + return _u } // SetNillableUdFlash sets the "ud_flash" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableUdFlash(u *uint) *MatchPlayerUpdate { - if u != nil { - mpu.SetUdFlash(*u) +func (_u *MatchPlayerUpdate) SetNillableUdFlash(v *uint) *MatchPlayerUpdate { + if v != nil { + _u.SetUdFlash(*v) } - return mpu + return _u } -// AddUdFlash adds u to the "ud_flash" field. -func (mpu *MatchPlayerUpdate) AddUdFlash(u int) *MatchPlayerUpdate { - mpu.mutation.AddUdFlash(u) - return mpu +// AddUdFlash adds value to the "ud_flash" field. +func (_u *MatchPlayerUpdate) AddUdFlash(v int) *MatchPlayerUpdate { + _u.mutation.AddUdFlash(v) + return _u } // ClearUdFlash clears the value of the "ud_flash" field. -func (mpu *MatchPlayerUpdate) ClearUdFlash() *MatchPlayerUpdate { - mpu.mutation.ClearUdFlash() - return mpu +func (_u *MatchPlayerUpdate) ClearUdFlash() *MatchPlayerUpdate { + _u.mutation.ClearUdFlash() + return _u } // SetUdDecoy sets the "ud_decoy" field. -func (mpu *MatchPlayerUpdate) SetUdDecoy(u uint) *MatchPlayerUpdate { - mpu.mutation.ResetUdDecoy() - mpu.mutation.SetUdDecoy(u) - return mpu +func (_u *MatchPlayerUpdate) SetUdDecoy(v uint) *MatchPlayerUpdate { + _u.mutation.ResetUdDecoy() + _u.mutation.SetUdDecoy(v) + return _u } // SetNillableUdDecoy sets the "ud_decoy" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableUdDecoy(u *uint) *MatchPlayerUpdate { - if u != nil { - mpu.SetUdDecoy(*u) +func (_u *MatchPlayerUpdate) SetNillableUdDecoy(v *uint) *MatchPlayerUpdate { + if v != nil { + _u.SetUdDecoy(*v) } - return mpu + return _u } -// AddUdDecoy adds u to the "ud_decoy" field. -func (mpu *MatchPlayerUpdate) AddUdDecoy(u int) *MatchPlayerUpdate { - mpu.mutation.AddUdDecoy(u) - return mpu +// AddUdDecoy adds value to the "ud_decoy" field. +func (_u *MatchPlayerUpdate) AddUdDecoy(v int) *MatchPlayerUpdate { + _u.mutation.AddUdDecoy(v) + return _u } // ClearUdDecoy clears the value of the "ud_decoy" field. -func (mpu *MatchPlayerUpdate) ClearUdDecoy() *MatchPlayerUpdate { - mpu.mutation.ClearUdDecoy() - return mpu +func (_u *MatchPlayerUpdate) ClearUdDecoy() *MatchPlayerUpdate { + _u.mutation.ClearUdDecoy() + return _u } // SetUdSmoke sets the "ud_smoke" field. -func (mpu *MatchPlayerUpdate) SetUdSmoke(u uint) *MatchPlayerUpdate { - mpu.mutation.ResetUdSmoke() - mpu.mutation.SetUdSmoke(u) - return mpu +func (_u *MatchPlayerUpdate) SetUdSmoke(v uint) *MatchPlayerUpdate { + _u.mutation.ResetUdSmoke() + _u.mutation.SetUdSmoke(v) + return _u } // SetNillableUdSmoke sets the "ud_smoke" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableUdSmoke(u *uint) *MatchPlayerUpdate { - if u != nil { - mpu.SetUdSmoke(*u) +func (_u *MatchPlayerUpdate) SetNillableUdSmoke(v *uint) *MatchPlayerUpdate { + if v != nil { + _u.SetUdSmoke(*v) } - return mpu + return _u } -// AddUdSmoke adds u to the "ud_smoke" field. -func (mpu *MatchPlayerUpdate) AddUdSmoke(u int) *MatchPlayerUpdate { - mpu.mutation.AddUdSmoke(u) - return mpu +// AddUdSmoke adds value to the "ud_smoke" field. +func (_u *MatchPlayerUpdate) AddUdSmoke(v int) *MatchPlayerUpdate { + _u.mutation.AddUdSmoke(v) + return _u } // ClearUdSmoke clears the value of the "ud_smoke" field. -func (mpu *MatchPlayerUpdate) ClearUdSmoke() *MatchPlayerUpdate { - mpu.mutation.ClearUdSmoke() - return mpu +func (_u *MatchPlayerUpdate) ClearUdSmoke() *MatchPlayerUpdate { + _u.mutation.ClearUdSmoke() + return _u } // SetCrosshair sets the "crosshair" field. -func (mpu *MatchPlayerUpdate) SetCrosshair(s string) *MatchPlayerUpdate { - mpu.mutation.SetCrosshair(s) - return mpu +func (_u *MatchPlayerUpdate) SetCrosshair(v string) *MatchPlayerUpdate { + _u.mutation.SetCrosshair(v) + return _u } // SetNillableCrosshair sets the "crosshair" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableCrosshair(s *string) *MatchPlayerUpdate { - if s != nil { - mpu.SetCrosshair(*s) +func (_u *MatchPlayerUpdate) SetNillableCrosshair(v *string) *MatchPlayerUpdate { + if v != nil { + _u.SetCrosshair(*v) } - return mpu + return _u } // ClearCrosshair clears the value of the "crosshair" field. -func (mpu *MatchPlayerUpdate) ClearCrosshair() *MatchPlayerUpdate { - mpu.mutation.ClearCrosshair() - return mpu +func (_u *MatchPlayerUpdate) ClearCrosshair() *MatchPlayerUpdate { + _u.mutation.ClearCrosshair() + return _u } // SetColor sets the "color" field. -func (mpu *MatchPlayerUpdate) SetColor(m matchplayer.Color) *MatchPlayerUpdate { - mpu.mutation.SetColor(m) - return mpu +func (_u *MatchPlayerUpdate) SetColor(v matchplayer.Color) *MatchPlayerUpdate { + _u.mutation.SetColor(v) + return _u } // SetNillableColor sets the "color" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableColor(m *matchplayer.Color) *MatchPlayerUpdate { - if m != nil { - mpu.SetColor(*m) +func (_u *MatchPlayerUpdate) SetNillableColor(v *matchplayer.Color) *MatchPlayerUpdate { + if v != nil { + _u.SetColor(*v) } - return mpu + return _u } // ClearColor clears the value of the "color" field. -func (mpu *MatchPlayerUpdate) ClearColor() *MatchPlayerUpdate { - mpu.mutation.ClearColor() - return mpu +func (_u *MatchPlayerUpdate) ClearColor() *MatchPlayerUpdate { + _u.mutation.ClearColor() + return _u } // SetKast sets the "kast" field. -func (mpu *MatchPlayerUpdate) SetKast(i int) *MatchPlayerUpdate { - mpu.mutation.ResetKast() - mpu.mutation.SetKast(i) - return mpu +func (_u *MatchPlayerUpdate) SetKast(v int) *MatchPlayerUpdate { + _u.mutation.ResetKast() + _u.mutation.SetKast(v) + return _u } // SetNillableKast sets the "kast" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableKast(i *int) *MatchPlayerUpdate { - if i != nil { - mpu.SetKast(*i) +func (_u *MatchPlayerUpdate) SetNillableKast(v *int) *MatchPlayerUpdate { + if v != nil { + _u.SetKast(*v) } - return mpu + return _u } -// AddKast adds i to the "kast" field. -func (mpu *MatchPlayerUpdate) AddKast(i int) *MatchPlayerUpdate { - mpu.mutation.AddKast(i) - return mpu +// AddKast adds value to the "kast" field. +func (_u *MatchPlayerUpdate) AddKast(v int) *MatchPlayerUpdate { + _u.mutation.AddKast(v) + return _u } // ClearKast clears the value of the "kast" field. -func (mpu *MatchPlayerUpdate) ClearKast() *MatchPlayerUpdate { - mpu.mutation.ClearKast() - return mpu +func (_u *MatchPlayerUpdate) ClearKast() *MatchPlayerUpdate { + _u.mutation.ClearKast() + return _u } // SetFlashDurationSelf sets the "flash_duration_self" field. -func (mpu *MatchPlayerUpdate) SetFlashDurationSelf(f float32) *MatchPlayerUpdate { - mpu.mutation.ResetFlashDurationSelf() - mpu.mutation.SetFlashDurationSelf(f) - return mpu +func (_u *MatchPlayerUpdate) SetFlashDurationSelf(v float32) *MatchPlayerUpdate { + _u.mutation.ResetFlashDurationSelf() + _u.mutation.SetFlashDurationSelf(v) + return _u } // SetNillableFlashDurationSelf sets the "flash_duration_self" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableFlashDurationSelf(f *float32) *MatchPlayerUpdate { - if f != nil { - mpu.SetFlashDurationSelf(*f) +func (_u *MatchPlayerUpdate) SetNillableFlashDurationSelf(v *float32) *MatchPlayerUpdate { + if v != nil { + _u.SetFlashDurationSelf(*v) } - return mpu + return _u } -// AddFlashDurationSelf adds f to the "flash_duration_self" field. -func (mpu *MatchPlayerUpdate) AddFlashDurationSelf(f float32) *MatchPlayerUpdate { - mpu.mutation.AddFlashDurationSelf(f) - return mpu +// AddFlashDurationSelf adds value to the "flash_duration_self" field. +func (_u *MatchPlayerUpdate) AddFlashDurationSelf(v float32) *MatchPlayerUpdate { + _u.mutation.AddFlashDurationSelf(v) + return _u } // ClearFlashDurationSelf clears the value of the "flash_duration_self" field. -func (mpu *MatchPlayerUpdate) ClearFlashDurationSelf() *MatchPlayerUpdate { - mpu.mutation.ClearFlashDurationSelf() - return mpu +func (_u *MatchPlayerUpdate) ClearFlashDurationSelf() *MatchPlayerUpdate { + _u.mutation.ClearFlashDurationSelf() + return _u } // SetFlashDurationTeam sets the "flash_duration_team" field. -func (mpu *MatchPlayerUpdate) SetFlashDurationTeam(f float32) *MatchPlayerUpdate { - mpu.mutation.ResetFlashDurationTeam() - mpu.mutation.SetFlashDurationTeam(f) - return mpu +func (_u *MatchPlayerUpdate) SetFlashDurationTeam(v float32) *MatchPlayerUpdate { + _u.mutation.ResetFlashDurationTeam() + _u.mutation.SetFlashDurationTeam(v) + return _u } // SetNillableFlashDurationTeam sets the "flash_duration_team" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableFlashDurationTeam(f *float32) *MatchPlayerUpdate { - if f != nil { - mpu.SetFlashDurationTeam(*f) +func (_u *MatchPlayerUpdate) SetNillableFlashDurationTeam(v *float32) *MatchPlayerUpdate { + if v != nil { + _u.SetFlashDurationTeam(*v) } - return mpu + return _u } -// AddFlashDurationTeam adds f to the "flash_duration_team" field. -func (mpu *MatchPlayerUpdate) AddFlashDurationTeam(f float32) *MatchPlayerUpdate { - mpu.mutation.AddFlashDurationTeam(f) - return mpu +// AddFlashDurationTeam adds value to the "flash_duration_team" field. +func (_u *MatchPlayerUpdate) AddFlashDurationTeam(v float32) *MatchPlayerUpdate { + _u.mutation.AddFlashDurationTeam(v) + return _u } // ClearFlashDurationTeam clears the value of the "flash_duration_team" field. -func (mpu *MatchPlayerUpdate) ClearFlashDurationTeam() *MatchPlayerUpdate { - mpu.mutation.ClearFlashDurationTeam() - return mpu +func (_u *MatchPlayerUpdate) ClearFlashDurationTeam() *MatchPlayerUpdate { + _u.mutation.ClearFlashDurationTeam() + return _u } // SetFlashDurationEnemy sets the "flash_duration_enemy" field. -func (mpu *MatchPlayerUpdate) SetFlashDurationEnemy(f float32) *MatchPlayerUpdate { - mpu.mutation.ResetFlashDurationEnemy() - mpu.mutation.SetFlashDurationEnemy(f) - return mpu +func (_u *MatchPlayerUpdate) SetFlashDurationEnemy(v float32) *MatchPlayerUpdate { + _u.mutation.ResetFlashDurationEnemy() + _u.mutation.SetFlashDurationEnemy(v) + return _u } // SetNillableFlashDurationEnemy sets the "flash_duration_enemy" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableFlashDurationEnemy(f *float32) *MatchPlayerUpdate { - if f != nil { - mpu.SetFlashDurationEnemy(*f) +func (_u *MatchPlayerUpdate) SetNillableFlashDurationEnemy(v *float32) *MatchPlayerUpdate { + if v != nil { + _u.SetFlashDurationEnemy(*v) } - return mpu + return _u } -// AddFlashDurationEnemy adds f to the "flash_duration_enemy" field. -func (mpu *MatchPlayerUpdate) AddFlashDurationEnemy(f float32) *MatchPlayerUpdate { - mpu.mutation.AddFlashDurationEnemy(f) - return mpu +// AddFlashDurationEnemy adds value to the "flash_duration_enemy" field. +func (_u *MatchPlayerUpdate) AddFlashDurationEnemy(v float32) *MatchPlayerUpdate { + _u.mutation.AddFlashDurationEnemy(v) + return _u } // ClearFlashDurationEnemy clears the value of the "flash_duration_enemy" field. -func (mpu *MatchPlayerUpdate) ClearFlashDurationEnemy() *MatchPlayerUpdate { - mpu.mutation.ClearFlashDurationEnemy() - return mpu +func (_u *MatchPlayerUpdate) ClearFlashDurationEnemy() *MatchPlayerUpdate { + _u.mutation.ClearFlashDurationEnemy() + return _u } // SetFlashTotalSelf sets the "flash_total_self" field. -func (mpu *MatchPlayerUpdate) SetFlashTotalSelf(u uint) *MatchPlayerUpdate { - mpu.mutation.ResetFlashTotalSelf() - mpu.mutation.SetFlashTotalSelf(u) - return mpu +func (_u *MatchPlayerUpdate) SetFlashTotalSelf(v uint) *MatchPlayerUpdate { + _u.mutation.ResetFlashTotalSelf() + _u.mutation.SetFlashTotalSelf(v) + return _u } // SetNillableFlashTotalSelf sets the "flash_total_self" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableFlashTotalSelf(u *uint) *MatchPlayerUpdate { - if u != nil { - mpu.SetFlashTotalSelf(*u) +func (_u *MatchPlayerUpdate) SetNillableFlashTotalSelf(v *uint) *MatchPlayerUpdate { + if v != nil { + _u.SetFlashTotalSelf(*v) } - return mpu + return _u } -// AddFlashTotalSelf adds u to the "flash_total_self" field. -func (mpu *MatchPlayerUpdate) AddFlashTotalSelf(u int) *MatchPlayerUpdate { - mpu.mutation.AddFlashTotalSelf(u) - return mpu +// AddFlashTotalSelf adds value to the "flash_total_self" field. +func (_u *MatchPlayerUpdate) AddFlashTotalSelf(v int) *MatchPlayerUpdate { + _u.mutation.AddFlashTotalSelf(v) + return _u } // ClearFlashTotalSelf clears the value of the "flash_total_self" field. -func (mpu *MatchPlayerUpdate) ClearFlashTotalSelf() *MatchPlayerUpdate { - mpu.mutation.ClearFlashTotalSelf() - return mpu +func (_u *MatchPlayerUpdate) ClearFlashTotalSelf() *MatchPlayerUpdate { + _u.mutation.ClearFlashTotalSelf() + return _u } // SetFlashTotalTeam sets the "flash_total_team" field. -func (mpu *MatchPlayerUpdate) SetFlashTotalTeam(u uint) *MatchPlayerUpdate { - mpu.mutation.ResetFlashTotalTeam() - mpu.mutation.SetFlashTotalTeam(u) - return mpu +func (_u *MatchPlayerUpdate) SetFlashTotalTeam(v uint) *MatchPlayerUpdate { + _u.mutation.ResetFlashTotalTeam() + _u.mutation.SetFlashTotalTeam(v) + return _u } // SetNillableFlashTotalTeam sets the "flash_total_team" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableFlashTotalTeam(u *uint) *MatchPlayerUpdate { - if u != nil { - mpu.SetFlashTotalTeam(*u) +func (_u *MatchPlayerUpdate) SetNillableFlashTotalTeam(v *uint) *MatchPlayerUpdate { + if v != nil { + _u.SetFlashTotalTeam(*v) } - return mpu + return _u } -// AddFlashTotalTeam adds u to the "flash_total_team" field. -func (mpu *MatchPlayerUpdate) AddFlashTotalTeam(u int) *MatchPlayerUpdate { - mpu.mutation.AddFlashTotalTeam(u) - return mpu +// AddFlashTotalTeam adds value to the "flash_total_team" field. +func (_u *MatchPlayerUpdate) AddFlashTotalTeam(v int) *MatchPlayerUpdate { + _u.mutation.AddFlashTotalTeam(v) + return _u } // ClearFlashTotalTeam clears the value of the "flash_total_team" field. -func (mpu *MatchPlayerUpdate) ClearFlashTotalTeam() *MatchPlayerUpdate { - mpu.mutation.ClearFlashTotalTeam() - return mpu +func (_u *MatchPlayerUpdate) ClearFlashTotalTeam() *MatchPlayerUpdate { + _u.mutation.ClearFlashTotalTeam() + return _u } // SetFlashTotalEnemy sets the "flash_total_enemy" field. -func (mpu *MatchPlayerUpdate) SetFlashTotalEnemy(u uint) *MatchPlayerUpdate { - mpu.mutation.ResetFlashTotalEnemy() - mpu.mutation.SetFlashTotalEnemy(u) - return mpu +func (_u *MatchPlayerUpdate) SetFlashTotalEnemy(v uint) *MatchPlayerUpdate { + _u.mutation.ResetFlashTotalEnemy() + _u.mutation.SetFlashTotalEnemy(v) + return _u } // SetNillableFlashTotalEnemy sets the "flash_total_enemy" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableFlashTotalEnemy(u *uint) *MatchPlayerUpdate { - if u != nil { - mpu.SetFlashTotalEnemy(*u) +func (_u *MatchPlayerUpdate) SetNillableFlashTotalEnemy(v *uint) *MatchPlayerUpdate { + if v != nil { + _u.SetFlashTotalEnemy(*v) } - return mpu + return _u } -// AddFlashTotalEnemy adds u to the "flash_total_enemy" field. -func (mpu *MatchPlayerUpdate) AddFlashTotalEnemy(u int) *MatchPlayerUpdate { - mpu.mutation.AddFlashTotalEnemy(u) - return mpu +// AddFlashTotalEnemy adds value to the "flash_total_enemy" field. +func (_u *MatchPlayerUpdate) AddFlashTotalEnemy(v int) *MatchPlayerUpdate { + _u.mutation.AddFlashTotalEnemy(v) + return _u } // ClearFlashTotalEnemy clears the value of the "flash_total_enemy" field. -func (mpu *MatchPlayerUpdate) ClearFlashTotalEnemy() *MatchPlayerUpdate { - mpu.mutation.ClearFlashTotalEnemy() - return mpu +func (_u *MatchPlayerUpdate) ClearFlashTotalEnemy() *MatchPlayerUpdate { + _u.mutation.ClearFlashTotalEnemy() + return _u } // SetMatchStats sets the "match_stats" field. -func (mpu *MatchPlayerUpdate) SetMatchStats(u uint64) *MatchPlayerUpdate { - mpu.mutation.SetMatchStats(u) - return mpu +func (_u *MatchPlayerUpdate) SetMatchStats(v uint64) *MatchPlayerUpdate { + _u.mutation.SetMatchStats(v) + return _u } // SetNillableMatchStats sets the "match_stats" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableMatchStats(u *uint64) *MatchPlayerUpdate { - if u != nil { - mpu.SetMatchStats(*u) +func (_u *MatchPlayerUpdate) SetNillableMatchStats(v *uint64) *MatchPlayerUpdate { + if v != nil { + _u.SetMatchStats(*v) } - return mpu + return _u } // ClearMatchStats clears the value of the "match_stats" field. -func (mpu *MatchPlayerUpdate) ClearMatchStats() *MatchPlayerUpdate { - mpu.mutation.ClearMatchStats() - return mpu +func (_u *MatchPlayerUpdate) ClearMatchStats() *MatchPlayerUpdate { + _u.mutation.ClearMatchStats() + return _u } // SetPlayerStats sets the "player_stats" field. -func (mpu *MatchPlayerUpdate) SetPlayerStats(u uint64) *MatchPlayerUpdate { - mpu.mutation.SetPlayerStats(u) - return mpu +func (_u *MatchPlayerUpdate) SetPlayerStats(v uint64) *MatchPlayerUpdate { + _u.mutation.SetPlayerStats(v) + return _u } // SetNillablePlayerStats sets the "player_stats" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillablePlayerStats(u *uint64) *MatchPlayerUpdate { - if u != nil { - mpu.SetPlayerStats(*u) +func (_u *MatchPlayerUpdate) SetNillablePlayerStats(v *uint64) *MatchPlayerUpdate { + if v != nil { + _u.SetPlayerStats(*v) } - return mpu + return _u } // ClearPlayerStats clears the value of the "player_stats" field. -func (mpu *MatchPlayerUpdate) ClearPlayerStats() *MatchPlayerUpdate { - mpu.mutation.ClearPlayerStats() - return mpu +func (_u *MatchPlayerUpdate) ClearPlayerStats() *MatchPlayerUpdate { + _u.mutation.ClearPlayerStats() + return _u } // SetFlashAssists sets the "flash_assists" field. -func (mpu *MatchPlayerUpdate) SetFlashAssists(i int) *MatchPlayerUpdate { - mpu.mutation.ResetFlashAssists() - mpu.mutation.SetFlashAssists(i) - return mpu +func (_u *MatchPlayerUpdate) SetFlashAssists(v int) *MatchPlayerUpdate { + _u.mutation.ResetFlashAssists() + _u.mutation.SetFlashAssists(v) + return _u } // SetNillableFlashAssists sets the "flash_assists" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableFlashAssists(i *int) *MatchPlayerUpdate { - if i != nil { - mpu.SetFlashAssists(*i) +func (_u *MatchPlayerUpdate) SetNillableFlashAssists(v *int) *MatchPlayerUpdate { + if v != nil { + _u.SetFlashAssists(*v) } - return mpu + return _u } -// AddFlashAssists adds i to the "flash_assists" field. -func (mpu *MatchPlayerUpdate) AddFlashAssists(i int) *MatchPlayerUpdate { - mpu.mutation.AddFlashAssists(i) - return mpu +// AddFlashAssists adds value to the "flash_assists" field. +func (_u *MatchPlayerUpdate) AddFlashAssists(v int) *MatchPlayerUpdate { + _u.mutation.AddFlashAssists(v) + return _u } // ClearFlashAssists clears the value of the "flash_assists" field. -func (mpu *MatchPlayerUpdate) ClearFlashAssists() *MatchPlayerUpdate { - mpu.mutation.ClearFlashAssists() - return mpu +func (_u *MatchPlayerUpdate) ClearFlashAssists() *MatchPlayerUpdate { + _u.mutation.ClearFlashAssists() + return _u } // SetAvgPing sets the "avg_ping" field. -func (mpu *MatchPlayerUpdate) SetAvgPing(f float64) *MatchPlayerUpdate { - mpu.mutation.ResetAvgPing() - mpu.mutation.SetAvgPing(f) - return mpu +func (_u *MatchPlayerUpdate) SetAvgPing(v float64) *MatchPlayerUpdate { + _u.mutation.ResetAvgPing() + _u.mutation.SetAvgPing(v) + return _u } // SetNillableAvgPing sets the "avg_ping" field if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableAvgPing(f *float64) *MatchPlayerUpdate { - if f != nil { - mpu.SetAvgPing(*f) +func (_u *MatchPlayerUpdate) SetNillableAvgPing(v *float64) *MatchPlayerUpdate { + if v != nil { + _u.SetAvgPing(*v) } - return mpu + return _u } -// AddAvgPing adds f to the "avg_ping" field. -func (mpu *MatchPlayerUpdate) AddAvgPing(f float64) *MatchPlayerUpdate { - mpu.mutation.AddAvgPing(f) - return mpu +// AddAvgPing adds value to the "avg_ping" field. +func (_u *MatchPlayerUpdate) AddAvgPing(v float64) *MatchPlayerUpdate { + _u.mutation.AddAvgPing(v) + return _u } // ClearAvgPing clears the value of the "avg_ping" field. -func (mpu *MatchPlayerUpdate) ClearAvgPing() *MatchPlayerUpdate { - mpu.mutation.ClearAvgPing() - return mpu +func (_u *MatchPlayerUpdate) ClearAvgPing() *MatchPlayerUpdate { + _u.mutation.ClearAvgPing() + return _u } // SetMatchesID sets the "matches" edge to the Match entity by ID. -func (mpu *MatchPlayerUpdate) SetMatchesID(id uint64) *MatchPlayerUpdate { - mpu.mutation.SetMatchesID(id) - return mpu +func (_u *MatchPlayerUpdate) SetMatchesID(id uint64) *MatchPlayerUpdate { + _u.mutation.SetMatchesID(id) + return _u } // SetNillableMatchesID sets the "matches" edge to the Match entity by ID if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillableMatchesID(id *uint64) *MatchPlayerUpdate { +func (_u *MatchPlayerUpdate) SetNillableMatchesID(id *uint64) *MatchPlayerUpdate { if id != nil { - mpu = mpu.SetMatchesID(*id) + _u = _u.SetMatchesID(*id) } - return mpu + return _u } // SetMatches sets the "matches" edge to the Match entity. -func (mpu *MatchPlayerUpdate) SetMatches(m *Match) *MatchPlayerUpdate { - return mpu.SetMatchesID(m.ID) +func (_u *MatchPlayerUpdate) SetMatches(v *Match) *MatchPlayerUpdate { + return _u.SetMatchesID(v.ID) } // SetPlayersID sets the "players" edge to the Player entity by ID. -func (mpu *MatchPlayerUpdate) SetPlayersID(id uint64) *MatchPlayerUpdate { - mpu.mutation.SetPlayersID(id) - return mpu +func (_u *MatchPlayerUpdate) SetPlayersID(id uint64) *MatchPlayerUpdate { + _u.mutation.SetPlayersID(id) + return _u } // SetNillablePlayersID sets the "players" edge to the Player entity by ID if the given value is not nil. -func (mpu *MatchPlayerUpdate) SetNillablePlayersID(id *uint64) *MatchPlayerUpdate { +func (_u *MatchPlayerUpdate) SetNillablePlayersID(id *uint64) *MatchPlayerUpdate { if id != nil { - mpu = mpu.SetPlayersID(*id) + _u = _u.SetPlayersID(*id) } - return mpu + return _u } // SetPlayers sets the "players" edge to the Player entity. -func (mpu *MatchPlayerUpdate) SetPlayers(p *Player) *MatchPlayerUpdate { - return mpu.SetPlayersID(p.ID) +func (_u *MatchPlayerUpdate) SetPlayers(v *Player) *MatchPlayerUpdate { + return _u.SetPlayersID(v.ID) } // AddWeaponStatIDs adds the "weapon_stats" edge to the Weapon entity by IDs. -func (mpu *MatchPlayerUpdate) AddWeaponStatIDs(ids ...int) *MatchPlayerUpdate { - mpu.mutation.AddWeaponStatIDs(ids...) - return mpu +func (_u *MatchPlayerUpdate) AddWeaponStatIDs(ids ...int) *MatchPlayerUpdate { + _u.mutation.AddWeaponStatIDs(ids...) + return _u } // AddWeaponStats adds the "weapon_stats" edges to the Weapon entity. -func (mpu *MatchPlayerUpdate) AddWeaponStats(w ...*Weapon) *MatchPlayerUpdate { - ids := make([]int, len(w)) - for i := range w { - ids[i] = w[i].ID +func (_u *MatchPlayerUpdate) AddWeaponStats(v ...*Weapon) *MatchPlayerUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mpu.AddWeaponStatIDs(ids...) + return _u.AddWeaponStatIDs(ids...) } // AddRoundStatIDs adds the "round_stats" edge to the RoundStats entity by IDs. -func (mpu *MatchPlayerUpdate) AddRoundStatIDs(ids ...int) *MatchPlayerUpdate { - mpu.mutation.AddRoundStatIDs(ids...) - return mpu +func (_u *MatchPlayerUpdate) AddRoundStatIDs(ids ...int) *MatchPlayerUpdate { + _u.mutation.AddRoundStatIDs(ids...) + return _u } // AddRoundStats adds the "round_stats" edges to the RoundStats entity. -func (mpu *MatchPlayerUpdate) AddRoundStats(r ...*RoundStats) *MatchPlayerUpdate { - ids := make([]int, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *MatchPlayerUpdate) AddRoundStats(v ...*RoundStats) *MatchPlayerUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mpu.AddRoundStatIDs(ids...) + return _u.AddRoundStatIDs(ids...) } // AddSprayIDs adds the "spray" edge to the Spray entity by IDs. -func (mpu *MatchPlayerUpdate) AddSprayIDs(ids ...int) *MatchPlayerUpdate { - mpu.mutation.AddSprayIDs(ids...) - return mpu +func (_u *MatchPlayerUpdate) AddSprayIDs(ids ...int) *MatchPlayerUpdate { + _u.mutation.AddSprayIDs(ids...) + return _u } // AddSpray adds the "spray" edges to the Spray entity. -func (mpu *MatchPlayerUpdate) AddSpray(s ...*Spray) *MatchPlayerUpdate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID +func (_u *MatchPlayerUpdate) AddSpray(v ...*Spray) *MatchPlayerUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mpu.AddSprayIDs(ids...) + return _u.AddSprayIDs(ids...) } // AddMessageIDs adds the "messages" edge to the Messages entity by IDs. -func (mpu *MatchPlayerUpdate) AddMessageIDs(ids ...int) *MatchPlayerUpdate { - mpu.mutation.AddMessageIDs(ids...) - return mpu +func (_u *MatchPlayerUpdate) AddMessageIDs(ids ...int) *MatchPlayerUpdate { + _u.mutation.AddMessageIDs(ids...) + return _u } // AddMessages adds the "messages" edges to the Messages entity. -func (mpu *MatchPlayerUpdate) AddMessages(m ...*Messages) *MatchPlayerUpdate { - ids := make([]int, len(m)) - for i := range m { - ids[i] = m[i].ID +func (_u *MatchPlayerUpdate) AddMessages(v ...*Messages) *MatchPlayerUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mpu.AddMessageIDs(ids...) + return _u.AddMessageIDs(ids...) } // Mutation returns the MatchPlayerMutation object of the builder. -func (mpu *MatchPlayerUpdate) Mutation() *MatchPlayerMutation { - return mpu.mutation +func (_u *MatchPlayerUpdate) Mutation() *MatchPlayerMutation { + return _u.mutation } // ClearMatches clears the "matches" edge to the Match entity. -func (mpu *MatchPlayerUpdate) ClearMatches() *MatchPlayerUpdate { - mpu.mutation.ClearMatches() - return mpu +func (_u *MatchPlayerUpdate) ClearMatches() *MatchPlayerUpdate { + _u.mutation.ClearMatches() + return _u } // ClearPlayers clears the "players" edge to the Player entity. -func (mpu *MatchPlayerUpdate) ClearPlayers() *MatchPlayerUpdate { - mpu.mutation.ClearPlayers() - return mpu +func (_u *MatchPlayerUpdate) ClearPlayers() *MatchPlayerUpdate { + _u.mutation.ClearPlayers() + return _u } // ClearWeaponStats clears all "weapon_stats" edges to the Weapon entity. -func (mpu *MatchPlayerUpdate) ClearWeaponStats() *MatchPlayerUpdate { - mpu.mutation.ClearWeaponStats() - return mpu +func (_u *MatchPlayerUpdate) ClearWeaponStats() *MatchPlayerUpdate { + _u.mutation.ClearWeaponStats() + return _u } // RemoveWeaponStatIDs removes the "weapon_stats" edge to Weapon entities by IDs. -func (mpu *MatchPlayerUpdate) RemoveWeaponStatIDs(ids ...int) *MatchPlayerUpdate { - mpu.mutation.RemoveWeaponStatIDs(ids...) - return mpu +func (_u *MatchPlayerUpdate) RemoveWeaponStatIDs(ids ...int) *MatchPlayerUpdate { + _u.mutation.RemoveWeaponStatIDs(ids...) + return _u } // RemoveWeaponStats removes "weapon_stats" edges to Weapon entities. -func (mpu *MatchPlayerUpdate) RemoveWeaponStats(w ...*Weapon) *MatchPlayerUpdate { - ids := make([]int, len(w)) - for i := range w { - ids[i] = w[i].ID +func (_u *MatchPlayerUpdate) RemoveWeaponStats(v ...*Weapon) *MatchPlayerUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mpu.RemoveWeaponStatIDs(ids...) + return _u.RemoveWeaponStatIDs(ids...) } // ClearRoundStats clears all "round_stats" edges to the RoundStats entity. -func (mpu *MatchPlayerUpdate) ClearRoundStats() *MatchPlayerUpdate { - mpu.mutation.ClearRoundStats() - return mpu +func (_u *MatchPlayerUpdate) ClearRoundStats() *MatchPlayerUpdate { + _u.mutation.ClearRoundStats() + return _u } // RemoveRoundStatIDs removes the "round_stats" edge to RoundStats entities by IDs. -func (mpu *MatchPlayerUpdate) RemoveRoundStatIDs(ids ...int) *MatchPlayerUpdate { - mpu.mutation.RemoveRoundStatIDs(ids...) - return mpu +func (_u *MatchPlayerUpdate) RemoveRoundStatIDs(ids ...int) *MatchPlayerUpdate { + _u.mutation.RemoveRoundStatIDs(ids...) + return _u } // RemoveRoundStats removes "round_stats" edges to RoundStats entities. -func (mpu *MatchPlayerUpdate) RemoveRoundStats(r ...*RoundStats) *MatchPlayerUpdate { - ids := make([]int, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *MatchPlayerUpdate) RemoveRoundStats(v ...*RoundStats) *MatchPlayerUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mpu.RemoveRoundStatIDs(ids...) + return _u.RemoveRoundStatIDs(ids...) } // ClearSpray clears all "spray" edges to the Spray entity. -func (mpu *MatchPlayerUpdate) ClearSpray() *MatchPlayerUpdate { - mpu.mutation.ClearSpray() - return mpu +func (_u *MatchPlayerUpdate) ClearSpray() *MatchPlayerUpdate { + _u.mutation.ClearSpray() + return _u } // RemoveSprayIDs removes the "spray" edge to Spray entities by IDs. -func (mpu *MatchPlayerUpdate) RemoveSprayIDs(ids ...int) *MatchPlayerUpdate { - mpu.mutation.RemoveSprayIDs(ids...) - return mpu +func (_u *MatchPlayerUpdate) RemoveSprayIDs(ids ...int) *MatchPlayerUpdate { + _u.mutation.RemoveSprayIDs(ids...) + return _u } // RemoveSpray removes "spray" edges to Spray entities. -func (mpu *MatchPlayerUpdate) RemoveSpray(s ...*Spray) *MatchPlayerUpdate { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID +func (_u *MatchPlayerUpdate) RemoveSpray(v ...*Spray) *MatchPlayerUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mpu.RemoveSprayIDs(ids...) + return _u.RemoveSprayIDs(ids...) } // ClearMessages clears all "messages" edges to the Messages entity. -func (mpu *MatchPlayerUpdate) ClearMessages() *MatchPlayerUpdate { - mpu.mutation.ClearMessages() - return mpu +func (_u *MatchPlayerUpdate) ClearMessages() *MatchPlayerUpdate { + _u.mutation.ClearMessages() + return _u } // RemoveMessageIDs removes the "messages" edge to Messages entities by IDs. -func (mpu *MatchPlayerUpdate) RemoveMessageIDs(ids ...int) *MatchPlayerUpdate { - mpu.mutation.RemoveMessageIDs(ids...) - return mpu +func (_u *MatchPlayerUpdate) RemoveMessageIDs(ids ...int) *MatchPlayerUpdate { + _u.mutation.RemoveMessageIDs(ids...) + return _u } // RemoveMessages removes "messages" edges to Messages entities. -func (mpu *MatchPlayerUpdate) RemoveMessages(m ...*Messages) *MatchPlayerUpdate { - ids := make([]int, len(m)) - for i := range m { - ids[i] = m[i].ID +func (_u *MatchPlayerUpdate) RemoveMessages(v ...*Messages) *MatchPlayerUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mpu.RemoveMessageIDs(ids...) + return _u.RemoveMessageIDs(ids...) } // Save executes the query and returns the number of nodes affected by the update operation. -func (mpu *MatchPlayerUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, mpu.sqlSave, mpu.mutation, mpu.hooks) +func (_u *MatchPlayerUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (mpu *MatchPlayerUpdate) SaveX(ctx context.Context) int { - affected, err := mpu.Save(ctx) +func (_u *MatchPlayerUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) if err != nil { panic(err) } @@ -1013,21 +1069,21 @@ func (mpu *MatchPlayerUpdate) SaveX(ctx context.Context) int { } // Exec executes the query. -func (mpu *MatchPlayerUpdate) Exec(ctx context.Context) error { - _, err := mpu.Save(ctx) +func (_u *MatchPlayerUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (mpu *MatchPlayerUpdate) ExecX(ctx context.Context) { - if err := mpu.Exec(ctx); err != nil { +func (_u *MatchPlayerUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (mpu *MatchPlayerUpdate) check() error { - if v, ok := mpu.mutation.Color(); ok { +func (_u *MatchPlayerUpdate) check() error { + if v, ok := _u.mutation.Color(); ok { if err := matchplayer.ColorValidator(v); err != nil { return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "MatchPlayer.color": %w`, err)} } @@ -1036,276 +1092,276 @@ func (mpu *MatchPlayerUpdate) check() error { } // 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 (_u *MatchPlayerUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MatchPlayerUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { - if err := mpu.check(); err != nil { - return n, err +func (_u *MatchPlayerUpdate) sqlSave(ctx context.Context) (_node int, err error) { + if err := _u.check(); err != nil { + return _node, err } _spec := sqlgraph.NewUpdateSpec(matchplayer.Table, matchplayer.Columns, sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt)) - if ps := mpu.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := mpu.mutation.TeamID(); ok { + if value, ok := _u.mutation.TeamID(); ok { _spec.SetField(matchplayer.FieldTeamID, field.TypeInt, value) } - if value, ok := mpu.mutation.AddedTeamID(); ok { + if value, ok := _u.mutation.AddedTeamID(); ok { _spec.AddField(matchplayer.FieldTeamID, field.TypeInt, value) } - if value, ok := mpu.mutation.Kills(); ok { + if value, ok := _u.mutation.Kills(); ok { _spec.SetField(matchplayer.FieldKills, field.TypeInt, value) } - if value, ok := mpu.mutation.AddedKills(); ok { + if value, ok := _u.mutation.AddedKills(); ok { _spec.AddField(matchplayer.FieldKills, field.TypeInt, value) } - if value, ok := mpu.mutation.Deaths(); ok { + if value, ok := _u.mutation.Deaths(); ok { _spec.SetField(matchplayer.FieldDeaths, field.TypeInt, value) } - if value, ok := mpu.mutation.AddedDeaths(); ok { + if value, ok := _u.mutation.AddedDeaths(); ok { _spec.AddField(matchplayer.FieldDeaths, field.TypeInt, value) } - if value, ok := mpu.mutation.Assists(); ok { + if value, ok := _u.mutation.Assists(); ok { _spec.SetField(matchplayer.FieldAssists, field.TypeInt, value) } - if value, ok := mpu.mutation.AddedAssists(); ok { + if value, ok := _u.mutation.AddedAssists(); ok { _spec.AddField(matchplayer.FieldAssists, field.TypeInt, value) } - if value, ok := mpu.mutation.Headshot(); ok { + if value, ok := _u.mutation.Headshot(); ok { _spec.SetField(matchplayer.FieldHeadshot, field.TypeInt, value) } - if value, ok := mpu.mutation.AddedHeadshot(); ok { + if value, ok := _u.mutation.AddedHeadshot(); ok { _spec.AddField(matchplayer.FieldHeadshot, field.TypeInt, value) } - if value, ok := mpu.mutation.Mvp(); ok { + if value, ok := _u.mutation.Mvp(); ok { _spec.SetField(matchplayer.FieldMvp, field.TypeUint, value) } - if value, ok := mpu.mutation.AddedMvp(); ok { + if value, ok := _u.mutation.AddedMvp(); ok { _spec.AddField(matchplayer.FieldMvp, field.TypeUint, value) } - if value, ok := mpu.mutation.Score(); ok { + if value, ok := _u.mutation.Score(); ok { _spec.SetField(matchplayer.FieldScore, field.TypeInt, value) } - if value, ok := mpu.mutation.AddedScore(); ok { + if value, ok := _u.mutation.AddedScore(); ok { _spec.AddField(matchplayer.FieldScore, field.TypeInt, value) } - if value, ok := mpu.mutation.RankNew(); ok { + if value, ok := _u.mutation.RankNew(); ok { _spec.SetField(matchplayer.FieldRankNew, field.TypeInt, value) } - if value, ok := mpu.mutation.AddedRankNew(); ok { + if value, ok := _u.mutation.AddedRankNew(); ok { _spec.AddField(matchplayer.FieldRankNew, field.TypeInt, value) } - if mpu.mutation.RankNewCleared() { + if _u.mutation.RankNewCleared() { _spec.ClearField(matchplayer.FieldRankNew, field.TypeInt) } - if value, ok := mpu.mutation.RankOld(); ok { + if value, ok := _u.mutation.RankOld(); ok { _spec.SetField(matchplayer.FieldRankOld, field.TypeInt, value) } - if value, ok := mpu.mutation.AddedRankOld(); ok { + if value, ok := _u.mutation.AddedRankOld(); ok { _spec.AddField(matchplayer.FieldRankOld, field.TypeInt, value) } - if mpu.mutation.RankOldCleared() { + if _u.mutation.RankOldCleared() { _spec.ClearField(matchplayer.FieldRankOld, field.TypeInt) } - if value, ok := mpu.mutation.Mk2(); ok { + if value, ok := _u.mutation.Mk2(); ok { _spec.SetField(matchplayer.FieldMk2, field.TypeUint, value) } - if value, ok := mpu.mutation.AddedMk2(); ok { + if value, ok := _u.mutation.AddedMk2(); ok { _spec.AddField(matchplayer.FieldMk2, field.TypeUint, value) } - if mpu.mutation.Mk2Cleared() { + if _u.mutation.Mk2Cleared() { _spec.ClearField(matchplayer.FieldMk2, field.TypeUint) } - if value, ok := mpu.mutation.Mk3(); ok { + if value, ok := _u.mutation.Mk3(); ok { _spec.SetField(matchplayer.FieldMk3, field.TypeUint, value) } - if value, ok := mpu.mutation.AddedMk3(); ok { + if value, ok := _u.mutation.AddedMk3(); ok { _spec.AddField(matchplayer.FieldMk3, field.TypeUint, value) } - if mpu.mutation.Mk3Cleared() { + if _u.mutation.Mk3Cleared() { _spec.ClearField(matchplayer.FieldMk3, field.TypeUint) } - if value, ok := mpu.mutation.Mk4(); ok { + if value, ok := _u.mutation.Mk4(); ok { _spec.SetField(matchplayer.FieldMk4, field.TypeUint, value) } - if value, ok := mpu.mutation.AddedMk4(); ok { + if value, ok := _u.mutation.AddedMk4(); ok { _spec.AddField(matchplayer.FieldMk4, field.TypeUint, value) } - if mpu.mutation.Mk4Cleared() { + if _u.mutation.Mk4Cleared() { _spec.ClearField(matchplayer.FieldMk4, field.TypeUint) } - if value, ok := mpu.mutation.Mk5(); ok { + if value, ok := _u.mutation.Mk5(); ok { _spec.SetField(matchplayer.FieldMk5, field.TypeUint, value) } - if value, ok := mpu.mutation.AddedMk5(); ok { + if value, ok := _u.mutation.AddedMk5(); ok { _spec.AddField(matchplayer.FieldMk5, field.TypeUint, value) } - if mpu.mutation.Mk5Cleared() { + if _u.mutation.Mk5Cleared() { _spec.ClearField(matchplayer.FieldMk5, field.TypeUint) } - if value, ok := mpu.mutation.DmgEnemy(); ok { + if value, ok := _u.mutation.DmgEnemy(); ok { _spec.SetField(matchplayer.FieldDmgEnemy, field.TypeUint, value) } - if value, ok := mpu.mutation.AddedDmgEnemy(); ok { + if value, ok := _u.mutation.AddedDmgEnemy(); ok { _spec.AddField(matchplayer.FieldDmgEnemy, field.TypeUint, value) } - if mpu.mutation.DmgEnemyCleared() { + if _u.mutation.DmgEnemyCleared() { _spec.ClearField(matchplayer.FieldDmgEnemy, field.TypeUint) } - if value, ok := mpu.mutation.DmgTeam(); ok { + if value, ok := _u.mutation.DmgTeam(); ok { _spec.SetField(matchplayer.FieldDmgTeam, field.TypeUint, value) } - if value, ok := mpu.mutation.AddedDmgTeam(); ok { + if value, ok := _u.mutation.AddedDmgTeam(); ok { _spec.AddField(matchplayer.FieldDmgTeam, field.TypeUint, value) } - if mpu.mutation.DmgTeamCleared() { + if _u.mutation.DmgTeamCleared() { _spec.ClearField(matchplayer.FieldDmgTeam, field.TypeUint) } - if value, ok := mpu.mutation.UdHe(); ok { + if value, ok := _u.mutation.UdHe(); ok { _spec.SetField(matchplayer.FieldUdHe, field.TypeUint, value) } - if value, ok := mpu.mutation.AddedUdHe(); ok { + if value, ok := _u.mutation.AddedUdHe(); ok { _spec.AddField(matchplayer.FieldUdHe, field.TypeUint, value) } - if mpu.mutation.UdHeCleared() { + if _u.mutation.UdHeCleared() { _spec.ClearField(matchplayer.FieldUdHe, field.TypeUint) } - if value, ok := mpu.mutation.UdFlames(); ok { + if value, ok := _u.mutation.UdFlames(); ok { _spec.SetField(matchplayer.FieldUdFlames, field.TypeUint, value) } - if value, ok := mpu.mutation.AddedUdFlames(); ok { + if value, ok := _u.mutation.AddedUdFlames(); ok { _spec.AddField(matchplayer.FieldUdFlames, field.TypeUint, value) } - if mpu.mutation.UdFlamesCleared() { + if _u.mutation.UdFlamesCleared() { _spec.ClearField(matchplayer.FieldUdFlames, field.TypeUint) } - if value, ok := mpu.mutation.UdFlash(); ok { + if value, ok := _u.mutation.UdFlash(); ok { _spec.SetField(matchplayer.FieldUdFlash, field.TypeUint, value) } - if value, ok := mpu.mutation.AddedUdFlash(); ok { + if value, ok := _u.mutation.AddedUdFlash(); ok { _spec.AddField(matchplayer.FieldUdFlash, field.TypeUint, value) } - if mpu.mutation.UdFlashCleared() { + if _u.mutation.UdFlashCleared() { _spec.ClearField(matchplayer.FieldUdFlash, field.TypeUint) } - if value, ok := mpu.mutation.UdDecoy(); ok { + if value, ok := _u.mutation.UdDecoy(); ok { _spec.SetField(matchplayer.FieldUdDecoy, field.TypeUint, value) } - if value, ok := mpu.mutation.AddedUdDecoy(); ok { + if value, ok := _u.mutation.AddedUdDecoy(); ok { _spec.AddField(matchplayer.FieldUdDecoy, field.TypeUint, value) } - if mpu.mutation.UdDecoyCleared() { + if _u.mutation.UdDecoyCleared() { _spec.ClearField(matchplayer.FieldUdDecoy, field.TypeUint) } - if value, ok := mpu.mutation.UdSmoke(); ok { + if value, ok := _u.mutation.UdSmoke(); ok { _spec.SetField(matchplayer.FieldUdSmoke, field.TypeUint, value) } - if value, ok := mpu.mutation.AddedUdSmoke(); ok { + if value, ok := _u.mutation.AddedUdSmoke(); ok { _spec.AddField(matchplayer.FieldUdSmoke, field.TypeUint, value) } - if mpu.mutation.UdSmokeCleared() { + if _u.mutation.UdSmokeCleared() { _spec.ClearField(matchplayer.FieldUdSmoke, field.TypeUint) } - if value, ok := mpu.mutation.Crosshair(); ok { + if value, ok := _u.mutation.Crosshair(); ok { _spec.SetField(matchplayer.FieldCrosshair, field.TypeString, value) } - if mpu.mutation.CrosshairCleared() { + if _u.mutation.CrosshairCleared() { _spec.ClearField(matchplayer.FieldCrosshair, field.TypeString) } - if value, ok := mpu.mutation.Color(); ok { + if value, ok := _u.mutation.Color(); ok { _spec.SetField(matchplayer.FieldColor, field.TypeEnum, value) } - if mpu.mutation.ColorCleared() { + if _u.mutation.ColorCleared() { _spec.ClearField(matchplayer.FieldColor, field.TypeEnum) } - if value, ok := mpu.mutation.Kast(); ok { + if value, ok := _u.mutation.Kast(); ok { _spec.SetField(matchplayer.FieldKast, field.TypeInt, value) } - if value, ok := mpu.mutation.AddedKast(); ok { + if value, ok := _u.mutation.AddedKast(); ok { _spec.AddField(matchplayer.FieldKast, field.TypeInt, value) } - if mpu.mutation.KastCleared() { + if _u.mutation.KastCleared() { _spec.ClearField(matchplayer.FieldKast, field.TypeInt) } - if value, ok := mpu.mutation.FlashDurationSelf(); ok { + if value, ok := _u.mutation.FlashDurationSelf(); ok { _spec.SetField(matchplayer.FieldFlashDurationSelf, field.TypeFloat32, value) } - if value, ok := mpu.mutation.AddedFlashDurationSelf(); ok { + if value, ok := _u.mutation.AddedFlashDurationSelf(); ok { _spec.AddField(matchplayer.FieldFlashDurationSelf, field.TypeFloat32, value) } - if mpu.mutation.FlashDurationSelfCleared() { + if _u.mutation.FlashDurationSelfCleared() { _spec.ClearField(matchplayer.FieldFlashDurationSelf, field.TypeFloat32) } - if value, ok := mpu.mutation.FlashDurationTeam(); ok { + if value, ok := _u.mutation.FlashDurationTeam(); ok { _spec.SetField(matchplayer.FieldFlashDurationTeam, field.TypeFloat32, value) } - if value, ok := mpu.mutation.AddedFlashDurationTeam(); ok { + if value, ok := _u.mutation.AddedFlashDurationTeam(); ok { _spec.AddField(matchplayer.FieldFlashDurationTeam, field.TypeFloat32, value) } - if mpu.mutation.FlashDurationTeamCleared() { + if _u.mutation.FlashDurationTeamCleared() { _spec.ClearField(matchplayer.FieldFlashDurationTeam, field.TypeFloat32) } - if value, ok := mpu.mutation.FlashDurationEnemy(); ok { + if value, ok := _u.mutation.FlashDurationEnemy(); ok { _spec.SetField(matchplayer.FieldFlashDurationEnemy, field.TypeFloat32, value) } - if value, ok := mpu.mutation.AddedFlashDurationEnemy(); ok { + if value, ok := _u.mutation.AddedFlashDurationEnemy(); ok { _spec.AddField(matchplayer.FieldFlashDurationEnemy, field.TypeFloat32, value) } - if mpu.mutation.FlashDurationEnemyCleared() { + if _u.mutation.FlashDurationEnemyCleared() { _spec.ClearField(matchplayer.FieldFlashDurationEnemy, field.TypeFloat32) } - if value, ok := mpu.mutation.FlashTotalSelf(); ok { + if value, ok := _u.mutation.FlashTotalSelf(); ok { _spec.SetField(matchplayer.FieldFlashTotalSelf, field.TypeUint, value) } - if value, ok := mpu.mutation.AddedFlashTotalSelf(); ok { + if value, ok := _u.mutation.AddedFlashTotalSelf(); ok { _spec.AddField(matchplayer.FieldFlashTotalSelf, field.TypeUint, value) } - if mpu.mutation.FlashTotalSelfCleared() { + if _u.mutation.FlashTotalSelfCleared() { _spec.ClearField(matchplayer.FieldFlashTotalSelf, field.TypeUint) } - if value, ok := mpu.mutation.FlashTotalTeam(); ok { + if value, ok := _u.mutation.FlashTotalTeam(); ok { _spec.SetField(matchplayer.FieldFlashTotalTeam, field.TypeUint, value) } - if value, ok := mpu.mutation.AddedFlashTotalTeam(); ok { + if value, ok := _u.mutation.AddedFlashTotalTeam(); ok { _spec.AddField(matchplayer.FieldFlashTotalTeam, field.TypeUint, value) } - if mpu.mutation.FlashTotalTeamCleared() { + if _u.mutation.FlashTotalTeamCleared() { _spec.ClearField(matchplayer.FieldFlashTotalTeam, field.TypeUint) } - if value, ok := mpu.mutation.FlashTotalEnemy(); ok { + if value, ok := _u.mutation.FlashTotalEnemy(); ok { _spec.SetField(matchplayer.FieldFlashTotalEnemy, field.TypeUint, value) } - if value, ok := mpu.mutation.AddedFlashTotalEnemy(); ok { + if value, ok := _u.mutation.AddedFlashTotalEnemy(); ok { _spec.AddField(matchplayer.FieldFlashTotalEnemy, field.TypeUint, value) } - if mpu.mutation.FlashTotalEnemyCleared() { + if _u.mutation.FlashTotalEnemyCleared() { _spec.ClearField(matchplayer.FieldFlashTotalEnemy, field.TypeUint) } - if value, ok := mpu.mutation.FlashAssists(); ok { + if value, ok := _u.mutation.FlashAssists(); ok { _spec.SetField(matchplayer.FieldFlashAssists, field.TypeInt, value) } - if value, ok := mpu.mutation.AddedFlashAssists(); ok { + if value, ok := _u.mutation.AddedFlashAssists(); ok { _spec.AddField(matchplayer.FieldFlashAssists, field.TypeInt, value) } - if mpu.mutation.FlashAssistsCleared() { + if _u.mutation.FlashAssistsCleared() { _spec.ClearField(matchplayer.FieldFlashAssists, field.TypeInt) } - if value, ok := mpu.mutation.AvgPing(); ok { + if value, ok := _u.mutation.AvgPing(); ok { _spec.SetField(matchplayer.FieldAvgPing, field.TypeFloat64, value) } - if value, ok := mpu.mutation.AddedAvgPing(); ok { + if value, ok := _u.mutation.AddedAvgPing(); ok { _spec.AddField(matchplayer.FieldAvgPing, field.TypeFloat64, value) } - if mpu.mutation.AvgPingCleared() { + if _u.mutation.AvgPingCleared() { _spec.ClearField(matchplayer.FieldAvgPing, field.TypeFloat64) } - if mpu.mutation.MatchesCleared() { + if _u.mutation.MatchesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -1318,7 +1374,7 @@ func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mpu.mutation.MatchesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.MatchesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -1334,7 +1390,7 @@ func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if mpu.mutation.PlayersCleared() { + if _u.mutation.PlayersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -1347,7 +1403,7 @@ func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mpu.mutation.PlayersIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PlayersIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -1363,7 +1419,7 @@ func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if mpu.mutation.WeaponStatsCleared() { + if _u.mutation.WeaponStatsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -1376,7 +1432,7 @@ func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mpu.mutation.RemovedWeaponStatsIDs(); len(nodes) > 0 && !mpu.mutation.WeaponStatsCleared() { + if nodes := _u.mutation.RemovedWeaponStatsIDs(); len(nodes) > 0 && !_u.mutation.WeaponStatsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -1392,7 +1448,7 @@ func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mpu.mutation.WeaponStatsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.WeaponStatsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -1408,7 +1464,7 @@ func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if mpu.mutation.RoundStatsCleared() { + if _u.mutation.RoundStatsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -1421,7 +1477,7 @@ func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mpu.mutation.RemovedRoundStatsIDs(); len(nodes) > 0 && !mpu.mutation.RoundStatsCleared() { + if nodes := _u.mutation.RemovedRoundStatsIDs(); len(nodes) > 0 && !_u.mutation.RoundStatsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -1437,7 +1493,7 @@ func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mpu.mutation.RoundStatsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.RoundStatsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -1453,7 +1509,7 @@ func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if mpu.mutation.SprayCleared() { + if _u.mutation.SprayCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -1466,7 +1522,7 @@ func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mpu.mutation.RemovedSprayIDs(); len(nodes) > 0 && !mpu.mutation.SprayCleared() { + if nodes := _u.mutation.RemovedSprayIDs(); len(nodes) > 0 && !_u.mutation.SprayCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -1482,7 +1538,7 @@ func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mpu.mutation.SprayIDs(); len(nodes) > 0 { + if nodes := _u.mutation.SprayIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -1498,7 +1554,7 @@ func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if mpu.mutation.MessagesCleared() { + if _u.mutation.MessagesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -1511,7 +1567,7 @@ func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mpu.mutation.RemovedMessagesIDs(); len(nodes) > 0 && !mpu.mutation.MessagesCleared() { + if nodes := _u.mutation.RemovedMessagesIDs(); len(nodes) > 0 && !_u.mutation.MessagesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -1527,7 +1583,7 @@ func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mpu.mutation.MessagesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.MessagesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -1543,8 +1599,8 @@ func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(mpu.modifiers...) - if n, err = sqlgraph.UpdateNodes(ctx, mpu.driver, _spec); err != nil { + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{matchplayer.Label} } else if sqlgraph.IsConstraintError(err) { @@ -1552,8 +1608,8 @@ func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } return 0, err } - mpu.mutation.done = true - return n, nil + _u.mutation.done = true + return _node, nil } // MatchPlayerUpdateOne is the builder for updating a single MatchPlayer entity. @@ -1566,990 +1622,1046 @@ type MatchPlayerUpdateOne struct { } // SetTeamID sets the "team_id" field. -func (mpuo *MatchPlayerUpdateOne) SetTeamID(i int) *MatchPlayerUpdateOne { - mpuo.mutation.ResetTeamID() - mpuo.mutation.SetTeamID(i) - return mpuo +func (_u *MatchPlayerUpdateOne) SetTeamID(v int) *MatchPlayerUpdateOne { + _u.mutation.ResetTeamID() + _u.mutation.SetTeamID(v) + return _u } -// AddTeamID adds i to the "team_id" field. -func (mpuo *MatchPlayerUpdateOne) AddTeamID(i int) *MatchPlayerUpdateOne { - mpuo.mutation.AddTeamID(i) - return mpuo +// SetNillableTeamID sets the "team_id" field if the given value is not nil. +func (_u *MatchPlayerUpdateOne) SetNillableTeamID(v *int) *MatchPlayerUpdateOne { + if v != nil { + _u.SetTeamID(*v) + } + return _u +} + +// AddTeamID adds value to the "team_id" field. +func (_u *MatchPlayerUpdateOne) AddTeamID(v int) *MatchPlayerUpdateOne { + _u.mutation.AddTeamID(v) + return _u } // SetKills sets the "kills" field. -func (mpuo *MatchPlayerUpdateOne) SetKills(i int) *MatchPlayerUpdateOne { - mpuo.mutation.ResetKills() - mpuo.mutation.SetKills(i) - return mpuo +func (_u *MatchPlayerUpdateOne) SetKills(v int) *MatchPlayerUpdateOne { + _u.mutation.ResetKills() + _u.mutation.SetKills(v) + return _u } -// AddKills adds i to the "kills" field. -func (mpuo *MatchPlayerUpdateOne) AddKills(i int) *MatchPlayerUpdateOne { - mpuo.mutation.AddKills(i) - return mpuo +// SetNillableKills sets the "kills" field if the given value is not nil. +func (_u *MatchPlayerUpdateOne) SetNillableKills(v *int) *MatchPlayerUpdateOne { + if v != nil { + _u.SetKills(*v) + } + return _u +} + +// AddKills adds value to the "kills" field. +func (_u *MatchPlayerUpdateOne) AddKills(v int) *MatchPlayerUpdateOne { + _u.mutation.AddKills(v) + return _u } // SetDeaths sets the "deaths" field. -func (mpuo *MatchPlayerUpdateOne) SetDeaths(i int) *MatchPlayerUpdateOne { - mpuo.mutation.ResetDeaths() - mpuo.mutation.SetDeaths(i) - return mpuo +func (_u *MatchPlayerUpdateOne) SetDeaths(v int) *MatchPlayerUpdateOne { + _u.mutation.ResetDeaths() + _u.mutation.SetDeaths(v) + return _u } -// AddDeaths adds i to the "deaths" field. -func (mpuo *MatchPlayerUpdateOne) AddDeaths(i int) *MatchPlayerUpdateOne { - mpuo.mutation.AddDeaths(i) - return mpuo +// SetNillableDeaths sets the "deaths" field if the given value is not nil. +func (_u *MatchPlayerUpdateOne) SetNillableDeaths(v *int) *MatchPlayerUpdateOne { + if v != nil { + _u.SetDeaths(*v) + } + return _u +} + +// AddDeaths adds value to the "deaths" field. +func (_u *MatchPlayerUpdateOne) AddDeaths(v int) *MatchPlayerUpdateOne { + _u.mutation.AddDeaths(v) + return _u } // SetAssists sets the "assists" field. -func (mpuo *MatchPlayerUpdateOne) SetAssists(i int) *MatchPlayerUpdateOne { - mpuo.mutation.ResetAssists() - mpuo.mutation.SetAssists(i) - return mpuo +func (_u *MatchPlayerUpdateOne) SetAssists(v int) *MatchPlayerUpdateOne { + _u.mutation.ResetAssists() + _u.mutation.SetAssists(v) + return _u } -// AddAssists adds i to the "assists" field. -func (mpuo *MatchPlayerUpdateOne) AddAssists(i int) *MatchPlayerUpdateOne { - mpuo.mutation.AddAssists(i) - return mpuo +// SetNillableAssists sets the "assists" field if the given value is not nil. +func (_u *MatchPlayerUpdateOne) SetNillableAssists(v *int) *MatchPlayerUpdateOne { + if v != nil { + _u.SetAssists(*v) + } + return _u +} + +// AddAssists adds value to the "assists" field. +func (_u *MatchPlayerUpdateOne) AddAssists(v int) *MatchPlayerUpdateOne { + _u.mutation.AddAssists(v) + return _u } // SetHeadshot sets the "headshot" field. -func (mpuo *MatchPlayerUpdateOne) SetHeadshot(i int) *MatchPlayerUpdateOne { - mpuo.mutation.ResetHeadshot() - mpuo.mutation.SetHeadshot(i) - return mpuo +func (_u *MatchPlayerUpdateOne) SetHeadshot(v int) *MatchPlayerUpdateOne { + _u.mutation.ResetHeadshot() + _u.mutation.SetHeadshot(v) + return _u } -// AddHeadshot adds i to the "headshot" field. -func (mpuo *MatchPlayerUpdateOne) AddHeadshot(i int) *MatchPlayerUpdateOne { - mpuo.mutation.AddHeadshot(i) - return mpuo +// SetNillableHeadshot sets the "headshot" field if the given value is not nil. +func (_u *MatchPlayerUpdateOne) SetNillableHeadshot(v *int) *MatchPlayerUpdateOne { + if v != nil { + _u.SetHeadshot(*v) + } + return _u +} + +// AddHeadshot adds value to the "headshot" field. +func (_u *MatchPlayerUpdateOne) AddHeadshot(v int) *MatchPlayerUpdateOne { + _u.mutation.AddHeadshot(v) + return _u } // SetMvp sets the "mvp" field. -func (mpuo *MatchPlayerUpdateOne) SetMvp(u uint) *MatchPlayerUpdateOne { - mpuo.mutation.ResetMvp() - mpuo.mutation.SetMvp(u) - return mpuo +func (_u *MatchPlayerUpdateOne) SetMvp(v uint) *MatchPlayerUpdateOne { + _u.mutation.ResetMvp() + _u.mutation.SetMvp(v) + return _u } -// AddMvp adds u to the "mvp" field. -func (mpuo *MatchPlayerUpdateOne) AddMvp(u int) *MatchPlayerUpdateOne { - mpuo.mutation.AddMvp(u) - return mpuo +// SetNillableMvp sets the "mvp" field if the given value is not nil. +func (_u *MatchPlayerUpdateOne) SetNillableMvp(v *uint) *MatchPlayerUpdateOne { + if v != nil { + _u.SetMvp(*v) + } + return _u +} + +// AddMvp adds value to the "mvp" field. +func (_u *MatchPlayerUpdateOne) AddMvp(v int) *MatchPlayerUpdateOne { + _u.mutation.AddMvp(v) + return _u } // SetScore sets the "score" field. -func (mpuo *MatchPlayerUpdateOne) SetScore(i int) *MatchPlayerUpdateOne { - mpuo.mutation.ResetScore() - mpuo.mutation.SetScore(i) - return mpuo +func (_u *MatchPlayerUpdateOne) SetScore(v int) *MatchPlayerUpdateOne { + _u.mutation.ResetScore() + _u.mutation.SetScore(v) + return _u } -// AddScore adds i to the "score" field. -func (mpuo *MatchPlayerUpdateOne) AddScore(i int) *MatchPlayerUpdateOne { - mpuo.mutation.AddScore(i) - return mpuo +// SetNillableScore sets the "score" field if the given value is not nil. +func (_u *MatchPlayerUpdateOne) SetNillableScore(v *int) *MatchPlayerUpdateOne { + if v != nil { + _u.SetScore(*v) + } + return _u +} + +// AddScore adds value to the "score" field. +func (_u *MatchPlayerUpdateOne) AddScore(v int) *MatchPlayerUpdateOne { + _u.mutation.AddScore(v) + return _u } // SetRankNew sets the "rank_new" field. -func (mpuo *MatchPlayerUpdateOne) SetRankNew(i int) *MatchPlayerUpdateOne { - mpuo.mutation.ResetRankNew() - mpuo.mutation.SetRankNew(i) - return mpuo +func (_u *MatchPlayerUpdateOne) SetRankNew(v int) *MatchPlayerUpdateOne { + _u.mutation.ResetRankNew() + _u.mutation.SetRankNew(v) + return _u } // SetNillableRankNew sets the "rank_new" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableRankNew(i *int) *MatchPlayerUpdateOne { - if i != nil { - mpuo.SetRankNew(*i) +func (_u *MatchPlayerUpdateOne) SetNillableRankNew(v *int) *MatchPlayerUpdateOne { + if v != nil { + _u.SetRankNew(*v) } - return mpuo + return _u } -// AddRankNew adds i to the "rank_new" field. -func (mpuo *MatchPlayerUpdateOne) AddRankNew(i int) *MatchPlayerUpdateOne { - mpuo.mutation.AddRankNew(i) - return mpuo +// AddRankNew adds value to the "rank_new" field. +func (_u *MatchPlayerUpdateOne) AddRankNew(v int) *MatchPlayerUpdateOne { + _u.mutation.AddRankNew(v) + return _u } // ClearRankNew clears the value of the "rank_new" field. -func (mpuo *MatchPlayerUpdateOne) ClearRankNew() *MatchPlayerUpdateOne { - mpuo.mutation.ClearRankNew() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearRankNew() *MatchPlayerUpdateOne { + _u.mutation.ClearRankNew() + return _u } // SetRankOld sets the "rank_old" field. -func (mpuo *MatchPlayerUpdateOne) SetRankOld(i int) *MatchPlayerUpdateOne { - mpuo.mutation.ResetRankOld() - mpuo.mutation.SetRankOld(i) - return mpuo +func (_u *MatchPlayerUpdateOne) SetRankOld(v int) *MatchPlayerUpdateOne { + _u.mutation.ResetRankOld() + _u.mutation.SetRankOld(v) + return _u } // SetNillableRankOld sets the "rank_old" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableRankOld(i *int) *MatchPlayerUpdateOne { - if i != nil { - mpuo.SetRankOld(*i) +func (_u *MatchPlayerUpdateOne) SetNillableRankOld(v *int) *MatchPlayerUpdateOne { + if v != nil { + _u.SetRankOld(*v) } - return mpuo + return _u } -// AddRankOld adds i to the "rank_old" field. -func (mpuo *MatchPlayerUpdateOne) AddRankOld(i int) *MatchPlayerUpdateOne { - mpuo.mutation.AddRankOld(i) - return mpuo +// AddRankOld adds value to the "rank_old" field. +func (_u *MatchPlayerUpdateOne) AddRankOld(v int) *MatchPlayerUpdateOne { + _u.mutation.AddRankOld(v) + return _u } // ClearRankOld clears the value of the "rank_old" field. -func (mpuo *MatchPlayerUpdateOne) ClearRankOld() *MatchPlayerUpdateOne { - mpuo.mutation.ClearRankOld() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearRankOld() *MatchPlayerUpdateOne { + _u.mutation.ClearRankOld() + return _u } // SetMk2 sets the "mk_2" field. -func (mpuo *MatchPlayerUpdateOne) SetMk2(u uint) *MatchPlayerUpdateOne { - mpuo.mutation.ResetMk2() - mpuo.mutation.SetMk2(u) - return mpuo +func (_u *MatchPlayerUpdateOne) SetMk2(v uint) *MatchPlayerUpdateOne { + _u.mutation.ResetMk2() + _u.mutation.SetMk2(v) + return _u } // SetNillableMk2 sets the "mk_2" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableMk2(u *uint) *MatchPlayerUpdateOne { - if u != nil { - mpuo.SetMk2(*u) +func (_u *MatchPlayerUpdateOne) SetNillableMk2(v *uint) *MatchPlayerUpdateOne { + if v != nil { + _u.SetMk2(*v) } - return mpuo + return _u } -// AddMk2 adds u to the "mk_2" field. -func (mpuo *MatchPlayerUpdateOne) AddMk2(u int) *MatchPlayerUpdateOne { - mpuo.mutation.AddMk2(u) - return mpuo +// AddMk2 adds value to the "mk_2" field. +func (_u *MatchPlayerUpdateOne) AddMk2(v int) *MatchPlayerUpdateOne { + _u.mutation.AddMk2(v) + return _u } // ClearMk2 clears the value of the "mk_2" field. -func (mpuo *MatchPlayerUpdateOne) ClearMk2() *MatchPlayerUpdateOne { - mpuo.mutation.ClearMk2() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearMk2() *MatchPlayerUpdateOne { + _u.mutation.ClearMk2() + return _u } // SetMk3 sets the "mk_3" field. -func (mpuo *MatchPlayerUpdateOne) SetMk3(u uint) *MatchPlayerUpdateOne { - mpuo.mutation.ResetMk3() - mpuo.mutation.SetMk3(u) - return mpuo +func (_u *MatchPlayerUpdateOne) SetMk3(v uint) *MatchPlayerUpdateOne { + _u.mutation.ResetMk3() + _u.mutation.SetMk3(v) + return _u } // SetNillableMk3 sets the "mk_3" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableMk3(u *uint) *MatchPlayerUpdateOne { - if u != nil { - mpuo.SetMk3(*u) +func (_u *MatchPlayerUpdateOne) SetNillableMk3(v *uint) *MatchPlayerUpdateOne { + if v != nil { + _u.SetMk3(*v) } - return mpuo + return _u } -// AddMk3 adds u to the "mk_3" field. -func (mpuo *MatchPlayerUpdateOne) AddMk3(u int) *MatchPlayerUpdateOne { - mpuo.mutation.AddMk3(u) - return mpuo +// AddMk3 adds value to the "mk_3" field. +func (_u *MatchPlayerUpdateOne) AddMk3(v int) *MatchPlayerUpdateOne { + _u.mutation.AddMk3(v) + return _u } // ClearMk3 clears the value of the "mk_3" field. -func (mpuo *MatchPlayerUpdateOne) ClearMk3() *MatchPlayerUpdateOne { - mpuo.mutation.ClearMk3() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearMk3() *MatchPlayerUpdateOne { + _u.mutation.ClearMk3() + return _u } // SetMk4 sets the "mk_4" field. -func (mpuo *MatchPlayerUpdateOne) SetMk4(u uint) *MatchPlayerUpdateOne { - mpuo.mutation.ResetMk4() - mpuo.mutation.SetMk4(u) - return mpuo +func (_u *MatchPlayerUpdateOne) SetMk4(v uint) *MatchPlayerUpdateOne { + _u.mutation.ResetMk4() + _u.mutation.SetMk4(v) + return _u } // SetNillableMk4 sets the "mk_4" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableMk4(u *uint) *MatchPlayerUpdateOne { - if u != nil { - mpuo.SetMk4(*u) +func (_u *MatchPlayerUpdateOne) SetNillableMk4(v *uint) *MatchPlayerUpdateOne { + if v != nil { + _u.SetMk4(*v) } - return mpuo + return _u } -// AddMk4 adds u to the "mk_4" field. -func (mpuo *MatchPlayerUpdateOne) AddMk4(u int) *MatchPlayerUpdateOne { - mpuo.mutation.AddMk4(u) - return mpuo +// AddMk4 adds value to the "mk_4" field. +func (_u *MatchPlayerUpdateOne) AddMk4(v int) *MatchPlayerUpdateOne { + _u.mutation.AddMk4(v) + return _u } // ClearMk4 clears the value of the "mk_4" field. -func (mpuo *MatchPlayerUpdateOne) ClearMk4() *MatchPlayerUpdateOne { - mpuo.mutation.ClearMk4() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearMk4() *MatchPlayerUpdateOne { + _u.mutation.ClearMk4() + return _u } // SetMk5 sets the "mk_5" field. -func (mpuo *MatchPlayerUpdateOne) SetMk5(u uint) *MatchPlayerUpdateOne { - mpuo.mutation.ResetMk5() - mpuo.mutation.SetMk5(u) - return mpuo +func (_u *MatchPlayerUpdateOne) SetMk5(v uint) *MatchPlayerUpdateOne { + _u.mutation.ResetMk5() + _u.mutation.SetMk5(v) + return _u } // SetNillableMk5 sets the "mk_5" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableMk5(u *uint) *MatchPlayerUpdateOne { - if u != nil { - mpuo.SetMk5(*u) +func (_u *MatchPlayerUpdateOne) SetNillableMk5(v *uint) *MatchPlayerUpdateOne { + if v != nil { + _u.SetMk5(*v) } - return mpuo + return _u } -// AddMk5 adds u to the "mk_5" field. -func (mpuo *MatchPlayerUpdateOne) AddMk5(u int) *MatchPlayerUpdateOne { - mpuo.mutation.AddMk5(u) - return mpuo +// AddMk5 adds value to the "mk_5" field. +func (_u *MatchPlayerUpdateOne) AddMk5(v int) *MatchPlayerUpdateOne { + _u.mutation.AddMk5(v) + return _u } // ClearMk5 clears the value of the "mk_5" field. -func (mpuo *MatchPlayerUpdateOne) ClearMk5() *MatchPlayerUpdateOne { - mpuo.mutation.ClearMk5() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearMk5() *MatchPlayerUpdateOne { + _u.mutation.ClearMk5() + return _u } // SetDmgEnemy sets the "dmg_enemy" field. -func (mpuo *MatchPlayerUpdateOne) SetDmgEnemy(u uint) *MatchPlayerUpdateOne { - mpuo.mutation.ResetDmgEnemy() - mpuo.mutation.SetDmgEnemy(u) - return mpuo +func (_u *MatchPlayerUpdateOne) SetDmgEnemy(v uint) *MatchPlayerUpdateOne { + _u.mutation.ResetDmgEnemy() + _u.mutation.SetDmgEnemy(v) + return _u } // SetNillableDmgEnemy sets the "dmg_enemy" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableDmgEnemy(u *uint) *MatchPlayerUpdateOne { - if u != nil { - mpuo.SetDmgEnemy(*u) +func (_u *MatchPlayerUpdateOne) SetNillableDmgEnemy(v *uint) *MatchPlayerUpdateOne { + if v != nil { + _u.SetDmgEnemy(*v) } - return mpuo + return _u } -// AddDmgEnemy adds u to the "dmg_enemy" field. -func (mpuo *MatchPlayerUpdateOne) AddDmgEnemy(u int) *MatchPlayerUpdateOne { - mpuo.mutation.AddDmgEnemy(u) - return mpuo +// AddDmgEnemy adds value to the "dmg_enemy" field. +func (_u *MatchPlayerUpdateOne) AddDmgEnemy(v int) *MatchPlayerUpdateOne { + _u.mutation.AddDmgEnemy(v) + return _u } // ClearDmgEnemy clears the value of the "dmg_enemy" field. -func (mpuo *MatchPlayerUpdateOne) ClearDmgEnemy() *MatchPlayerUpdateOne { - mpuo.mutation.ClearDmgEnemy() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearDmgEnemy() *MatchPlayerUpdateOne { + _u.mutation.ClearDmgEnemy() + return _u } // SetDmgTeam sets the "dmg_team" field. -func (mpuo *MatchPlayerUpdateOne) SetDmgTeam(u uint) *MatchPlayerUpdateOne { - mpuo.mutation.ResetDmgTeam() - mpuo.mutation.SetDmgTeam(u) - return mpuo +func (_u *MatchPlayerUpdateOne) SetDmgTeam(v uint) *MatchPlayerUpdateOne { + _u.mutation.ResetDmgTeam() + _u.mutation.SetDmgTeam(v) + return _u } // SetNillableDmgTeam sets the "dmg_team" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableDmgTeam(u *uint) *MatchPlayerUpdateOne { - if u != nil { - mpuo.SetDmgTeam(*u) +func (_u *MatchPlayerUpdateOne) SetNillableDmgTeam(v *uint) *MatchPlayerUpdateOne { + if v != nil { + _u.SetDmgTeam(*v) } - return mpuo + return _u } -// AddDmgTeam adds u to the "dmg_team" field. -func (mpuo *MatchPlayerUpdateOne) AddDmgTeam(u int) *MatchPlayerUpdateOne { - mpuo.mutation.AddDmgTeam(u) - return mpuo +// AddDmgTeam adds value to the "dmg_team" field. +func (_u *MatchPlayerUpdateOne) AddDmgTeam(v int) *MatchPlayerUpdateOne { + _u.mutation.AddDmgTeam(v) + return _u } // ClearDmgTeam clears the value of the "dmg_team" field. -func (mpuo *MatchPlayerUpdateOne) ClearDmgTeam() *MatchPlayerUpdateOne { - mpuo.mutation.ClearDmgTeam() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearDmgTeam() *MatchPlayerUpdateOne { + _u.mutation.ClearDmgTeam() + return _u } // SetUdHe sets the "ud_he" field. -func (mpuo *MatchPlayerUpdateOne) SetUdHe(u uint) *MatchPlayerUpdateOne { - mpuo.mutation.ResetUdHe() - mpuo.mutation.SetUdHe(u) - return mpuo +func (_u *MatchPlayerUpdateOne) SetUdHe(v uint) *MatchPlayerUpdateOne { + _u.mutation.ResetUdHe() + _u.mutation.SetUdHe(v) + return _u } // SetNillableUdHe sets the "ud_he" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableUdHe(u *uint) *MatchPlayerUpdateOne { - if u != nil { - mpuo.SetUdHe(*u) +func (_u *MatchPlayerUpdateOne) SetNillableUdHe(v *uint) *MatchPlayerUpdateOne { + if v != nil { + _u.SetUdHe(*v) } - return mpuo + return _u } -// AddUdHe adds u to the "ud_he" field. -func (mpuo *MatchPlayerUpdateOne) AddUdHe(u int) *MatchPlayerUpdateOne { - mpuo.mutation.AddUdHe(u) - return mpuo +// AddUdHe adds value to the "ud_he" field. +func (_u *MatchPlayerUpdateOne) AddUdHe(v int) *MatchPlayerUpdateOne { + _u.mutation.AddUdHe(v) + return _u } // ClearUdHe clears the value of the "ud_he" field. -func (mpuo *MatchPlayerUpdateOne) ClearUdHe() *MatchPlayerUpdateOne { - mpuo.mutation.ClearUdHe() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearUdHe() *MatchPlayerUpdateOne { + _u.mutation.ClearUdHe() + return _u } // SetUdFlames sets the "ud_flames" field. -func (mpuo *MatchPlayerUpdateOne) SetUdFlames(u uint) *MatchPlayerUpdateOne { - mpuo.mutation.ResetUdFlames() - mpuo.mutation.SetUdFlames(u) - return mpuo +func (_u *MatchPlayerUpdateOne) SetUdFlames(v uint) *MatchPlayerUpdateOne { + _u.mutation.ResetUdFlames() + _u.mutation.SetUdFlames(v) + return _u } // SetNillableUdFlames sets the "ud_flames" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableUdFlames(u *uint) *MatchPlayerUpdateOne { - if u != nil { - mpuo.SetUdFlames(*u) +func (_u *MatchPlayerUpdateOne) SetNillableUdFlames(v *uint) *MatchPlayerUpdateOne { + if v != nil { + _u.SetUdFlames(*v) } - return mpuo + return _u } -// AddUdFlames adds u to the "ud_flames" field. -func (mpuo *MatchPlayerUpdateOne) AddUdFlames(u int) *MatchPlayerUpdateOne { - mpuo.mutation.AddUdFlames(u) - return mpuo +// AddUdFlames adds value to the "ud_flames" field. +func (_u *MatchPlayerUpdateOne) AddUdFlames(v int) *MatchPlayerUpdateOne { + _u.mutation.AddUdFlames(v) + return _u } // ClearUdFlames clears the value of the "ud_flames" field. -func (mpuo *MatchPlayerUpdateOne) ClearUdFlames() *MatchPlayerUpdateOne { - mpuo.mutation.ClearUdFlames() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearUdFlames() *MatchPlayerUpdateOne { + _u.mutation.ClearUdFlames() + return _u } // SetUdFlash sets the "ud_flash" field. -func (mpuo *MatchPlayerUpdateOne) SetUdFlash(u uint) *MatchPlayerUpdateOne { - mpuo.mutation.ResetUdFlash() - mpuo.mutation.SetUdFlash(u) - return mpuo +func (_u *MatchPlayerUpdateOne) SetUdFlash(v uint) *MatchPlayerUpdateOne { + _u.mutation.ResetUdFlash() + _u.mutation.SetUdFlash(v) + return _u } // SetNillableUdFlash sets the "ud_flash" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableUdFlash(u *uint) *MatchPlayerUpdateOne { - if u != nil { - mpuo.SetUdFlash(*u) +func (_u *MatchPlayerUpdateOne) SetNillableUdFlash(v *uint) *MatchPlayerUpdateOne { + if v != nil { + _u.SetUdFlash(*v) } - return mpuo + return _u } -// AddUdFlash adds u to the "ud_flash" field. -func (mpuo *MatchPlayerUpdateOne) AddUdFlash(u int) *MatchPlayerUpdateOne { - mpuo.mutation.AddUdFlash(u) - return mpuo +// AddUdFlash adds value to the "ud_flash" field. +func (_u *MatchPlayerUpdateOne) AddUdFlash(v int) *MatchPlayerUpdateOne { + _u.mutation.AddUdFlash(v) + return _u } // ClearUdFlash clears the value of the "ud_flash" field. -func (mpuo *MatchPlayerUpdateOne) ClearUdFlash() *MatchPlayerUpdateOne { - mpuo.mutation.ClearUdFlash() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearUdFlash() *MatchPlayerUpdateOne { + _u.mutation.ClearUdFlash() + return _u } // SetUdDecoy sets the "ud_decoy" field. -func (mpuo *MatchPlayerUpdateOne) SetUdDecoy(u uint) *MatchPlayerUpdateOne { - mpuo.mutation.ResetUdDecoy() - mpuo.mutation.SetUdDecoy(u) - return mpuo +func (_u *MatchPlayerUpdateOne) SetUdDecoy(v uint) *MatchPlayerUpdateOne { + _u.mutation.ResetUdDecoy() + _u.mutation.SetUdDecoy(v) + return _u } // SetNillableUdDecoy sets the "ud_decoy" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableUdDecoy(u *uint) *MatchPlayerUpdateOne { - if u != nil { - mpuo.SetUdDecoy(*u) +func (_u *MatchPlayerUpdateOne) SetNillableUdDecoy(v *uint) *MatchPlayerUpdateOne { + if v != nil { + _u.SetUdDecoy(*v) } - return mpuo + return _u } -// AddUdDecoy adds u to the "ud_decoy" field. -func (mpuo *MatchPlayerUpdateOne) AddUdDecoy(u int) *MatchPlayerUpdateOne { - mpuo.mutation.AddUdDecoy(u) - return mpuo +// AddUdDecoy adds value to the "ud_decoy" field. +func (_u *MatchPlayerUpdateOne) AddUdDecoy(v int) *MatchPlayerUpdateOne { + _u.mutation.AddUdDecoy(v) + return _u } // ClearUdDecoy clears the value of the "ud_decoy" field. -func (mpuo *MatchPlayerUpdateOne) ClearUdDecoy() *MatchPlayerUpdateOne { - mpuo.mutation.ClearUdDecoy() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearUdDecoy() *MatchPlayerUpdateOne { + _u.mutation.ClearUdDecoy() + return _u } // SetUdSmoke sets the "ud_smoke" field. -func (mpuo *MatchPlayerUpdateOne) SetUdSmoke(u uint) *MatchPlayerUpdateOne { - mpuo.mutation.ResetUdSmoke() - mpuo.mutation.SetUdSmoke(u) - return mpuo +func (_u *MatchPlayerUpdateOne) SetUdSmoke(v uint) *MatchPlayerUpdateOne { + _u.mutation.ResetUdSmoke() + _u.mutation.SetUdSmoke(v) + return _u } // SetNillableUdSmoke sets the "ud_smoke" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableUdSmoke(u *uint) *MatchPlayerUpdateOne { - if u != nil { - mpuo.SetUdSmoke(*u) +func (_u *MatchPlayerUpdateOne) SetNillableUdSmoke(v *uint) *MatchPlayerUpdateOne { + if v != nil { + _u.SetUdSmoke(*v) } - return mpuo + return _u } -// AddUdSmoke adds u to the "ud_smoke" field. -func (mpuo *MatchPlayerUpdateOne) AddUdSmoke(u int) *MatchPlayerUpdateOne { - mpuo.mutation.AddUdSmoke(u) - return mpuo +// AddUdSmoke adds value to the "ud_smoke" field. +func (_u *MatchPlayerUpdateOne) AddUdSmoke(v int) *MatchPlayerUpdateOne { + _u.mutation.AddUdSmoke(v) + return _u } // ClearUdSmoke clears the value of the "ud_smoke" field. -func (mpuo *MatchPlayerUpdateOne) ClearUdSmoke() *MatchPlayerUpdateOne { - mpuo.mutation.ClearUdSmoke() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearUdSmoke() *MatchPlayerUpdateOne { + _u.mutation.ClearUdSmoke() + return _u } // SetCrosshair sets the "crosshair" field. -func (mpuo *MatchPlayerUpdateOne) SetCrosshair(s string) *MatchPlayerUpdateOne { - mpuo.mutation.SetCrosshair(s) - return mpuo +func (_u *MatchPlayerUpdateOne) SetCrosshair(v string) *MatchPlayerUpdateOne { + _u.mutation.SetCrosshair(v) + return _u } // SetNillableCrosshair sets the "crosshair" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableCrosshair(s *string) *MatchPlayerUpdateOne { - if s != nil { - mpuo.SetCrosshair(*s) +func (_u *MatchPlayerUpdateOne) SetNillableCrosshair(v *string) *MatchPlayerUpdateOne { + if v != nil { + _u.SetCrosshair(*v) } - return mpuo + return _u } // ClearCrosshair clears the value of the "crosshair" field. -func (mpuo *MatchPlayerUpdateOne) ClearCrosshair() *MatchPlayerUpdateOne { - mpuo.mutation.ClearCrosshair() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearCrosshair() *MatchPlayerUpdateOne { + _u.mutation.ClearCrosshair() + return _u } // SetColor sets the "color" field. -func (mpuo *MatchPlayerUpdateOne) SetColor(m matchplayer.Color) *MatchPlayerUpdateOne { - mpuo.mutation.SetColor(m) - return mpuo +func (_u *MatchPlayerUpdateOne) SetColor(v matchplayer.Color) *MatchPlayerUpdateOne { + _u.mutation.SetColor(v) + return _u } // SetNillableColor sets the "color" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableColor(m *matchplayer.Color) *MatchPlayerUpdateOne { - if m != nil { - mpuo.SetColor(*m) +func (_u *MatchPlayerUpdateOne) SetNillableColor(v *matchplayer.Color) *MatchPlayerUpdateOne { + if v != nil { + _u.SetColor(*v) } - return mpuo + return _u } // ClearColor clears the value of the "color" field. -func (mpuo *MatchPlayerUpdateOne) ClearColor() *MatchPlayerUpdateOne { - mpuo.mutation.ClearColor() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearColor() *MatchPlayerUpdateOne { + _u.mutation.ClearColor() + return _u } // SetKast sets the "kast" field. -func (mpuo *MatchPlayerUpdateOne) SetKast(i int) *MatchPlayerUpdateOne { - mpuo.mutation.ResetKast() - mpuo.mutation.SetKast(i) - return mpuo +func (_u *MatchPlayerUpdateOne) SetKast(v int) *MatchPlayerUpdateOne { + _u.mutation.ResetKast() + _u.mutation.SetKast(v) + return _u } // SetNillableKast sets the "kast" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableKast(i *int) *MatchPlayerUpdateOne { - if i != nil { - mpuo.SetKast(*i) +func (_u *MatchPlayerUpdateOne) SetNillableKast(v *int) *MatchPlayerUpdateOne { + if v != nil { + _u.SetKast(*v) } - return mpuo + return _u } -// AddKast adds i to the "kast" field. -func (mpuo *MatchPlayerUpdateOne) AddKast(i int) *MatchPlayerUpdateOne { - mpuo.mutation.AddKast(i) - return mpuo +// AddKast adds value to the "kast" field. +func (_u *MatchPlayerUpdateOne) AddKast(v int) *MatchPlayerUpdateOne { + _u.mutation.AddKast(v) + return _u } // ClearKast clears the value of the "kast" field. -func (mpuo *MatchPlayerUpdateOne) ClearKast() *MatchPlayerUpdateOne { - mpuo.mutation.ClearKast() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearKast() *MatchPlayerUpdateOne { + _u.mutation.ClearKast() + return _u } // SetFlashDurationSelf sets the "flash_duration_self" field. -func (mpuo *MatchPlayerUpdateOne) SetFlashDurationSelf(f float32) *MatchPlayerUpdateOne { - mpuo.mutation.ResetFlashDurationSelf() - mpuo.mutation.SetFlashDurationSelf(f) - return mpuo +func (_u *MatchPlayerUpdateOne) SetFlashDurationSelf(v float32) *MatchPlayerUpdateOne { + _u.mutation.ResetFlashDurationSelf() + _u.mutation.SetFlashDurationSelf(v) + return _u } // SetNillableFlashDurationSelf sets the "flash_duration_self" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableFlashDurationSelf(f *float32) *MatchPlayerUpdateOne { - if f != nil { - mpuo.SetFlashDurationSelf(*f) +func (_u *MatchPlayerUpdateOne) SetNillableFlashDurationSelf(v *float32) *MatchPlayerUpdateOne { + if v != nil { + _u.SetFlashDurationSelf(*v) } - return mpuo + return _u } -// AddFlashDurationSelf adds f to the "flash_duration_self" field. -func (mpuo *MatchPlayerUpdateOne) AddFlashDurationSelf(f float32) *MatchPlayerUpdateOne { - mpuo.mutation.AddFlashDurationSelf(f) - return mpuo +// AddFlashDurationSelf adds value to the "flash_duration_self" field. +func (_u *MatchPlayerUpdateOne) AddFlashDurationSelf(v float32) *MatchPlayerUpdateOne { + _u.mutation.AddFlashDurationSelf(v) + return _u } // ClearFlashDurationSelf clears the value of the "flash_duration_self" field. -func (mpuo *MatchPlayerUpdateOne) ClearFlashDurationSelf() *MatchPlayerUpdateOne { - mpuo.mutation.ClearFlashDurationSelf() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearFlashDurationSelf() *MatchPlayerUpdateOne { + _u.mutation.ClearFlashDurationSelf() + return _u } // SetFlashDurationTeam sets the "flash_duration_team" field. -func (mpuo *MatchPlayerUpdateOne) SetFlashDurationTeam(f float32) *MatchPlayerUpdateOne { - mpuo.mutation.ResetFlashDurationTeam() - mpuo.mutation.SetFlashDurationTeam(f) - return mpuo +func (_u *MatchPlayerUpdateOne) SetFlashDurationTeam(v float32) *MatchPlayerUpdateOne { + _u.mutation.ResetFlashDurationTeam() + _u.mutation.SetFlashDurationTeam(v) + return _u } // SetNillableFlashDurationTeam sets the "flash_duration_team" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableFlashDurationTeam(f *float32) *MatchPlayerUpdateOne { - if f != nil { - mpuo.SetFlashDurationTeam(*f) +func (_u *MatchPlayerUpdateOne) SetNillableFlashDurationTeam(v *float32) *MatchPlayerUpdateOne { + if v != nil { + _u.SetFlashDurationTeam(*v) } - return mpuo + return _u } -// AddFlashDurationTeam adds f to the "flash_duration_team" field. -func (mpuo *MatchPlayerUpdateOne) AddFlashDurationTeam(f float32) *MatchPlayerUpdateOne { - mpuo.mutation.AddFlashDurationTeam(f) - return mpuo +// AddFlashDurationTeam adds value to the "flash_duration_team" field. +func (_u *MatchPlayerUpdateOne) AddFlashDurationTeam(v float32) *MatchPlayerUpdateOne { + _u.mutation.AddFlashDurationTeam(v) + return _u } // ClearFlashDurationTeam clears the value of the "flash_duration_team" field. -func (mpuo *MatchPlayerUpdateOne) ClearFlashDurationTeam() *MatchPlayerUpdateOne { - mpuo.mutation.ClearFlashDurationTeam() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearFlashDurationTeam() *MatchPlayerUpdateOne { + _u.mutation.ClearFlashDurationTeam() + return _u } // SetFlashDurationEnemy sets the "flash_duration_enemy" field. -func (mpuo *MatchPlayerUpdateOne) SetFlashDurationEnemy(f float32) *MatchPlayerUpdateOne { - mpuo.mutation.ResetFlashDurationEnemy() - mpuo.mutation.SetFlashDurationEnemy(f) - return mpuo +func (_u *MatchPlayerUpdateOne) SetFlashDurationEnemy(v float32) *MatchPlayerUpdateOne { + _u.mutation.ResetFlashDurationEnemy() + _u.mutation.SetFlashDurationEnemy(v) + return _u } // SetNillableFlashDurationEnemy sets the "flash_duration_enemy" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableFlashDurationEnemy(f *float32) *MatchPlayerUpdateOne { - if f != nil { - mpuo.SetFlashDurationEnemy(*f) +func (_u *MatchPlayerUpdateOne) SetNillableFlashDurationEnemy(v *float32) *MatchPlayerUpdateOne { + if v != nil { + _u.SetFlashDurationEnemy(*v) } - return mpuo + return _u } -// AddFlashDurationEnemy adds f to the "flash_duration_enemy" field. -func (mpuo *MatchPlayerUpdateOne) AddFlashDurationEnemy(f float32) *MatchPlayerUpdateOne { - mpuo.mutation.AddFlashDurationEnemy(f) - return mpuo +// AddFlashDurationEnemy adds value to the "flash_duration_enemy" field. +func (_u *MatchPlayerUpdateOne) AddFlashDurationEnemy(v float32) *MatchPlayerUpdateOne { + _u.mutation.AddFlashDurationEnemy(v) + return _u } // ClearFlashDurationEnemy clears the value of the "flash_duration_enemy" field. -func (mpuo *MatchPlayerUpdateOne) ClearFlashDurationEnemy() *MatchPlayerUpdateOne { - mpuo.mutation.ClearFlashDurationEnemy() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearFlashDurationEnemy() *MatchPlayerUpdateOne { + _u.mutation.ClearFlashDurationEnemy() + return _u } // SetFlashTotalSelf sets the "flash_total_self" field. -func (mpuo *MatchPlayerUpdateOne) SetFlashTotalSelf(u uint) *MatchPlayerUpdateOne { - mpuo.mutation.ResetFlashTotalSelf() - mpuo.mutation.SetFlashTotalSelf(u) - return mpuo +func (_u *MatchPlayerUpdateOne) SetFlashTotalSelf(v uint) *MatchPlayerUpdateOne { + _u.mutation.ResetFlashTotalSelf() + _u.mutation.SetFlashTotalSelf(v) + return _u } // SetNillableFlashTotalSelf sets the "flash_total_self" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableFlashTotalSelf(u *uint) *MatchPlayerUpdateOne { - if u != nil { - mpuo.SetFlashTotalSelf(*u) +func (_u *MatchPlayerUpdateOne) SetNillableFlashTotalSelf(v *uint) *MatchPlayerUpdateOne { + if v != nil { + _u.SetFlashTotalSelf(*v) } - return mpuo + return _u } -// AddFlashTotalSelf adds u to the "flash_total_self" field. -func (mpuo *MatchPlayerUpdateOne) AddFlashTotalSelf(u int) *MatchPlayerUpdateOne { - mpuo.mutation.AddFlashTotalSelf(u) - return mpuo +// AddFlashTotalSelf adds value to the "flash_total_self" field. +func (_u *MatchPlayerUpdateOne) AddFlashTotalSelf(v int) *MatchPlayerUpdateOne { + _u.mutation.AddFlashTotalSelf(v) + return _u } // ClearFlashTotalSelf clears the value of the "flash_total_self" field. -func (mpuo *MatchPlayerUpdateOne) ClearFlashTotalSelf() *MatchPlayerUpdateOne { - mpuo.mutation.ClearFlashTotalSelf() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearFlashTotalSelf() *MatchPlayerUpdateOne { + _u.mutation.ClearFlashTotalSelf() + return _u } // SetFlashTotalTeam sets the "flash_total_team" field. -func (mpuo *MatchPlayerUpdateOne) SetFlashTotalTeam(u uint) *MatchPlayerUpdateOne { - mpuo.mutation.ResetFlashTotalTeam() - mpuo.mutation.SetFlashTotalTeam(u) - return mpuo +func (_u *MatchPlayerUpdateOne) SetFlashTotalTeam(v uint) *MatchPlayerUpdateOne { + _u.mutation.ResetFlashTotalTeam() + _u.mutation.SetFlashTotalTeam(v) + return _u } // SetNillableFlashTotalTeam sets the "flash_total_team" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableFlashTotalTeam(u *uint) *MatchPlayerUpdateOne { - if u != nil { - mpuo.SetFlashTotalTeam(*u) +func (_u *MatchPlayerUpdateOne) SetNillableFlashTotalTeam(v *uint) *MatchPlayerUpdateOne { + if v != nil { + _u.SetFlashTotalTeam(*v) } - return mpuo + return _u } -// AddFlashTotalTeam adds u to the "flash_total_team" field. -func (mpuo *MatchPlayerUpdateOne) AddFlashTotalTeam(u int) *MatchPlayerUpdateOne { - mpuo.mutation.AddFlashTotalTeam(u) - return mpuo +// AddFlashTotalTeam adds value to the "flash_total_team" field. +func (_u *MatchPlayerUpdateOne) AddFlashTotalTeam(v int) *MatchPlayerUpdateOne { + _u.mutation.AddFlashTotalTeam(v) + return _u } // ClearFlashTotalTeam clears the value of the "flash_total_team" field. -func (mpuo *MatchPlayerUpdateOne) ClearFlashTotalTeam() *MatchPlayerUpdateOne { - mpuo.mutation.ClearFlashTotalTeam() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearFlashTotalTeam() *MatchPlayerUpdateOne { + _u.mutation.ClearFlashTotalTeam() + return _u } // SetFlashTotalEnemy sets the "flash_total_enemy" field. -func (mpuo *MatchPlayerUpdateOne) SetFlashTotalEnemy(u uint) *MatchPlayerUpdateOne { - mpuo.mutation.ResetFlashTotalEnemy() - mpuo.mutation.SetFlashTotalEnemy(u) - return mpuo +func (_u *MatchPlayerUpdateOne) SetFlashTotalEnemy(v uint) *MatchPlayerUpdateOne { + _u.mutation.ResetFlashTotalEnemy() + _u.mutation.SetFlashTotalEnemy(v) + return _u } // SetNillableFlashTotalEnemy sets the "flash_total_enemy" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableFlashTotalEnemy(u *uint) *MatchPlayerUpdateOne { - if u != nil { - mpuo.SetFlashTotalEnemy(*u) +func (_u *MatchPlayerUpdateOne) SetNillableFlashTotalEnemy(v *uint) *MatchPlayerUpdateOne { + if v != nil { + _u.SetFlashTotalEnemy(*v) } - return mpuo + return _u } -// AddFlashTotalEnemy adds u to the "flash_total_enemy" field. -func (mpuo *MatchPlayerUpdateOne) AddFlashTotalEnemy(u int) *MatchPlayerUpdateOne { - mpuo.mutation.AddFlashTotalEnemy(u) - return mpuo +// AddFlashTotalEnemy adds value to the "flash_total_enemy" field. +func (_u *MatchPlayerUpdateOne) AddFlashTotalEnemy(v int) *MatchPlayerUpdateOne { + _u.mutation.AddFlashTotalEnemy(v) + return _u } // ClearFlashTotalEnemy clears the value of the "flash_total_enemy" field. -func (mpuo *MatchPlayerUpdateOne) ClearFlashTotalEnemy() *MatchPlayerUpdateOne { - mpuo.mutation.ClearFlashTotalEnemy() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearFlashTotalEnemy() *MatchPlayerUpdateOne { + _u.mutation.ClearFlashTotalEnemy() + return _u } // SetMatchStats sets the "match_stats" field. -func (mpuo *MatchPlayerUpdateOne) SetMatchStats(u uint64) *MatchPlayerUpdateOne { - mpuo.mutation.SetMatchStats(u) - return mpuo +func (_u *MatchPlayerUpdateOne) SetMatchStats(v uint64) *MatchPlayerUpdateOne { + _u.mutation.SetMatchStats(v) + return _u } // SetNillableMatchStats sets the "match_stats" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableMatchStats(u *uint64) *MatchPlayerUpdateOne { - if u != nil { - mpuo.SetMatchStats(*u) +func (_u *MatchPlayerUpdateOne) SetNillableMatchStats(v *uint64) *MatchPlayerUpdateOne { + if v != nil { + _u.SetMatchStats(*v) } - return mpuo + return _u } // ClearMatchStats clears the value of the "match_stats" field. -func (mpuo *MatchPlayerUpdateOne) ClearMatchStats() *MatchPlayerUpdateOne { - mpuo.mutation.ClearMatchStats() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearMatchStats() *MatchPlayerUpdateOne { + _u.mutation.ClearMatchStats() + return _u } // SetPlayerStats sets the "player_stats" field. -func (mpuo *MatchPlayerUpdateOne) SetPlayerStats(u uint64) *MatchPlayerUpdateOne { - mpuo.mutation.SetPlayerStats(u) - return mpuo +func (_u *MatchPlayerUpdateOne) SetPlayerStats(v uint64) *MatchPlayerUpdateOne { + _u.mutation.SetPlayerStats(v) + return _u } // SetNillablePlayerStats sets the "player_stats" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillablePlayerStats(u *uint64) *MatchPlayerUpdateOne { - if u != nil { - mpuo.SetPlayerStats(*u) +func (_u *MatchPlayerUpdateOne) SetNillablePlayerStats(v *uint64) *MatchPlayerUpdateOne { + if v != nil { + _u.SetPlayerStats(*v) } - return mpuo + return _u } // ClearPlayerStats clears the value of the "player_stats" field. -func (mpuo *MatchPlayerUpdateOne) ClearPlayerStats() *MatchPlayerUpdateOne { - mpuo.mutation.ClearPlayerStats() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearPlayerStats() *MatchPlayerUpdateOne { + _u.mutation.ClearPlayerStats() + return _u } // SetFlashAssists sets the "flash_assists" field. -func (mpuo *MatchPlayerUpdateOne) SetFlashAssists(i int) *MatchPlayerUpdateOne { - mpuo.mutation.ResetFlashAssists() - mpuo.mutation.SetFlashAssists(i) - return mpuo +func (_u *MatchPlayerUpdateOne) SetFlashAssists(v int) *MatchPlayerUpdateOne { + _u.mutation.ResetFlashAssists() + _u.mutation.SetFlashAssists(v) + return _u } // SetNillableFlashAssists sets the "flash_assists" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableFlashAssists(i *int) *MatchPlayerUpdateOne { - if i != nil { - mpuo.SetFlashAssists(*i) +func (_u *MatchPlayerUpdateOne) SetNillableFlashAssists(v *int) *MatchPlayerUpdateOne { + if v != nil { + _u.SetFlashAssists(*v) } - return mpuo + return _u } -// AddFlashAssists adds i to the "flash_assists" field. -func (mpuo *MatchPlayerUpdateOne) AddFlashAssists(i int) *MatchPlayerUpdateOne { - mpuo.mutation.AddFlashAssists(i) - return mpuo +// AddFlashAssists adds value to the "flash_assists" field. +func (_u *MatchPlayerUpdateOne) AddFlashAssists(v int) *MatchPlayerUpdateOne { + _u.mutation.AddFlashAssists(v) + return _u } // ClearFlashAssists clears the value of the "flash_assists" field. -func (mpuo *MatchPlayerUpdateOne) ClearFlashAssists() *MatchPlayerUpdateOne { - mpuo.mutation.ClearFlashAssists() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearFlashAssists() *MatchPlayerUpdateOne { + _u.mutation.ClearFlashAssists() + return _u } // SetAvgPing sets the "avg_ping" field. -func (mpuo *MatchPlayerUpdateOne) SetAvgPing(f float64) *MatchPlayerUpdateOne { - mpuo.mutation.ResetAvgPing() - mpuo.mutation.SetAvgPing(f) - return mpuo +func (_u *MatchPlayerUpdateOne) SetAvgPing(v float64) *MatchPlayerUpdateOne { + _u.mutation.ResetAvgPing() + _u.mutation.SetAvgPing(v) + return _u } // SetNillableAvgPing sets the "avg_ping" field if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableAvgPing(f *float64) *MatchPlayerUpdateOne { - if f != nil { - mpuo.SetAvgPing(*f) +func (_u *MatchPlayerUpdateOne) SetNillableAvgPing(v *float64) *MatchPlayerUpdateOne { + if v != nil { + _u.SetAvgPing(*v) } - return mpuo + return _u } -// AddAvgPing adds f to the "avg_ping" field. -func (mpuo *MatchPlayerUpdateOne) AddAvgPing(f float64) *MatchPlayerUpdateOne { - mpuo.mutation.AddAvgPing(f) - return mpuo +// AddAvgPing adds value to the "avg_ping" field. +func (_u *MatchPlayerUpdateOne) AddAvgPing(v float64) *MatchPlayerUpdateOne { + _u.mutation.AddAvgPing(v) + return _u } // ClearAvgPing clears the value of the "avg_ping" field. -func (mpuo *MatchPlayerUpdateOne) ClearAvgPing() *MatchPlayerUpdateOne { - mpuo.mutation.ClearAvgPing() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearAvgPing() *MatchPlayerUpdateOne { + _u.mutation.ClearAvgPing() + return _u } // SetMatchesID sets the "matches" edge to the Match entity by ID. -func (mpuo *MatchPlayerUpdateOne) SetMatchesID(id uint64) *MatchPlayerUpdateOne { - mpuo.mutation.SetMatchesID(id) - return mpuo +func (_u *MatchPlayerUpdateOne) SetMatchesID(id uint64) *MatchPlayerUpdateOne { + _u.mutation.SetMatchesID(id) + return _u } // SetNillableMatchesID sets the "matches" edge to the Match entity by ID if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillableMatchesID(id *uint64) *MatchPlayerUpdateOne { +func (_u *MatchPlayerUpdateOne) SetNillableMatchesID(id *uint64) *MatchPlayerUpdateOne { if id != nil { - mpuo = mpuo.SetMatchesID(*id) + _u = _u.SetMatchesID(*id) } - return mpuo + return _u } // SetMatches sets the "matches" edge to the Match entity. -func (mpuo *MatchPlayerUpdateOne) SetMatches(m *Match) *MatchPlayerUpdateOne { - return mpuo.SetMatchesID(m.ID) +func (_u *MatchPlayerUpdateOne) SetMatches(v *Match) *MatchPlayerUpdateOne { + return _u.SetMatchesID(v.ID) } // SetPlayersID sets the "players" edge to the Player entity by ID. -func (mpuo *MatchPlayerUpdateOne) SetPlayersID(id uint64) *MatchPlayerUpdateOne { - mpuo.mutation.SetPlayersID(id) - return mpuo +func (_u *MatchPlayerUpdateOne) SetPlayersID(id uint64) *MatchPlayerUpdateOne { + _u.mutation.SetPlayersID(id) + return _u } // SetNillablePlayersID sets the "players" edge to the Player entity by ID if the given value is not nil. -func (mpuo *MatchPlayerUpdateOne) SetNillablePlayersID(id *uint64) *MatchPlayerUpdateOne { +func (_u *MatchPlayerUpdateOne) SetNillablePlayersID(id *uint64) *MatchPlayerUpdateOne { if id != nil { - mpuo = mpuo.SetPlayersID(*id) + _u = _u.SetPlayersID(*id) } - return mpuo + return _u } // SetPlayers sets the "players" edge to the Player entity. -func (mpuo *MatchPlayerUpdateOne) SetPlayers(p *Player) *MatchPlayerUpdateOne { - return mpuo.SetPlayersID(p.ID) +func (_u *MatchPlayerUpdateOne) SetPlayers(v *Player) *MatchPlayerUpdateOne { + return _u.SetPlayersID(v.ID) } // AddWeaponStatIDs adds the "weapon_stats" edge to the Weapon entity by IDs. -func (mpuo *MatchPlayerUpdateOne) AddWeaponStatIDs(ids ...int) *MatchPlayerUpdateOne { - mpuo.mutation.AddWeaponStatIDs(ids...) - return mpuo +func (_u *MatchPlayerUpdateOne) AddWeaponStatIDs(ids ...int) *MatchPlayerUpdateOne { + _u.mutation.AddWeaponStatIDs(ids...) + return _u } // AddWeaponStats adds the "weapon_stats" edges to the Weapon entity. -func (mpuo *MatchPlayerUpdateOne) AddWeaponStats(w ...*Weapon) *MatchPlayerUpdateOne { - ids := make([]int, len(w)) - for i := range w { - ids[i] = w[i].ID +func (_u *MatchPlayerUpdateOne) AddWeaponStats(v ...*Weapon) *MatchPlayerUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mpuo.AddWeaponStatIDs(ids...) + return _u.AddWeaponStatIDs(ids...) } // AddRoundStatIDs adds the "round_stats" edge to the RoundStats entity by IDs. -func (mpuo *MatchPlayerUpdateOne) AddRoundStatIDs(ids ...int) *MatchPlayerUpdateOne { - mpuo.mutation.AddRoundStatIDs(ids...) - return mpuo +func (_u *MatchPlayerUpdateOne) AddRoundStatIDs(ids ...int) *MatchPlayerUpdateOne { + _u.mutation.AddRoundStatIDs(ids...) + return _u } // AddRoundStats adds the "round_stats" edges to the RoundStats entity. -func (mpuo *MatchPlayerUpdateOne) AddRoundStats(r ...*RoundStats) *MatchPlayerUpdateOne { - ids := make([]int, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *MatchPlayerUpdateOne) AddRoundStats(v ...*RoundStats) *MatchPlayerUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mpuo.AddRoundStatIDs(ids...) + return _u.AddRoundStatIDs(ids...) } // AddSprayIDs adds the "spray" edge to the Spray entity by IDs. -func (mpuo *MatchPlayerUpdateOne) AddSprayIDs(ids ...int) *MatchPlayerUpdateOne { - mpuo.mutation.AddSprayIDs(ids...) - return mpuo +func (_u *MatchPlayerUpdateOne) AddSprayIDs(ids ...int) *MatchPlayerUpdateOne { + _u.mutation.AddSprayIDs(ids...) + return _u } // AddSpray adds the "spray" edges to the Spray entity. -func (mpuo *MatchPlayerUpdateOne) AddSpray(s ...*Spray) *MatchPlayerUpdateOne { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID +func (_u *MatchPlayerUpdateOne) AddSpray(v ...*Spray) *MatchPlayerUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mpuo.AddSprayIDs(ids...) + return _u.AddSprayIDs(ids...) } // AddMessageIDs adds the "messages" edge to the Messages entity by IDs. -func (mpuo *MatchPlayerUpdateOne) AddMessageIDs(ids ...int) *MatchPlayerUpdateOne { - mpuo.mutation.AddMessageIDs(ids...) - return mpuo +func (_u *MatchPlayerUpdateOne) AddMessageIDs(ids ...int) *MatchPlayerUpdateOne { + _u.mutation.AddMessageIDs(ids...) + return _u } // AddMessages adds the "messages" edges to the Messages entity. -func (mpuo *MatchPlayerUpdateOne) AddMessages(m ...*Messages) *MatchPlayerUpdateOne { - ids := make([]int, len(m)) - for i := range m { - ids[i] = m[i].ID +func (_u *MatchPlayerUpdateOne) AddMessages(v ...*Messages) *MatchPlayerUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mpuo.AddMessageIDs(ids...) + return _u.AddMessageIDs(ids...) } // Mutation returns the MatchPlayerMutation object of the builder. -func (mpuo *MatchPlayerUpdateOne) Mutation() *MatchPlayerMutation { - return mpuo.mutation +func (_u *MatchPlayerUpdateOne) Mutation() *MatchPlayerMutation { + return _u.mutation } // ClearMatches clears the "matches" edge to the Match entity. -func (mpuo *MatchPlayerUpdateOne) ClearMatches() *MatchPlayerUpdateOne { - mpuo.mutation.ClearMatches() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearMatches() *MatchPlayerUpdateOne { + _u.mutation.ClearMatches() + return _u } // ClearPlayers clears the "players" edge to the Player entity. -func (mpuo *MatchPlayerUpdateOne) ClearPlayers() *MatchPlayerUpdateOne { - mpuo.mutation.ClearPlayers() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearPlayers() *MatchPlayerUpdateOne { + _u.mutation.ClearPlayers() + return _u } // ClearWeaponStats clears all "weapon_stats" edges to the Weapon entity. -func (mpuo *MatchPlayerUpdateOne) ClearWeaponStats() *MatchPlayerUpdateOne { - mpuo.mutation.ClearWeaponStats() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearWeaponStats() *MatchPlayerUpdateOne { + _u.mutation.ClearWeaponStats() + return _u } // RemoveWeaponStatIDs removes the "weapon_stats" edge to Weapon entities by IDs. -func (mpuo *MatchPlayerUpdateOne) RemoveWeaponStatIDs(ids ...int) *MatchPlayerUpdateOne { - mpuo.mutation.RemoveWeaponStatIDs(ids...) - return mpuo +func (_u *MatchPlayerUpdateOne) RemoveWeaponStatIDs(ids ...int) *MatchPlayerUpdateOne { + _u.mutation.RemoveWeaponStatIDs(ids...) + return _u } // RemoveWeaponStats removes "weapon_stats" edges to Weapon entities. -func (mpuo *MatchPlayerUpdateOne) RemoveWeaponStats(w ...*Weapon) *MatchPlayerUpdateOne { - ids := make([]int, len(w)) - for i := range w { - ids[i] = w[i].ID +func (_u *MatchPlayerUpdateOne) RemoveWeaponStats(v ...*Weapon) *MatchPlayerUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mpuo.RemoveWeaponStatIDs(ids...) + return _u.RemoveWeaponStatIDs(ids...) } // ClearRoundStats clears all "round_stats" edges to the RoundStats entity. -func (mpuo *MatchPlayerUpdateOne) ClearRoundStats() *MatchPlayerUpdateOne { - mpuo.mutation.ClearRoundStats() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearRoundStats() *MatchPlayerUpdateOne { + _u.mutation.ClearRoundStats() + return _u } // RemoveRoundStatIDs removes the "round_stats" edge to RoundStats entities by IDs. -func (mpuo *MatchPlayerUpdateOne) RemoveRoundStatIDs(ids ...int) *MatchPlayerUpdateOne { - mpuo.mutation.RemoveRoundStatIDs(ids...) - return mpuo +func (_u *MatchPlayerUpdateOne) RemoveRoundStatIDs(ids ...int) *MatchPlayerUpdateOne { + _u.mutation.RemoveRoundStatIDs(ids...) + return _u } // RemoveRoundStats removes "round_stats" edges to RoundStats entities. -func (mpuo *MatchPlayerUpdateOne) RemoveRoundStats(r ...*RoundStats) *MatchPlayerUpdateOne { - ids := make([]int, len(r)) - for i := range r { - ids[i] = r[i].ID +func (_u *MatchPlayerUpdateOne) RemoveRoundStats(v ...*RoundStats) *MatchPlayerUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mpuo.RemoveRoundStatIDs(ids...) + return _u.RemoveRoundStatIDs(ids...) } // ClearSpray clears all "spray" edges to the Spray entity. -func (mpuo *MatchPlayerUpdateOne) ClearSpray() *MatchPlayerUpdateOne { - mpuo.mutation.ClearSpray() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearSpray() *MatchPlayerUpdateOne { + _u.mutation.ClearSpray() + return _u } // RemoveSprayIDs removes the "spray" edge to Spray entities by IDs. -func (mpuo *MatchPlayerUpdateOne) RemoveSprayIDs(ids ...int) *MatchPlayerUpdateOne { - mpuo.mutation.RemoveSprayIDs(ids...) - return mpuo +func (_u *MatchPlayerUpdateOne) RemoveSprayIDs(ids ...int) *MatchPlayerUpdateOne { + _u.mutation.RemoveSprayIDs(ids...) + return _u } // RemoveSpray removes "spray" edges to Spray entities. -func (mpuo *MatchPlayerUpdateOne) RemoveSpray(s ...*Spray) *MatchPlayerUpdateOne { - ids := make([]int, len(s)) - for i := range s { - ids[i] = s[i].ID +func (_u *MatchPlayerUpdateOne) RemoveSpray(v ...*Spray) *MatchPlayerUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mpuo.RemoveSprayIDs(ids...) + return _u.RemoveSprayIDs(ids...) } // ClearMessages clears all "messages" edges to the Messages entity. -func (mpuo *MatchPlayerUpdateOne) ClearMessages() *MatchPlayerUpdateOne { - mpuo.mutation.ClearMessages() - return mpuo +func (_u *MatchPlayerUpdateOne) ClearMessages() *MatchPlayerUpdateOne { + _u.mutation.ClearMessages() + return _u } // RemoveMessageIDs removes the "messages" edge to Messages entities by IDs. -func (mpuo *MatchPlayerUpdateOne) RemoveMessageIDs(ids ...int) *MatchPlayerUpdateOne { - mpuo.mutation.RemoveMessageIDs(ids...) - return mpuo +func (_u *MatchPlayerUpdateOne) RemoveMessageIDs(ids ...int) *MatchPlayerUpdateOne { + _u.mutation.RemoveMessageIDs(ids...) + return _u } // RemoveMessages removes "messages" edges to Messages entities. -func (mpuo *MatchPlayerUpdateOne) RemoveMessages(m ...*Messages) *MatchPlayerUpdateOne { - ids := make([]int, len(m)) - for i := range m { - ids[i] = m[i].ID +func (_u *MatchPlayerUpdateOne) RemoveMessages(v ...*Messages) *MatchPlayerUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return mpuo.RemoveMessageIDs(ids...) + return _u.RemoveMessageIDs(ids...) } // Where appends a list predicates to the MatchPlayerUpdate builder. -func (mpuo *MatchPlayerUpdateOne) Where(ps ...predicate.MatchPlayer) *MatchPlayerUpdateOne { - mpuo.mutation.Where(ps...) - return mpuo +func (_u *MatchPlayerUpdateOne) Where(ps ...predicate.MatchPlayer) *MatchPlayerUpdateOne { + _u.mutation.Where(ps...) + return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. -func (mpuo *MatchPlayerUpdateOne) Select(field string, fields ...string) *MatchPlayerUpdateOne { - mpuo.fields = append([]string{field}, fields...) - return mpuo +func (_u *MatchPlayerUpdateOne) Select(field string, fields ...string) *MatchPlayerUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u } // Save executes the query and returns the updated MatchPlayer entity. -func (mpuo *MatchPlayerUpdateOne) Save(ctx context.Context) (*MatchPlayer, error) { - return withHooks(ctx, mpuo.sqlSave, mpuo.mutation, mpuo.hooks) +func (_u *MatchPlayerUpdateOne) Save(ctx context.Context) (*MatchPlayer, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (mpuo *MatchPlayerUpdateOne) SaveX(ctx context.Context) *MatchPlayer { - node, err := mpuo.Save(ctx) +func (_u *MatchPlayerUpdateOne) SaveX(ctx context.Context) *MatchPlayer { + node, err := _u.Save(ctx) if err != nil { panic(err) } @@ -2557,21 +2669,21 @@ func (mpuo *MatchPlayerUpdateOne) SaveX(ctx context.Context) *MatchPlayer { } // Exec executes the query on the entity. -func (mpuo *MatchPlayerUpdateOne) Exec(ctx context.Context) error { - _, err := mpuo.Save(ctx) +func (_u *MatchPlayerUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (mpuo *MatchPlayerUpdateOne) ExecX(ctx context.Context) { - if err := mpuo.Exec(ctx); err != nil { +func (_u *MatchPlayerUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (mpuo *MatchPlayerUpdateOne) check() error { - if v, ok := mpuo.mutation.Color(); ok { +func (_u *MatchPlayerUpdateOne) check() error { + if v, ok := _u.mutation.Color(); ok { if err := matchplayer.ColorValidator(v); err != nil { return &ValidationError{Name: "color", err: fmt.Errorf(`ent: validator failed for field "MatchPlayer.color": %w`, err)} } @@ -2580,22 +2692,22 @@ func (mpuo *MatchPlayerUpdateOne) check() error { } // 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 (_u *MatchPlayerUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MatchPlayerUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlayer, err error) { - if err := mpuo.check(); err != nil { +func (_u *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlayer, err error) { + if err := _u.check(); err != nil { return _node, err } _spec := sqlgraph.NewUpdateSpec(matchplayer.Table, matchplayer.Columns, sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt)) - id, ok := mpuo.mutation.ID() + id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "MatchPlayer.id" for update`)} } _spec.Node.ID.Value = id - if fields := mpuo.fields; len(fields) > 0 { + if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, matchplayer.FieldID) for _, f := range fields { @@ -2607,266 +2719,266 @@ func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlay } } } - if ps := mpuo.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := mpuo.mutation.TeamID(); ok { + if value, ok := _u.mutation.TeamID(); ok { _spec.SetField(matchplayer.FieldTeamID, field.TypeInt, value) } - if value, ok := mpuo.mutation.AddedTeamID(); ok { + if value, ok := _u.mutation.AddedTeamID(); ok { _spec.AddField(matchplayer.FieldTeamID, field.TypeInt, value) } - if value, ok := mpuo.mutation.Kills(); ok { + if value, ok := _u.mutation.Kills(); ok { _spec.SetField(matchplayer.FieldKills, field.TypeInt, value) } - if value, ok := mpuo.mutation.AddedKills(); ok { + if value, ok := _u.mutation.AddedKills(); ok { _spec.AddField(matchplayer.FieldKills, field.TypeInt, value) } - if value, ok := mpuo.mutation.Deaths(); ok { + if value, ok := _u.mutation.Deaths(); ok { _spec.SetField(matchplayer.FieldDeaths, field.TypeInt, value) } - if value, ok := mpuo.mutation.AddedDeaths(); ok { + if value, ok := _u.mutation.AddedDeaths(); ok { _spec.AddField(matchplayer.FieldDeaths, field.TypeInt, value) } - if value, ok := mpuo.mutation.Assists(); ok { + if value, ok := _u.mutation.Assists(); ok { _spec.SetField(matchplayer.FieldAssists, field.TypeInt, value) } - if value, ok := mpuo.mutation.AddedAssists(); ok { + if value, ok := _u.mutation.AddedAssists(); ok { _spec.AddField(matchplayer.FieldAssists, field.TypeInt, value) } - if value, ok := mpuo.mutation.Headshot(); ok { + if value, ok := _u.mutation.Headshot(); ok { _spec.SetField(matchplayer.FieldHeadshot, field.TypeInt, value) } - if value, ok := mpuo.mutation.AddedHeadshot(); ok { + if value, ok := _u.mutation.AddedHeadshot(); ok { _spec.AddField(matchplayer.FieldHeadshot, field.TypeInt, value) } - if value, ok := mpuo.mutation.Mvp(); ok { + if value, ok := _u.mutation.Mvp(); ok { _spec.SetField(matchplayer.FieldMvp, field.TypeUint, value) } - if value, ok := mpuo.mutation.AddedMvp(); ok { + if value, ok := _u.mutation.AddedMvp(); ok { _spec.AddField(matchplayer.FieldMvp, field.TypeUint, value) } - if value, ok := mpuo.mutation.Score(); ok { + if value, ok := _u.mutation.Score(); ok { _spec.SetField(matchplayer.FieldScore, field.TypeInt, value) } - if value, ok := mpuo.mutation.AddedScore(); ok { + if value, ok := _u.mutation.AddedScore(); ok { _spec.AddField(matchplayer.FieldScore, field.TypeInt, value) } - if value, ok := mpuo.mutation.RankNew(); ok { + if value, ok := _u.mutation.RankNew(); ok { _spec.SetField(matchplayer.FieldRankNew, field.TypeInt, value) } - if value, ok := mpuo.mutation.AddedRankNew(); ok { + if value, ok := _u.mutation.AddedRankNew(); ok { _spec.AddField(matchplayer.FieldRankNew, field.TypeInt, value) } - if mpuo.mutation.RankNewCleared() { + if _u.mutation.RankNewCleared() { _spec.ClearField(matchplayer.FieldRankNew, field.TypeInt) } - if value, ok := mpuo.mutation.RankOld(); ok { + if value, ok := _u.mutation.RankOld(); ok { _spec.SetField(matchplayer.FieldRankOld, field.TypeInt, value) } - if value, ok := mpuo.mutation.AddedRankOld(); ok { + if value, ok := _u.mutation.AddedRankOld(); ok { _spec.AddField(matchplayer.FieldRankOld, field.TypeInt, value) } - if mpuo.mutation.RankOldCleared() { + if _u.mutation.RankOldCleared() { _spec.ClearField(matchplayer.FieldRankOld, field.TypeInt) } - if value, ok := mpuo.mutation.Mk2(); ok { + if value, ok := _u.mutation.Mk2(); ok { _spec.SetField(matchplayer.FieldMk2, field.TypeUint, value) } - if value, ok := mpuo.mutation.AddedMk2(); ok { + if value, ok := _u.mutation.AddedMk2(); ok { _spec.AddField(matchplayer.FieldMk2, field.TypeUint, value) } - if mpuo.mutation.Mk2Cleared() { + if _u.mutation.Mk2Cleared() { _spec.ClearField(matchplayer.FieldMk2, field.TypeUint) } - if value, ok := mpuo.mutation.Mk3(); ok { + if value, ok := _u.mutation.Mk3(); ok { _spec.SetField(matchplayer.FieldMk3, field.TypeUint, value) } - if value, ok := mpuo.mutation.AddedMk3(); ok { + if value, ok := _u.mutation.AddedMk3(); ok { _spec.AddField(matchplayer.FieldMk3, field.TypeUint, value) } - if mpuo.mutation.Mk3Cleared() { + if _u.mutation.Mk3Cleared() { _spec.ClearField(matchplayer.FieldMk3, field.TypeUint) } - if value, ok := mpuo.mutation.Mk4(); ok { + if value, ok := _u.mutation.Mk4(); ok { _spec.SetField(matchplayer.FieldMk4, field.TypeUint, value) } - if value, ok := mpuo.mutation.AddedMk4(); ok { + if value, ok := _u.mutation.AddedMk4(); ok { _spec.AddField(matchplayer.FieldMk4, field.TypeUint, value) } - if mpuo.mutation.Mk4Cleared() { + if _u.mutation.Mk4Cleared() { _spec.ClearField(matchplayer.FieldMk4, field.TypeUint) } - if value, ok := mpuo.mutation.Mk5(); ok { + if value, ok := _u.mutation.Mk5(); ok { _spec.SetField(matchplayer.FieldMk5, field.TypeUint, value) } - if value, ok := mpuo.mutation.AddedMk5(); ok { + if value, ok := _u.mutation.AddedMk5(); ok { _spec.AddField(matchplayer.FieldMk5, field.TypeUint, value) } - if mpuo.mutation.Mk5Cleared() { + if _u.mutation.Mk5Cleared() { _spec.ClearField(matchplayer.FieldMk5, field.TypeUint) } - if value, ok := mpuo.mutation.DmgEnemy(); ok { + if value, ok := _u.mutation.DmgEnemy(); ok { _spec.SetField(matchplayer.FieldDmgEnemy, field.TypeUint, value) } - if value, ok := mpuo.mutation.AddedDmgEnemy(); ok { + if value, ok := _u.mutation.AddedDmgEnemy(); ok { _spec.AddField(matchplayer.FieldDmgEnemy, field.TypeUint, value) } - if mpuo.mutation.DmgEnemyCleared() { + if _u.mutation.DmgEnemyCleared() { _spec.ClearField(matchplayer.FieldDmgEnemy, field.TypeUint) } - if value, ok := mpuo.mutation.DmgTeam(); ok { + if value, ok := _u.mutation.DmgTeam(); ok { _spec.SetField(matchplayer.FieldDmgTeam, field.TypeUint, value) } - if value, ok := mpuo.mutation.AddedDmgTeam(); ok { + if value, ok := _u.mutation.AddedDmgTeam(); ok { _spec.AddField(matchplayer.FieldDmgTeam, field.TypeUint, value) } - if mpuo.mutation.DmgTeamCleared() { + if _u.mutation.DmgTeamCleared() { _spec.ClearField(matchplayer.FieldDmgTeam, field.TypeUint) } - if value, ok := mpuo.mutation.UdHe(); ok { + if value, ok := _u.mutation.UdHe(); ok { _spec.SetField(matchplayer.FieldUdHe, field.TypeUint, value) } - if value, ok := mpuo.mutation.AddedUdHe(); ok { + if value, ok := _u.mutation.AddedUdHe(); ok { _spec.AddField(matchplayer.FieldUdHe, field.TypeUint, value) } - if mpuo.mutation.UdHeCleared() { + if _u.mutation.UdHeCleared() { _spec.ClearField(matchplayer.FieldUdHe, field.TypeUint) } - if value, ok := mpuo.mutation.UdFlames(); ok { + if value, ok := _u.mutation.UdFlames(); ok { _spec.SetField(matchplayer.FieldUdFlames, field.TypeUint, value) } - if value, ok := mpuo.mutation.AddedUdFlames(); ok { + if value, ok := _u.mutation.AddedUdFlames(); ok { _spec.AddField(matchplayer.FieldUdFlames, field.TypeUint, value) } - if mpuo.mutation.UdFlamesCleared() { + if _u.mutation.UdFlamesCleared() { _spec.ClearField(matchplayer.FieldUdFlames, field.TypeUint) } - if value, ok := mpuo.mutation.UdFlash(); ok { + if value, ok := _u.mutation.UdFlash(); ok { _spec.SetField(matchplayer.FieldUdFlash, field.TypeUint, value) } - if value, ok := mpuo.mutation.AddedUdFlash(); ok { + if value, ok := _u.mutation.AddedUdFlash(); ok { _spec.AddField(matchplayer.FieldUdFlash, field.TypeUint, value) } - if mpuo.mutation.UdFlashCleared() { + if _u.mutation.UdFlashCleared() { _spec.ClearField(matchplayer.FieldUdFlash, field.TypeUint) } - if value, ok := mpuo.mutation.UdDecoy(); ok { + if value, ok := _u.mutation.UdDecoy(); ok { _spec.SetField(matchplayer.FieldUdDecoy, field.TypeUint, value) } - if value, ok := mpuo.mutation.AddedUdDecoy(); ok { + if value, ok := _u.mutation.AddedUdDecoy(); ok { _spec.AddField(matchplayer.FieldUdDecoy, field.TypeUint, value) } - if mpuo.mutation.UdDecoyCleared() { + if _u.mutation.UdDecoyCleared() { _spec.ClearField(matchplayer.FieldUdDecoy, field.TypeUint) } - if value, ok := mpuo.mutation.UdSmoke(); ok { + if value, ok := _u.mutation.UdSmoke(); ok { _spec.SetField(matchplayer.FieldUdSmoke, field.TypeUint, value) } - if value, ok := mpuo.mutation.AddedUdSmoke(); ok { + if value, ok := _u.mutation.AddedUdSmoke(); ok { _spec.AddField(matchplayer.FieldUdSmoke, field.TypeUint, value) } - if mpuo.mutation.UdSmokeCleared() { + if _u.mutation.UdSmokeCleared() { _spec.ClearField(matchplayer.FieldUdSmoke, field.TypeUint) } - if value, ok := mpuo.mutation.Crosshair(); ok { + if value, ok := _u.mutation.Crosshair(); ok { _spec.SetField(matchplayer.FieldCrosshair, field.TypeString, value) } - if mpuo.mutation.CrosshairCleared() { + if _u.mutation.CrosshairCleared() { _spec.ClearField(matchplayer.FieldCrosshair, field.TypeString) } - if value, ok := mpuo.mutation.Color(); ok { + if value, ok := _u.mutation.Color(); ok { _spec.SetField(matchplayer.FieldColor, field.TypeEnum, value) } - if mpuo.mutation.ColorCleared() { + if _u.mutation.ColorCleared() { _spec.ClearField(matchplayer.FieldColor, field.TypeEnum) } - if value, ok := mpuo.mutation.Kast(); ok { + if value, ok := _u.mutation.Kast(); ok { _spec.SetField(matchplayer.FieldKast, field.TypeInt, value) } - if value, ok := mpuo.mutation.AddedKast(); ok { + if value, ok := _u.mutation.AddedKast(); ok { _spec.AddField(matchplayer.FieldKast, field.TypeInt, value) } - if mpuo.mutation.KastCleared() { + if _u.mutation.KastCleared() { _spec.ClearField(matchplayer.FieldKast, field.TypeInt) } - if value, ok := mpuo.mutation.FlashDurationSelf(); ok { + if value, ok := _u.mutation.FlashDurationSelf(); ok { _spec.SetField(matchplayer.FieldFlashDurationSelf, field.TypeFloat32, value) } - if value, ok := mpuo.mutation.AddedFlashDurationSelf(); ok { + if value, ok := _u.mutation.AddedFlashDurationSelf(); ok { _spec.AddField(matchplayer.FieldFlashDurationSelf, field.TypeFloat32, value) } - if mpuo.mutation.FlashDurationSelfCleared() { + if _u.mutation.FlashDurationSelfCleared() { _spec.ClearField(matchplayer.FieldFlashDurationSelf, field.TypeFloat32) } - if value, ok := mpuo.mutation.FlashDurationTeam(); ok { + if value, ok := _u.mutation.FlashDurationTeam(); ok { _spec.SetField(matchplayer.FieldFlashDurationTeam, field.TypeFloat32, value) } - if value, ok := mpuo.mutation.AddedFlashDurationTeam(); ok { + if value, ok := _u.mutation.AddedFlashDurationTeam(); ok { _spec.AddField(matchplayer.FieldFlashDurationTeam, field.TypeFloat32, value) } - if mpuo.mutation.FlashDurationTeamCleared() { + if _u.mutation.FlashDurationTeamCleared() { _spec.ClearField(matchplayer.FieldFlashDurationTeam, field.TypeFloat32) } - if value, ok := mpuo.mutation.FlashDurationEnemy(); ok { + if value, ok := _u.mutation.FlashDurationEnemy(); ok { _spec.SetField(matchplayer.FieldFlashDurationEnemy, field.TypeFloat32, value) } - if value, ok := mpuo.mutation.AddedFlashDurationEnemy(); ok { + if value, ok := _u.mutation.AddedFlashDurationEnemy(); ok { _spec.AddField(matchplayer.FieldFlashDurationEnemy, field.TypeFloat32, value) } - if mpuo.mutation.FlashDurationEnemyCleared() { + if _u.mutation.FlashDurationEnemyCleared() { _spec.ClearField(matchplayer.FieldFlashDurationEnemy, field.TypeFloat32) } - if value, ok := mpuo.mutation.FlashTotalSelf(); ok { + if value, ok := _u.mutation.FlashTotalSelf(); ok { _spec.SetField(matchplayer.FieldFlashTotalSelf, field.TypeUint, value) } - if value, ok := mpuo.mutation.AddedFlashTotalSelf(); ok { + if value, ok := _u.mutation.AddedFlashTotalSelf(); ok { _spec.AddField(matchplayer.FieldFlashTotalSelf, field.TypeUint, value) } - if mpuo.mutation.FlashTotalSelfCleared() { + if _u.mutation.FlashTotalSelfCleared() { _spec.ClearField(matchplayer.FieldFlashTotalSelf, field.TypeUint) } - if value, ok := mpuo.mutation.FlashTotalTeam(); ok { + if value, ok := _u.mutation.FlashTotalTeam(); ok { _spec.SetField(matchplayer.FieldFlashTotalTeam, field.TypeUint, value) } - if value, ok := mpuo.mutation.AddedFlashTotalTeam(); ok { + if value, ok := _u.mutation.AddedFlashTotalTeam(); ok { _spec.AddField(matchplayer.FieldFlashTotalTeam, field.TypeUint, value) } - if mpuo.mutation.FlashTotalTeamCleared() { + if _u.mutation.FlashTotalTeamCleared() { _spec.ClearField(matchplayer.FieldFlashTotalTeam, field.TypeUint) } - if value, ok := mpuo.mutation.FlashTotalEnemy(); ok { + if value, ok := _u.mutation.FlashTotalEnemy(); ok { _spec.SetField(matchplayer.FieldFlashTotalEnemy, field.TypeUint, value) } - if value, ok := mpuo.mutation.AddedFlashTotalEnemy(); ok { + if value, ok := _u.mutation.AddedFlashTotalEnemy(); ok { _spec.AddField(matchplayer.FieldFlashTotalEnemy, field.TypeUint, value) } - if mpuo.mutation.FlashTotalEnemyCleared() { + if _u.mutation.FlashTotalEnemyCleared() { _spec.ClearField(matchplayer.FieldFlashTotalEnemy, field.TypeUint) } - if value, ok := mpuo.mutation.FlashAssists(); ok { + if value, ok := _u.mutation.FlashAssists(); ok { _spec.SetField(matchplayer.FieldFlashAssists, field.TypeInt, value) } - if value, ok := mpuo.mutation.AddedFlashAssists(); ok { + if value, ok := _u.mutation.AddedFlashAssists(); ok { _spec.AddField(matchplayer.FieldFlashAssists, field.TypeInt, value) } - if mpuo.mutation.FlashAssistsCleared() { + if _u.mutation.FlashAssistsCleared() { _spec.ClearField(matchplayer.FieldFlashAssists, field.TypeInt) } - if value, ok := mpuo.mutation.AvgPing(); ok { + if value, ok := _u.mutation.AvgPing(); ok { _spec.SetField(matchplayer.FieldAvgPing, field.TypeFloat64, value) } - if value, ok := mpuo.mutation.AddedAvgPing(); ok { + if value, ok := _u.mutation.AddedAvgPing(); ok { _spec.AddField(matchplayer.FieldAvgPing, field.TypeFloat64, value) } - if mpuo.mutation.AvgPingCleared() { + if _u.mutation.AvgPingCleared() { _spec.ClearField(matchplayer.FieldAvgPing, field.TypeFloat64) } - if mpuo.mutation.MatchesCleared() { + if _u.mutation.MatchesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -2879,7 +2991,7 @@ func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlay } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mpuo.mutation.MatchesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.MatchesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -2895,7 +3007,7 @@ func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlay } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if mpuo.mutation.PlayersCleared() { + if _u.mutation.PlayersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -2908,7 +3020,7 @@ func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlay } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mpuo.mutation.PlayersIDs(); len(nodes) > 0 { + if nodes := _u.mutation.PlayersIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -2924,7 +3036,7 @@ func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlay } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if mpuo.mutation.WeaponStatsCleared() { + if _u.mutation.WeaponStatsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -2937,7 +3049,7 @@ func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlay } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mpuo.mutation.RemovedWeaponStatsIDs(); len(nodes) > 0 && !mpuo.mutation.WeaponStatsCleared() { + if nodes := _u.mutation.RemovedWeaponStatsIDs(); len(nodes) > 0 && !_u.mutation.WeaponStatsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -2953,7 +3065,7 @@ func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlay } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mpuo.mutation.WeaponStatsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.WeaponStatsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -2969,7 +3081,7 @@ func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlay } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if mpuo.mutation.RoundStatsCleared() { + if _u.mutation.RoundStatsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -2982,7 +3094,7 @@ func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlay } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mpuo.mutation.RemovedRoundStatsIDs(); len(nodes) > 0 && !mpuo.mutation.RoundStatsCleared() { + if nodes := _u.mutation.RemovedRoundStatsIDs(); len(nodes) > 0 && !_u.mutation.RoundStatsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -2998,7 +3110,7 @@ func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlay } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mpuo.mutation.RoundStatsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.RoundStatsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -3014,7 +3126,7 @@ func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlay } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if mpuo.mutation.SprayCleared() { + if _u.mutation.SprayCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -3027,7 +3139,7 @@ func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlay } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mpuo.mutation.RemovedSprayIDs(); len(nodes) > 0 && !mpuo.mutation.SprayCleared() { + if nodes := _u.mutation.RemovedSprayIDs(); len(nodes) > 0 && !_u.mutation.SprayCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -3043,7 +3155,7 @@ func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlay } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mpuo.mutation.SprayIDs(); len(nodes) > 0 { + if nodes := _u.mutation.SprayIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -3059,7 +3171,7 @@ func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlay } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if mpuo.mutation.MessagesCleared() { + if _u.mutation.MessagesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -3072,7 +3184,7 @@ func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlay } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mpuo.mutation.RemovedMessagesIDs(); len(nodes) > 0 && !mpuo.mutation.MessagesCleared() { + if nodes := _u.mutation.RemovedMessagesIDs(); len(nodes) > 0 && !_u.mutation.MessagesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -3088,7 +3200,7 @@ func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlay } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mpuo.mutation.MessagesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.MessagesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -3104,11 +3216,11 @@ func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlay } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(mpuo.modifiers...) - _node = &MatchPlayer{config: mpuo.config} + _spec.AddModifiers(_u.modifiers...) + _node = &MatchPlayer{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, mpuo.driver, _spec); err != nil { + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{matchplayer.Label} } else if sqlgraph.IsConstraintError(err) { @@ -3116,6 +3228,6 @@ func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlay } return nil, err } - mpuo.mutation.done = true + _u.mutation.done = true return _node, nil } diff --git a/ent/messages.go b/ent/messages.go index bb3c1e7..b3d2ffc 100644 --- a/ent/messages.go +++ b/ent/messages.go @@ -42,12 +42,10 @@ type MessagesEdges struct { // MatchPlayerOrErr returns the MatchPlayer value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e MessagesEdges) MatchPlayerOrErr() (*MatchPlayer, error) { - if e.loadedTypes[0] { - if e.MatchPlayer == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: matchplayer.Label} - } + if e.MatchPlayer != nil { return e.MatchPlayer, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: matchplayer.Label} } return nil, &NotLoadedError{edge: "match_player"} } @@ -74,7 +72,7 @@ func (*Messages) scanValues(columns []string) ([]any, error) { // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the Messages fields. -func (m *Messages) assignValues(columns []string, values []any) error { +func (_m *Messages) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } @@ -85,34 +83,34 @@ func (m *Messages) assignValues(columns []string, values []any) error { if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - m.ID = int(value.Int64) + _m.ID = int(value.Int64) case messages.FieldMessage: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field message", values[i]) } else if value.Valid { - m.Message = value.String + _m.Message = value.String } case messages.FieldAllChat: if value, ok := values[i].(*sql.NullBool); !ok { return fmt.Errorf("unexpected type %T for field all_chat", values[i]) } else if value.Valid { - m.AllChat = value.Bool + _m.AllChat = value.Bool } case messages.FieldTick: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field tick", values[i]) } else if value.Valid { - m.Tick = int(value.Int64) + _m.Tick = int(value.Int64) } case messages.ForeignKeys[0]: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for edge-field match_player_messages", value) } else if value.Valid { - m.match_player_messages = new(int) - *m.match_player_messages = int(value.Int64) + _m.match_player_messages = new(int) + *_m.match_player_messages = int(value.Int64) } default: - m.selectValues.Set(columns[i], values[i]) + _m.selectValues.Set(columns[i], values[i]) } } return nil @@ -120,46 +118,46 @@ func (m *Messages) assignValues(columns []string, values []any) error { // Value returns the ent.Value that was dynamically selected and assigned to the Messages. // This includes values selected through modifiers, order, etc. -func (m *Messages) Value(name string) (ent.Value, error) { - return m.selectValues.Get(name) +func (_m *Messages) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) } // QueryMatchPlayer queries the "match_player" edge of the Messages entity. -func (m *Messages) QueryMatchPlayer() *MatchPlayerQuery { - return NewMessagesClient(m.config).QueryMatchPlayer(m) +func (_m *Messages) QueryMatchPlayer() *MatchPlayerQuery { + return NewMessagesClient(_m.config).QueryMatchPlayer(_m) } // Update returns a builder for updating this Messages. // Note that you need to call Messages.Unwrap() before calling this method if this Messages // was returned from a transaction, and the transaction was committed or rolled back. -func (m *Messages) Update() *MessagesUpdateOne { - return NewMessagesClient(m.config).UpdateOne(m) +func (_m *Messages) Update() *MessagesUpdateOne { + return NewMessagesClient(_m.config).UpdateOne(_m) } // 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) +func (_m *Messages) Unwrap() *Messages { + _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: Messages is not a transactional entity") } - m.config.driver = _tx.drv - return m + _m.config.driver = _tx.drv + return _m } // String implements the fmt.Stringer. -func (m *Messages) String() string { +func (_m *Messages) String() string { var builder strings.Builder builder.WriteString("Messages(") - builder.WriteString(fmt.Sprintf("id=%v, ", m.ID)) + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("message=") - builder.WriteString(m.Message) + builder.WriteString(_m.Message) builder.WriteString(", ") builder.WriteString("all_chat=") - builder.WriteString(fmt.Sprintf("%v", m.AllChat)) + builder.WriteString(fmt.Sprintf("%v", _m.AllChat)) builder.WriteString(", ") builder.WriteString("tick=") - builder.WriteString(fmt.Sprintf("%v", m.Tick)) + builder.WriteString(fmt.Sprintf("%v", _m.Tick)) builder.WriteByte(')') return builder.String() } diff --git a/ent/messages/where.go b/ent/messages/where.go index 4983c3f..38013a5 100644 --- a/ent/messages/where.go +++ b/ent/messages/where.go @@ -208,32 +208,15 @@ func HasMatchPlayerWith(preds ...predicate.MatchPlayer) predicate.Messages { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Messages) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Messages(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Messages) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Messages(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Messages) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Messages(sql.NotPredicates(p)) } diff --git a/ent/messages_create.go b/ent/messages_create.go index 1b3e9d5..a0b3d34 100644 --- a/ent/messages_create.go +++ b/ent/messages_create.go @@ -21,55 +21,55 @@ type MessagesCreate struct { } // SetMessage sets the "message" field. -func (mc *MessagesCreate) SetMessage(s string) *MessagesCreate { - mc.mutation.SetMessage(s) - return mc +func (_c *MessagesCreate) SetMessage(v string) *MessagesCreate { + _c.mutation.SetMessage(v) + return _c } // SetAllChat sets the "all_chat" field. -func (mc *MessagesCreate) SetAllChat(b bool) *MessagesCreate { - mc.mutation.SetAllChat(b) - return mc +func (_c *MessagesCreate) SetAllChat(v bool) *MessagesCreate { + _c.mutation.SetAllChat(v) + return _c } // SetTick sets the "tick" field. -func (mc *MessagesCreate) SetTick(i int) *MessagesCreate { - mc.mutation.SetTick(i) - return mc +func (_c *MessagesCreate) SetTick(v int) *MessagesCreate { + _c.mutation.SetTick(v) + return _c } // SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID. -func (mc *MessagesCreate) SetMatchPlayerID(id int) *MessagesCreate { - mc.mutation.SetMatchPlayerID(id) - return mc +func (_c *MessagesCreate) SetMatchPlayerID(id int) *MessagesCreate { + _c.mutation.SetMatchPlayerID(id) + return _c } // SetNillableMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID if the given value is not nil. -func (mc *MessagesCreate) SetNillableMatchPlayerID(id *int) *MessagesCreate { +func (_c *MessagesCreate) SetNillableMatchPlayerID(id *int) *MessagesCreate { if id != nil { - mc = mc.SetMatchPlayerID(*id) + _c = _c.SetMatchPlayerID(*id) } - return mc + return _c } // SetMatchPlayer sets the "match_player" edge to the MatchPlayer entity. -func (mc *MessagesCreate) SetMatchPlayer(m *MatchPlayer) *MessagesCreate { - return mc.SetMatchPlayerID(m.ID) +func (_c *MessagesCreate) SetMatchPlayer(v *MatchPlayer) *MessagesCreate { + return _c.SetMatchPlayerID(v.ID) } // Mutation returns the MessagesMutation object of the builder. -func (mc *MessagesCreate) Mutation() *MessagesMutation { - return mc.mutation +func (_c *MessagesCreate) Mutation() *MessagesMutation { + return _c.mutation } // Save creates the Messages in the database. -func (mc *MessagesCreate) Save(ctx context.Context) (*Messages, error) { - return withHooks(ctx, mc.sqlSave, mc.mutation, mc.hooks) +func (_c *MessagesCreate) Save(ctx context.Context) (*Messages, error) { + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. -func (mc *MessagesCreate) SaveX(ctx context.Context) *Messages { - v, err := mc.Save(ctx) +func (_c *MessagesCreate) SaveX(ctx context.Context) *Messages { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -77,38 +77,38 @@ func (mc *MessagesCreate) SaveX(ctx context.Context) *Messages { } // Exec executes the query. -func (mc *MessagesCreate) Exec(ctx context.Context) error { - _, err := mc.Save(ctx) +func (_c *MessagesCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (mc *MessagesCreate) ExecX(ctx context.Context) { - if err := mc.Exec(ctx); err != nil { +func (_c *MessagesCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (mc *MessagesCreate) check() error { - if _, ok := mc.mutation.Message(); !ok { +func (_c *MessagesCreate) check() error { + if _, ok := _c.mutation.Message(); !ok { return &ValidationError{Name: "message", err: errors.New(`ent: missing required field "Messages.message"`)} } - if _, ok := mc.mutation.AllChat(); !ok { + if _, ok := _c.mutation.AllChat(); !ok { return &ValidationError{Name: "all_chat", err: errors.New(`ent: missing required field "Messages.all_chat"`)} } - if _, ok := mc.mutation.Tick(); !ok { + if _, ok := _c.mutation.Tick(); !ok { return &ValidationError{Name: "tick", err: errors.New(`ent: missing required field "Messages.tick"`)} } return nil } -func (mc *MessagesCreate) sqlSave(ctx context.Context) (*Messages, error) { - if err := mc.check(); err != nil { +func (_c *MessagesCreate) sqlSave(ctx context.Context) (*Messages, error) { + if err := _c.check(); err != nil { return nil, err } - _node, _spec := mc.createSpec() - if err := sqlgraph.CreateNode(ctx, mc.driver, _spec); err != nil { + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -116,29 +116,29 @@ func (mc *MessagesCreate) sqlSave(ctx context.Context) (*Messages, error) { } id := _spec.ID.Value.(int64) _node.ID = int(id) - mc.mutation.id = &_node.ID - mc.mutation.done = true + _c.mutation.id = &_node.ID + _c.mutation.done = true return _node, nil } -func (mc *MessagesCreate) createSpec() (*Messages, *sqlgraph.CreateSpec) { +func (_c *MessagesCreate) createSpec() (*Messages, *sqlgraph.CreateSpec) { var ( - _node = &Messages{config: mc.config} + _node = &Messages{config: _c.config} _spec = sqlgraph.NewCreateSpec(messages.Table, sqlgraph.NewFieldSpec(messages.FieldID, field.TypeInt)) ) - if value, ok := mc.mutation.Message(); ok { + if value, ok := _c.mutation.Message(); ok { _spec.SetField(messages.FieldMessage, field.TypeString, value) _node.Message = value } - if value, ok := mc.mutation.AllChat(); ok { + if value, ok := _c.mutation.AllChat(); ok { _spec.SetField(messages.FieldAllChat, field.TypeBool, value) _node.AllChat = value } - if value, ok := mc.mutation.Tick(); ok { + if value, ok := _c.mutation.Tick(); ok { _spec.SetField(messages.FieldTick, field.TypeInt, value) _node.Tick = value } - if nodes := mc.mutation.MatchPlayerIDs(); len(nodes) > 0 { + if nodes := _c.mutation.MatchPlayerIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -161,17 +161,21 @@ func (mc *MessagesCreate) createSpec() (*Messages, *sqlgraph.CreateSpec) { // MessagesCreateBulk is the builder for creating many Messages entities in bulk. type MessagesCreateBulk struct { config + err error builders []*MessagesCreate } // Save creates the Messages entities in the database. -func (mcb *MessagesCreateBulk) Save(ctx context.Context) ([]*Messages, error) { - specs := make([]*sqlgraph.CreateSpec, len(mcb.builders)) - nodes := make([]*Messages, len(mcb.builders)) - mutators := make([]Mutator, len(mcb.builders)) - for i := range mcb.builders { +func (_c *MessagesCreateBulk) Save(ctx context.Context) ([]*Messages, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*Messages, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { func(i int, root context.Context) { - builder := mcb.builders[i] + builder := _c.builders[i] var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*MessagesMutation) if !ok { @@ -184,11 +188,11 @@ func (mcb *MessagesCreateBulk) Save(ctx context.Context) ([]*Messages, error) { var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, mcb.builders[i+1].mutation) + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, mcb.driver, spec); err != nil { + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -212,7 +216,7 @@ func (mcb *MessagesCreateBulk) Save(ctx context.Context) ([]*Messages, error) { }(i, ctx) } if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, mcb.builders[0].mutation); err != nil { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { return nil, err } } @@ -220,8 +224,8 @@ func (mcb *MessagesCreateBulk) Save(ctx context.Context) ([]*Messages, error) { } // SaveX is like Save, but panics if an error occurs. -func (mcb *MessagesCreateBulk) SaveX(ctx context.Context) []*Messages { - v, err := mcb.Save(ctx) +func (_c *MessagesCreateBulk) SaveX(ctx context.Context) []*Messages { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -229,14 +233,14 @@ func (mcb *MessagesCreateBulk) SaveX(ctx context.Context) []*Messages { } // Exec executes the query. -func (mcb *MessagesCreateBulk) Exec(ctx context.Context) error { - _, err := mcb.Save(ctx) +func (_c *MessagesCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (mcb *MessagesCreateBulk) ExecX(ctx context.Context) { - if err := mcb.Exec(ctx); err != nil { +func (_c *MessagesCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } diff --git a/ent/messages_delete.go b/ent/messages_delete.go index afc2bc8..70ce575 100644 --- a/ent/messages_delete.go +++ b/ent/messages_delete.go @@ -20,56 +20,56 @@ type MessagesDelete struct { } // Where appends a list predicates to the MessagesDelete builder. -func (md *MessagesDelete) Where(ps ...predicate.Messages) *MessagesDelete { - md.mutation.Where(ps...) - return md +func (_d *MessagesDelete) Where(ps ...predicate.Messages) *MessagesDelete { + _d.mutation.Where(ps...) + return _d } // Exec executes the deletion query and returns how many vertices were deleted. -func (md *MessagesDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, md.sqlExec, md.mutation, md.hooks) +func (_d *MessagesDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) } // ExecX is like Exec, but panics if an error occurs. -func (md *MessagesDelete) ExecX(ctx context.Context) int { - n, err := md.Exec(ctx) +func (_d *MessagesDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) if err != nil { panic(err) } return n } -func (md *MessagesDelete) sqlExec(ctx context.Context) (int, error) { +func (_d *MessagesDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(messages.Table, sqlgraph.NewFieldSpec(messages.FieldID, field.TypeInt)) - if ps := md.mutation.predicates; len(ps) > 0 { + if ps := _d.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - affected, err := sqlgraph.DeleteNodes(ctx, md.driver, _spec) + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } - md.mutation.done = true + _d.mutation.done = true return affected, err } // MessagesDeleteOne is the builder for deleting a single Messages entity. type MessagesDeleteOne struct { - md *MessagesDelete + _d *MessagesDelete } // Where appends a list predicates to the MessagesDelete builder. -func (mdo *MessagesDeleteOne) Where(ps ...predicate.Messages) *MessagesDeleteOne { - mdo.md.mutation.Where(ps...) - return mdo +func (_d *MessagesDeleteOne) Where(ps ...predicate.Messages) *MessagesDeleteOne { + _d._d.mutation.Where(ps...) + return _d } // Exec executes the deletion query. -func (mdo *MessagesDeleteOne) Exec(ctx context.Context) error { - n, err := mdo.md.Exec(ctx) +func (_d *MessagesDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) switch { case err != nil: return err @@ -81,8 +81,8 @@ func (mdo *MessagesDeleteOne) Exec(ctx context.Context) error { } // ExecX is like Exec, but panics if an error occurs. -func (mdo *MessagesDeleteOne) ExecX(ctx context.Context) { - if err := mdo.Exec(ctx); err != nil { +func (_d *MessagesDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { panic(err) } } diff --git a/ent/messages_query.go b/ent/messages_query.go index 1284bf1..e1abe7f 100644 --- a/ent/messages_query.go +++ b/ent/messages_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -31,44 +32,44 @@ type MessagesQuery struct { } // Where adds a new predicate for the MessagesQuery builder. -func (mq *MessagesQuery) Where(ps ...predicate.Messages) *MessagesQuery { - mq.predicates = append(mq.predicates, ps...) - return mq +func (_q *MessagesQuery) Where(ps ...predicate.Messages) *MessagesQuery { + _q.predicates = append(_q.predicates, ps...) + return _q } // Limit the number of records to be returned by this query. -func (mq *MessagesQuery) Limit(limit int) *MessagesQuery { - mq.ctx.Limit = &limit - return mq +func (_q *MessagesQuery) Limit(limit int) *MessagesQuery { + _q.ctx.Limit = &limit + return _q } // Offset to start from. -func (mq *MessagesQuery) Offset(offset int) *MessagesQuery { - mq.ctx.Offset = &offset - return mq +func (_q *MessagesQuery) Offset(offset int) *MessagesQuery { + _q.ctx.Offset = &offset + return _q } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. -func (mq *MessagesQuery) Unique(unique bool) *MessagesQuery { - mq.ctx.Unique = &unique - return mq +func (_q *MessagesQuery) Unique(unique bool) *MessagesQuery { + _q.ctx.Unique = &unique + return _q } // Order specifies how the records should be ordered. -func (mq *MessagesQuery) Order(o ...messages.OrderOption) *MessagesQuery { - mq.order = append(mq.order, o...) - return mq +func (_q *MessagesQuery) Order(o ...messages.OrderOption) *MessagesQuery { + _q.order = append(_q.order, o...) + return _q } // QueryMatchPlayer chains the current query on the "match_player" edge. -func (mq *MessagesQuery) QueryMatchPlayer() *MatchPlayerQuery { - query := (&MatchPlayerClient{config: mq.config}).Query() +func (_q *MessagesQuery) QueryMatchPlayer() *MatchPlayerQuery { + query := (&MatchPlayerClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := mq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := mq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -77,7 +78,7 @@ func (mq *MessagesQuery) QueryMatchPlayer() *MatchPlayerQuery { sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, messages.MatchPlayerTable, messages.MatchPlayerColumn), ) - fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query @@ -85,8 +86,8 @@ func (mq *MessagesQuery) QueryMatchPlayer() *MatchPlayerQuery { // First returns the first Messages entity from the query. // Returns a *NotFoundError when no Messages was found. -func (mq *MessagesQuery) First(ctx context.Context) (*Messages, error) { - nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, "First")) +func (_q *MessagesQuery) First(ctx context.Context) (*Messages, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -97,8 +98,8 @@ func (mq *MessagesQuery) First(ctx context.Context) (*Messages, error) { } // FirstX is like First, but panics if an error occurs. -func (mq *MessagesQuery) FirstX(ctx context.Context) *Messages { - node, err := mq.First(ctx) +func (_q *MessagesQuery) FirstX(ctx context.Context) *Messages { + node, err := _q.First(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -107,9 +108,9 @@ func (mq *MessagesQuery) FirstX(ctx context.Context) *Messages { // FirstID returns the first Messages ID from the query. // Returns a *NotFoundError when no Messages ID was found. -func (mq *MessagesQuery) FirstID(ctx context.Context) (id int, err error) { +func (_q *MessagesQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, "FirstID")); err != nil { + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -120,8 +121,8 @@ func (mq *MessagesQuery) FirstID(ctx context.Context) (id int, err error) { } // FirstIDX is like FirstID, but panics if an error occurs. -func (mq *MessagesQuery) FirstIDX(ctx context.Context) int { - id, err := mq.FirstID(ctx) +func (_q *MessagesQuery) FirstIDX(ctx context.Context) int { + id, err := _q.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -131,8 +132,8 @@ func (mq *MessagesQuery) FirstIDX(ctx context.Context) int { // Only returns a single Messages entity found by the query, ensuring it only returns one. // Returns a *NotSingularError when more than one Messages entity is found. // Returns a *NotFoundError when no Messages entities are found. -func (mq *MessagesQuery) Only(ctx context.Context) (*Messages, error) { - nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, "Only")) +func (_q *MessagesQuery) Only(ctx context.Context) (*Messages, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -147,8 +148,8 @@ func (mq *MessagesQuery) Only(ctx context.Context) (*Messages, error) { } // OnlyX is like Only, but panics if an error occurs. -func (mq *MessagesQuery) OnlyX(ctx context.Context) *Messages { - node, err := mq.Only(ctx) +func (_q *MessagesQuery) OnlyX(ctx context.Context) *Messages { + node, err := _q.Only(ctx) if err != nil { panic(err) } @@ -158,9 +159,9 @@ func (mq *MessagesQuery) OnlyX(ctx context.Context) *Messages { // OnlyID is like Only, but returns the only Messages ID in the query. // Returns a *NotSingularError when more than one Messages ID is found. // Returns a *NotFoundError when no entities are found. -func (mq *MessagesQuery) OnlyID(ctx context.Context) (id int, err error) { +func (_q *MessagesQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, "OnlyID")); err != nil { + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -175,8 +176,8 @@ func (mq *MessagesQuery) OnlyID(ctx context.Context) (id int, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (mq *MessagesQuery) OnlyIDX(ctx context.Context) int { - id, err := mq.OnlyID(ctx) +func (_q *MessagesQuery) OnlyIDX(ctx context.Context) int { + id, err := _q.OnlyID(ctx) if err != nil { panic(err) } @@ -184,18 +185,18 @@ func (mq *MessagesQuery) OnlyIDX(ctx context.Context) int { } // All executes the query and returns a list of MessagesSlice. -func (mq *MessagesQuery) All(ctx context.Context) ([]*Messages, error) { - ctx = setContextOp(ctx, mq.ctx, "All") - if err := mq.prepareQuery(ctx); err != nil { +func (_q *MessagesQuery) All(ctx context.Context) ([]*Messages, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { return nil, err } qr := querierAll[[]*Messages, *MessagesQuery]() - return withInterceptors[[]*Messages](ctx, mq, qr, mq.inters) + return withInterceptors[[]*Messages](ctx, _q, qr, _q.inters) } // AllX is like All, but panics if an error occurs. -func (mq *MessagesQuery) AllX(ctx context.Context) []*Messages { - nodes, err := mq.All(ctx) +func (_q *MessagesQuery) AllX(ctx context.Context) []*Messages { + nodes, err := _q.All(ctx) if err != nil { panic(err) } @@ -203,20 +204,20 @@ func (mq *MessagesQuery) AllX(ctx context.Context) []*Messages { } // IDs executes the query and returns a list of Messages IDs. -func (mq *MessagesQuery) IDs(ctx context.Context) (ids []int, err error) { - if mq.ctx.Unique == nil && mq.path != nil { - mq.Unique(true) +func (_q *MessagesQuery) IDs(ctx context.Context) (ids []int, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) } - ctx = setContextOp(ctx, mq.ctx, "IDs") - if err = mq.Select(messages.FieldID).Scan(ctx, &ids); err != nil { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(messages.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. -func (mq *MessagesQuery) IDsX(ctx context.Context) []int { - ids, err := mq.IDs(ctx) +func (_q *MessagesQuery) IDsX(ctx context.Context) []int { + ids, err := _q.IDs(ctx) if err != nil { panic(err) } @@ -224,17 +225,17 @@ func (mq *MessagesQuery) IDsX(ctx context.Context) []int { } // Count returns the count of the given query. -func (mq *MessagesQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, mq.ctx, "Count") - if err := mq.prepareQuery(ctx); err != nil { +func (_q *MessagesQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { return 0, err } - return withInterceptors[int](ctx, mq, querierCount[*MessagesQuery](), mq.inters) + return withInterceptors[int](ctx, _q, querierCount[*MessagesQuery](), _q.inters) } // CountX is like Count, but panics if an error occurs. -func (mq *MessagesQuery) CountX(ctx context.Context) int { - count, err := mq.Count(ctx) +func (_q *MessagesQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) if err != nil { panic(err) } @@ -242,9 +243,9 @@ func (mq *MessagesQuery) CountX(ctx context.Context) int { } // Exist returns true if the query has elements in the graph. -func (mq *MessagesQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, mq.ctx, "Exist") - switch _, err := mq.FirstID(ctx); { +func (_q *MessagesQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { case IsNotFound(err): return false, nil case err != nil: @@ -255,8 +256,8 @@ func (mq *MessagesQuery) Exist(ctx context.Context) (bool, error) { } // ExistX is like Exist, but panics if an error occurs. -func (mq *MessagesQuery) ExistX(ctx context.Context) bool { - exist, err := mq.Exist(ctx) +func (_q *MessagesQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) if err != nil { panic(err) } @@ -265,32 +266,33 @@ func (mq *MessagesQuery) ExistX(ctx context.Context) bool { // Clone returns a duplicate of the MessagesQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. -func (mq *MessagesQuery) Clone() *MessagesQuery { - if mq == nil { +func (_q *MessagesQuery) Clone() *MessagesQuery { + if _q == nil { return nil } return &MessagesQuery{ - config: mq.config, - ctx: mq.ctx.Clone(), - order: append([]messages.OrderOption{}, mq.order...), - inters: append([]Interceptor{}, mq.inters...), - predicates: append([]predicate.Messages{}, mq.predicates...), - withMatchPlayer: mq.withMatchPlayer.Clone(), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]messages.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.Messages{}, _q.predicates...), + withMatchPlayer: _q.withMatchPlayer.Clone(), // clone intermediate query. - sql: mq.sql.Clone(), - path: mq.path, + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), } } // WithMatchPlayer tells the query-builder to eager-load the nodes that are connected to // the "match_player" edge. The optional arguments are used to configure the query builder of the edge. -func (mq *MessagesQuery) WithMatchPlayer(opts ...func(*MatchPlayerQuery)) *MessagesQuery { - query := (&MatchPlayerClient{config: mq.config}).Query() +func (_q *MessagesQuery) WithMatchPlayer(opts ...func(*MatchPlayerQuery)) *MessagesQuery { + query := (&MatchPlayerClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - mq.withMatchPlayer = query - return mq + _q.withMatchPlayer = query + return _q } // GroupBy is used to group vertices by one or more fields/columns. @@ -307,10 +309,10 @@ 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 { - mq.ctx.Fields = append([]string{field}, fields...) - grbuild := &MessagesGroupBy{build: mq} - grbuild.flds = &mq.ctx.Fields +func (_q *MessagesQuery) GroupBy(field string, fields ...string) *MessagesGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &MessagesGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields grbuild.label = messages.Label grbuild.scan = grbuild.Scan return grbuild @@ -328,55 +330,55 @@ 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.ctx.Fields = append(mq.ctx.Fields, fields...) - sbuild := &MessagesSelect{MessagesQuery: mq} +func (_q *MessagesQuery) Select(fields ...string) *MessagesSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &MessagesSelect{MessagesQuery: _q} sbuild.label = messages.Label - sbuild.flds, sbuild.scan = &mq.ctx.Fields, sbuild.Scan + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan return sbuild } // Aggregate returns a MessagesSelect configured with the given aggregations. -func (mq *MessagesQuery) Aggregate(fns ...AggregateFunc) *MessagesSelect { - return mq.Select().Aggregate(fns...) +func (_q *MessagesQuery) Aggregate(fns ...AggregateFunc) *MessagesSelect { + return _q.Select().Aggregate(fns...) } -func (mq *MessagesQuery) prepareQuery(ctx context.Context) error { - for _, inter := range mq.inters { +func (_q *MessagesQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { if inter == nil { return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") } if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, mq); err != nil { + if err := trv.Traverse(ctx, _q); err != nil { return err } } } - for _, f := range mq.ctx.Fields { + for _, f := range _q.ctx.Fields { if !messages.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } - if mq.path != nil { - prev, err := mq.path(ctx) + if _q.path != nil { + prev, err := _q.path(ctx) if err != nil { return err } - mq.sql = prev + _q.sql = prev } return nil } -func (mq *MessagesQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Messages, error) { +func (_q *MessagesQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Messages, error) { var ( nodes = []*Messages{} - withFKs = mq.withFKs - _spec = mq.querySpec() + withFKs = _q.withFKs + _spec = _q.querySpec() loadedTypes = [1]bool{ - mq.withMatchPlayer != nil, + _q.withMatchPlayer != nil, } ) - if mq.withMatchPlayer != nil { + if _q.withMatchPlayer != nil { withFKs = true } if withFKs { @@ -386,25 +388,25 @@ func (mq *MessagesQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Mes return (*Messages).scanValues(nil, columns) } _spec.Assign = func(columns []string, values []any) error { - node := &Messages{config: mq.config} + node := &Messages{config: _q.config} nodes = append(nodes, node) node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) } - if len(mq.modifiers) > 0 { - _spec.Modifiers = mq.modifiers + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } for i := range hooks { hooks[i](ctx, _spec) } - if err := sqlgraph.QueryNodes(ctx, mq.driver, _spec); err != nil { + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { return nil, err } if len(nodes) == 0 { return nodes, nil } - if query := mq.withMatchPlayer; query != nil { - if err := mq.loadMatchPlayer(ctx, query, nodes, nil, + if query := _q.withMatchPlayer; query != nil { + if err := _q.loadMatchPlayer(ctx, query, nodes, nil, func(n *Messages, e *MatchPlayer) { n.Edges.MatchPlayer = e }); err != nil { return nil, err } @@ -412,7 +414,7 @@ func (mq *MessagesQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Mes return nodes, nil } -func (mq *MessagesQuery) loadMatchPlayer(ctx context.Context, query *MatchPlayerQuery, nodes []*Messages, init func(*Messages), assign func(*Messages, *MatchPlayer)) error { +func (_q *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 { @@ -445,27 +447,27 @@ func (mq *MessagesQuery) loadMatchPlayer(ctx context.Context, query *MatchPlayer return nil } -func (mq *MessagesQuery) sqlCount(ctx context.Context) (int, error) { - _spec := mq.querySpec() - if len(mq.modifiers) > 0 { - _spec.Modifiers = mq.modifiers +func (_q *MessagesQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } - _spec.Node.Columns = mq.ctx.Fields - if len(mq.ctx.Fields) > 0 { - _spec.Unique = mq.ctx.Unique != nil && *mq.ctx.Unique + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique } - return sqlgraph.CountNodes(ctx, mq.driver, _spec) + return sqlgraph.CountNodes(ctx, _q.driver, _spec) } -func (mq *MessagesQuery) querySpec() *sqlgraph.QuerySpec { +func (_q *MessagesQuery) querySpec() *sqlgraph.QuerySpec { _spec := sqlgraph.NewQuerySpec(messages.Table, messages.Columns, sqlgraph.NewFieldSpec(messages.FieldID, field.TypeInt)) - _spec.From = mq.sql - if unique := mq.ctx.Unique; unique != nil { + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { _spec.Unique = *unique - } else if mq.path != nil { + } else if _q.path != nil { _spec.Unique = true } - if fields := mq.ctx.Fields; len(fields) > 0 { + if fields := _q.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, messages.FieldID) for i := range fields { @@ -474,20 +476,20 @@ func (mq *MessagesQuery) querySpec() *sqlgraph.QuerySpec { } } } - if ps := mq.predicates; len(ps) > 0 { + if ps := _q.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if limit := mq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := mq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { _spec.Offset = *offset } - if ps := mq.order; len(ps) > 0 { + if ps := _q.order; len(ps) > 0 { _spec.Order = func(selector *sql.Selector) { for i := range ps { ps[i](selector) @@ -497,45 +499,45 @@ func (mq *MessagesQuery) querySpec() *sqlgraph.QuerySpec { return _spec } -func (mq *MessagesQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(mq.driver.Dialect()) +func (_q *MessagesQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) t1 := builder.Table(messages.Table) - columns := mq.ctx.Fields + columns := _q.ctx.Fields if len(columns) == 0 { columns = messages.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) - if mq.sql != nil { - selector = mq.sql + if _q.sql != nil { + selector = _q.sql selector.Select(selector.Columns(columns...)...) } - if mq.ctx.Unique != nil && *mq.ctx.Unique { + if _q.ctx.Unique != nil && *_q.ctx.Unique { selector.Distinct() } - for _, m := range mq.modifiers { + for _, m := range _q.modifiers { m(selector) } - for _, p := range mq.predicates { + for _, p := range _q.predicates { p(selector) } - for _, p := range mq.order { + for _, p := range _q.order { p(selector) } - if offset := mq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { // limit is mandatory for offset clause. We start // with default value, and override it below if needed. selector.Offset(*offset).Limit(math.MaxInt32) } - if limit := mq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector } // Modify adds a query modifier for attaching custom logic to queries. -func (mq *MessagesQuery) Modify(modifiers ...func(s *sql.Selector)) *MessagesSelect { - mq.modifiers = append(mq.modifiers, modifiers...) - return mq.Select() +func (_q *MessagesQuery) Modify(modifiers ...func(s *sql.Selector)) *MessagesSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() } // MessagesGroupBy is the group-by builder for Messages entities. @@ -545,41 +547,41 @@ type MessagesGroupBy struct { } // Aggregate adds the given aggregation functions to the group-by query. -func (mgb *MessagesGroupBy) Aggregate(fns ...AggregateFunc) *MessagesGroupBy { - mgb.fns = append(mgb.fns, fns...) - return mgb +func (_g *MessagesGroupBy) Aggregate(fns ...AggregateFunc) *MessagesGroupBy { + _g.fns = append(_g.fns, fns...) + return _g } // Scan applies the selector query and scans the result into the given value. -func (mgb *MessagesGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, mgb.build.ctx, "GroupBy") - if err := mgb.build.prepareQuery(ctx); err != nil { +func (_g *MessagesGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*MessagesQuery, *MessagesGroupBy](ctx, mgb.build, mgb, mgb.build.inters, v) + return scanWithInterceptors[*MessagesQuery, *MessagesGroupBy](ctx, _g.build, _g, _g.build.inters, v) } -func (mgb *MessagesGroupBy) sqlScan(ctx context.Context, root *MessagesQuery, v any) error { +func (_g *MessagesGroupBy) sqlScan(ctx context.Context, root *MessagesQuery, v any) error { selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(mgb.fns)) - for _, fn := range mgb.fns { + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { aggregation = append(aggregation, fn(selector)) } if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*mgb.flds)+len(mgb.fns)) - for _, f := range *mgb.flds { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { columns = append(columns, selector.C(f)) } columns = append(columns, aggregation...) selector.Select(columns...) } - selector.GroupBy(selector.Columns(*mgb.flds...)...) + selector.GroupBy(selector.Columns(*_g.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := mgb.build.driver.Query(ctx, query, args, rows); err != nil { + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -593,27 +595,27 @@ type MessagesSelect struct { } // Aggregate adds the given aggregation functions to the selector query. -func (ms *MessagesSelect) Aggregate(fns ...AggregateFunc) *MessagesSelect { - ms.fns = append(ms.fns, fns...) - return ms +func (_s *MessagesSelect) Aggregate(fns ...AggregateFunc) *MessagesSelect { + _s.fns = append(_s.fns, fns...) + return _s } // Scan applies the selector query and scans the result into the given value. -func (ms *MessagesSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ms.ctx, "Select") - if err := ms.prepareQuery(ctx); err != nil { +func (_s *MessagesSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*MessagesQuery, *MessagesSelect](ctx, ms.MessagesQuery, ms, ms.inters, v) + return scanWithInterceptors[*MessagesQuery, *MessagesSelect](ctx, _s.MessagesQuery, _s, _s.inters, v) } -func (ms *MessagesSelect) sqlScan(ctx context.Context, root *MessagesQuery, v any) error { +func (_s *MessagesSelect) sqlScan(ctx context.Context, root *MessagesQuery, v any) error { selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(ms.fns)) - for _, fn := range ms.fns { + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { aggregation = append(aggregation, fn(selector)) } - switch n := len(*ms.selector.flds); { + switch n := len(*_s.selector.flds); { case n == 0 && len(aggregation) > 0: selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: @@ -621,7 +623,7 @@ func (ms *MessagesSelect) sqlScan(ctx context.Context, root *MessagesQuery, v an } rows := &sql.Rows{} query, args := selector.Query() - if err := ms.driver.Query(ctx, query, args, rows); err != nil { + if err := _s.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -629,7 +631,7 @@ func (ms *MessagesSelect) sqlScan(ctx context.Context, root *MessagesQuery, v an } // Modify adds a query modifier for attaching custom logic to queries. -func (ms *MessagesSelect) Modify(modifiers ...func(s *sql.Selector)) *MessagesSelect { - ms.modifiers = append(ms.modifiers, modifiers...) - return ms +func (_s *MessagesSelect) Modify(modifiers ...func(s *sql.Selector)) *MessagesSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s } diff --git a/ent/messages_update.go b/ent/messages_update.go index 2597c51..f929e18 100644 --- a/ent/messages_update.go +++ b/ent/messages_update.go @@ -24,74 +24,98 @@ type MessagesUpdate struct { } // Where appends a list predicates to the MessagesUpdate builder. -func (mu *MessagesUpdate) Where(ps ...predicate.Messages) *MessagesUpdate { - mu.mutation.Where(ps...) - return mu +func (_u *MessagesUpdate) Where(ps ...predicate.Messages) *MessagesUpdate { + _u.mutation.Where(ps...) + return _u } // SetMessage sets the "message" field. -func (mu *MessagesUpdate) SetMessage(s string) *MessagesUpdate { - mu.mutation.SetMessage(s) - return mu +func (_u *MessagesUpdate) SetMessage(v string) *MessagesUpdate { + _u.mutation.SetMessage(v) + return _u +} + +// SetNillableMessage sets the "message" field if the given value is not nil. +func (_u *MessagesUpdate) SetNillableMessage(v *string) *MessagesUpdate { + if v != nil { + _u.SetMessage(*v) + } + return _u } // SetAllChat sets the "all_chat" field. -func (mu *MessagesUpdate) SetAllChat(b bool) *MessagesUpdate { - mu.mutation.SetAllChat(b) - return mu +func (_u *MessagesUpdate) SetAllChat(v bool) *MessagesUpdate { + _u.mutation.SetAllChat(v) + return _u +} + +// SetNillableAllChat sets the "all_chat" field if the given value is not nil. +func (_u *MessagesUpdate) SetNillableAllChat(v *bool) *MessagesUpdate { + if v != nil { + _u.SetAllChat(*v) + } + return _u } // SetTick sets the "tick" field. -func (mu *MessagesUpdate) SetTick(i int) *MessagesUpdate { - mu.mutation.ResetTick() - mu.mutation.SetTick(i) - return mu +func (_u *MessagesUpdate) SetTick(v int) *MessagesUpdate { + _u.mutation.ResetTick() + _u.mutation.SetTick(v) + return _u } -// AddTick adds i to the "tick" field. -func (mu *MessagesUpdate) AddTick(i int) *MessagesUpdate { - mu.mutation.AddTick(i) - return mu +// SetNillableTick sets the "tick" field if the given value is not nil. +func (_u *MessagesUpdate) SetNillableTick(v *int) *MessagesUpdate { + if v != nil { + _u.SetTick(*v) + } + return _u +} + +// AddTick adds value to the "tick" field. +func (_u *MessagesUpdate) AddTick(v int) *MessagesUpdate { + _u.mutation.AddTick(v) + return _u } // SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID. -func (mu *MessagesUpdate) SetMatchPlayerID(id int) *MessagesUpdate { - mu.mutation.SetMatchPlayerID(id) - return mu +func (_u *MessagesUpdate) SetMatchPlayerID(id int) *MessagesUpdate { + _u.mutation.SetMatchPlayerID(id) + return _u } // SetNillableMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID if the given value is not nil. -func (mu *MessagesUpdate) SetNillableMatchPlayerID(id *int) *MessagesUpdate { +func (_u *MessagesUpdate) SetNillableMatchPlayerID(id *int) *MessagesUpdate { if id != nil { - mu = mu.SetMatchPlayerID(*id) + _u = _u.SetMatchPlayerID(*id) } - return mu + return _u } // SetMatchPlayer sets the "match_player" edge to the MatchPlayer entity. -func (mu *MessagesUpdate) SetMatchPlayer(m *MatchPlayer) *MessagesUpdate { - return mu.SetMatchPlayerID(m.ID) +func (_u *MessagesUpdate) SetMatchPlayer(v *MatchPlayer) *MessagesUpdate { + return _u.SetMatchPlayerID(v.ID) } // Mutation returns the MessagesMutation object of the builder. -func (mu *MessagesUpdate) Mutation() *MessagesMutation { - return mu.mutation +func (_u *MessagesUpdate) Mutation() *MessagesMutation { + return _u.mutation } // ClearMatchPlayer clears the "match_player" edge to the MatchPlayer entity. -func (mu *MessagesUpdate) ClearMatchPlayer() *MessagesUpdate { - mu.mutation.ClearMatchPlayer() - return mu +func (_u *MessagesUpdate) ClearMatchPlayer() *MessagesUpdate { + _u.mutation.ClearMatchPlayer() + return _u } // Save executes the query and returns the number of nodes affected by the update operation. -func (mu *MessagesUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, mu.sqlSave, mu.mutation, mu.hooks) +func (_u *MessagesUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (mu *MessagesUpdate) SaveX(ctx context.Context) int { - affected, err := mu.Save(ctx) +func (_u *MessagesUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) if err != nil { panic(err) } @@ -99,46 +123,46 @@ func (mu *MessagesUpdate) SaveX(ctx context.Context) int { } // Exec executes the query. -func (mu *MessagesUpdate) Exec(ctx context.Context) error { - _, err := mu.Save(ctx) +func (_u *MessagesUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (mu *MessagesUpdate) ExecX(ctx context.Context) { - if err := mu.Exec(ctx); err != nil { +func (_u *MessagesUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // 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 (_u *MessagesUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MessagesUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (mu *MessagesUpdate) sqlSave(ctx context.Context) (n int, err error) { +func (_u *MessagesUpdate) sqlSave(ctx context.Context) (_node int, err error) { _spec := sqlgraph.NewUpdateSpec(messages.Table, messages.Columns, sqlgraph.NewFieldSpec(messages.FieldID, field.TypeInt)) - if ps := mu.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := mu.mutation.Message(); ok { + if value, ok := _u.mutation.Message(); ok { _spec.SetField(messages.FieldMessage, field.TypeString, value) } - if value, ok := mu.mutation.AllChat(); ok { + if value, ok := _u.mutation.AllChat(); ok { _spec.SetField(messages.FieldAllChat, field.TypeBool, value) } - if value, ok := mu.mutation.Tick(); ok { + if value, ok := _u.mutation.Tick(); ok { _spec.SetField(messages.FieldTick, field.TypeInt, value) } - if value, ok := mu.mutation.AddedTick(); ok { + if value, ok := _u.mutation.AddedTick(); ok { _spec.AddField(messages.FieldTick, field.TypeInt, value) } - if mu.mutation.MatchPlayerCleared() { + if _u.mutation.MatchPlayerCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -151,7 +175,7 @@ func (mu *MessagesUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := mu.mutation.MatchPlayerIDs(); len(nodes) > 0 { + if nodes := _u.mutation.MatchPlayerIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -167,8 +191,8 @@ func (mu *MessagesUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(mu.modifiers...) - if n, err = sqlgraph.UpdateNodes(ctx, mu.driver, _spec); err != nil { + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{messages.Label} } else if sqlgraph.IsConstraintError(err) { @@ -176,8 +200,8 @@ func (mu *MessagesUpdate) sqlSave(ctx context.Context) (n int, err error) { } return 0, err } - mu.mutation.done = true - return n, nil + _u.mutation.done = true + return _node, nil } // MessagesUpdateOne is the builder for updating a single Messages entity. @@ -190,81 +214,105 @@ type MessagesUpdateOne struct { } // SetMessage sets the "message" field. -func (muo *MessagesUpdateOne) SetMessage(s string) *MessagesUpdateOne { - muo.mutation.SetMessage(s) - return muo +func (_u *MessagesUpdateOne) SetMessage(v string) *MessagesUpdateOne { + _u.mutation.SetMessage(v) + return _u +} + +// SetNillableMessage sets the "message" field if the given value is not nil. +func (_u *MessagesUpdateOne) SetNillableMessage(v *string) *MessagesUpdateOne { + if v != nil { + _u.SetMessage(*v) + } + return _u } // SetAllChat sets the "all_chat" field. -func (muo *MessagesUpdateOne) SetAllChat(b bool) *MessagesUpdateOne { - muo.mutation.SetAllChat(b) - return muo +func (_u *MessagesUpdateOne) SetAllChat(v bool) *MessagesUpdateOne { + _u.mutation.SetAllChat(v) + return _u +} + +// SetNillableAllChat sets the "all_chat" field if the given value is not nil. +func (_u *MessagesUpdateOne) SetNillableAllChat(v *bool) *MessagesUpdateOne { + if v != nil { + _u.SetAllChat(*v) + } + return _u } // SetTick sets the "tick" field. -func (muo *MessagesUpdateOne) SetTick(i int) *MessagesUpdateOne { - muo.mutation.ResetTick() - muo.mutation.SetTick(i) - return muo +func (_u *MessagesUpdateOne) SetTick(v int) *MessagesUpdateOne { + _u.mutation.ResetTick() + _u.mutation.SetTick(v) + return _u } -// AddTick adds i to the "tick" field. -func (muo *MessagesUpdateOne) AddTick(i int) *MessagesUpdateOne { - muo.mutation.AddTick(i) - return muo +// SetNillableTick sets the "tick" field if the given value is not nil. +func (_u *MessagesUpdateOne) SetNillableTick(v *int) *MessagesUpdateOne { + if v != nil { + _u.SetTick(*v) + } + return _u +} + +// AddTick adds value to the "tick" field. +func (_u *MessagesUpdateOne) AddTick(v int) *MessagesUpdateOne { + _u.mutation.AddTick(v) + return _u } // SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID. -func (muo *MessagesUpdateOne) SetMatchPlayerID(id int) *MessagesUpdateOne { - muo.mutation.SetMatchPlayerID(id) - return muo +func (_u *MessagesUpdateOne) SetMatchPlayerID(id int) *MessagesUpdateOne { + _u.mutation.SetMatchPlayerID(id) + return _u } // SetNillableMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID if the given value is not nil. -func (muo *MessagesUpdateOne) SetNillableMatchPlayerID(id *int) *MessagesUpdateOne { +func (_u *MessagesUpdateOne) SetNillableMatchPlayerID(id *int) *MessagesUpdateOne { if id != nil { - muo = muo.SetMatchPlayerID(*id) + _u = _u.SetMatchPlayerID(*id) } - return muo + return _u } // SetMatchPlayer sets the "match_player" edge to the MatchPlayer entity. -func (muo *MessagesUpdateOne) SetMatchPlayer(m *MatchPlayer) *MessagesUpdateOne { - return muo.SetMatchPlayerID(m.ID) +func (_u *MessagesUpdateOne) SetMatchPlayer(v *MatchPlayer) *MessagesUpdateOne { + return _u.SetMatchPlayerID(v.ID) } // Mutation returns the MessagesMutation object of the builder. -func (muo *MessagesUpdateOne) Mutation() *MessagesMutation { - return muo.mutation +func (_u *MessagesUpdateOne) Mutation() *MessagesMutation { + return _u.mutation } // ClearMatchPlayer clears the "match_player" edge to the MatchPlayer entity. -func (muo *MessagesUpdateOne) ClearMatchPlayer() *MessagesUpdateOne { - muo.mutation.ClearMatchPlayer() - return muo +func (_u *MessagesUpdateOne) ClearMatchPlayer() *MessagesUpdateOne { + _u.mutation.ClearMatchPlayer() + return _u } // Where appends a list predicates to the MessagesUpdate builder. -func (muo *MessagesUpdateOne) Where(ps ...predicate.Messages) *MessagesUpdateOne { - muo.mutation.Where(ps...) - return muo +func (_u *MessagesUpdateOne) Where(ps ...predicate.Messages) *MessagesUpdateOne { + _u.mutation.Where(ps...) + return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. -func (muo *MessagesUpdateOne) Select(field string, fields ...string) *MessagesUpdateOne { - muo.fields = append([]string{field}, fields...) - return muo +func (_u *MessagesUpdateOne) Select(field string, fields ...string) *MessagesUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u } // Save executes the query and returns the updated Messages entity. -func (muo *MessagesUpdateOne) Save(ctx context.Context) (*Messages, error) { - return withHooks(ctx, muo.sqlSave, muo.mutation, muo.hooks) +func (_u *MessagesUpdateOne) Save(ctx context.Context) (*Messages, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (muo *MessagesUpdateOne) SaveX(ctx context.Context) *Messages { - node, err := muo.Save(ctx) +func (_u *MessagesUpdateOne) SaveX(ctx context.Context) *Messages { + node, err := _u.Save(ctx) if err != nil { panic(err) } @@ -272,32 +320,32 @@ func (muo *MessagesUpdateOne) SaveX(ctx context.Context) *Messages { } // Exec executes the query on the entity. -func (muo *MessagesUpdateOne) Exec(ctx context.Context) error { - _, err := muo.Save(ctx) +func (_u *MessagesUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (muo *MessagesUpdateOne) ExecX(ctx context.Context) { - if err := muo.Exec(ctx); err != nil { +func (_u *MessagesUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // 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 (_u *MessagesUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MessagesUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err error) { +func (_u *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err error) { _spec := sqlgraph.NewUpdateSpec(messages.Table, messages.Columns, sqlgraph.NewFieldSpec(messages.FieldID, field.TypeInt)) - id, ok := muo.mutation.ID() + id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Messages.id" for update`)} } _spec.Node.ID.Value = id - if fields := muo.fields; len(fields) > 0 { + if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, messages.FieldID) for _, f := range fields { @@ -309,26 +357,26 @@ func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err } } } - if ps := muo.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := muo.mutation.Message(); ok { + if value, ok := _u.mutation.Message(); ok { _spec.SetField(messages.FieldMessage, field.TypeString, value) } - if value, ok := muo.mutation.AllChat(); ok { + if value, ok := _u.mutation.AllChat(); ok { _spec.SetField(messages.FieldAllChat, field.TypeBool, value) } - if value, ok := muo.mutation.Tick(); ok { + if value, ok := _u.mutation.Tick(); ok { _spec.SetField(messages.FieldTick, field.TypeInt, value) } - if value, ok := muo.mutation.AddedTick(); ok { + if value, ok := _u.mutation.AddedTick(); ok { _spec.AddField(messages.FieldTick, field.TypeInt, value) } - if muo.mutation.MatchPlayerCleared() { + if _u.mutation.MatchPlayerCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -341,7 +389,7 @@ func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := muo.mutation.MatchPlayerIDs(); len(nodes) > 0 { + if nodes := _u.mutation.MatchPlayerIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -357,11 +405,11 @@ func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(muo.modifiers...) - _node = &Messages{config: muo.config} + _spec.AddModifiers(_u.modifiers...) + _node = &Messages{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, muo.driver, _spec); err != nil { + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{messages.Label} } else if sqlgraph.IsConstraintError(err) { @@ -369,6 +417,6 @@ func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err } return nil, err } - muo.mutation.done = true + _u.mutation.done = true return _node, nil } diff --git a/ent/mutation.go b/ent/mutation.go index 0208fc3..6a89973 100644 --- a/ent/mutation.go +++ b/ent/mutation.go @@ -3852,6 +3852,7 @@ func (m *MatchPlayerMutation) SetMatchesID(id uint64) { // ClearMatches clears the "matches" edge to the Match entity. func (m *MatchPlayerMutation) ClearMatches() { m.clearedmatches = true + m.clearedFields[matchplayer.FieldMatchStats] = struct{}{} } // MatchesCleared reports if the "matches" edge to the Match entity was cleared. @@ -3891,6 +3892,7 @@ func (m *MatchPlayerMutation) SetPlayersID(id uint64) { // ClearPlayers clears the "players" edge to the Player entity. func (m *MatchPlayerMutation) ClearPlayers() { m.clearedplayers = true + m.clearedFields[matchplayer.FieldPlayerStats] = struct{}{} } // PlayersCleared reports if the "players" edge to the Player entity was cleared. diff --git a/ent/player.go b/ent/player.go index 363f056..1981813 100644 --- a/ent/player.go +++ b/ent/player.go @@ -104,7 +104,7 @@ func (*Player) scanValues(columns []string) ([]any, error) { // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the Player fields. -func (pl *Player) assignValues(columns []string, values []any) error { +func (_m *Player) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } @@ -115,105 +115,105 @@ func (pl *Player) assignValues(columns []string, values []any) error { if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - pl.ID = uint64(value.Int64) + _m.ID = uint64(value.Int64) case player.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) } else if value.Valid { - pl.Name = value.String + _m.Name = value.String } case player.FieldAvatar: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field avatar", values[i]) } else if value.Valid { - pl.Avatar = value.String + _m.Avatar = value.String } case player.FieldVanityURL: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field vanity_url", values[i]) } else if value.Valid { - pl.VanityURL = value.String + _m.VanityURL = value.String } case player.FieldVanityURLReal: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field vanity_url_real", values[i]) } else if value.Valid { - pl.VanityURLReal = value.String + _m.VanityURLReal = value.String } case player.FieldVacDate: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field vac_date", values[i]) } else if value.Valid { - pl.VacDate = value.Time + _m.VacDate = value.Time } case player.FieldVacCount: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field vac_count", values[i]) } else if value.Valid { - pl.VacCount = int(value.Int64) + _m.VacCount = int(value.Int64) } case player.FieldGameBanDate: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field game_ban_date", values[i]) } else if value.Valid { - pl.GameBanDate = value.Time + _m.GameBanDate = value.Time } case player.FieldGameBanCount: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field game_ban_count", values[i]) } else if value.Valid { - pl.GameBanCount = int(value.Int64) + _m.GameBanCount = int(value.Int64) } case player.FieldSteamUpdated: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field steam_updated", values[i]) } else if value.Valid { - pl.SteamUpdated = value.Time + _m.SteamUpdated = value.Time } case player.FieldSharecodeUpdated: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field sharecode_updated", values[i]) } else if value.Valid { - pl.SharecodeUpdated = value.Time + _m.SharecodeUpdated = value.Time } case player.FieldAuthCode: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field auth_code", values[i]) } else if value.Valid { - pl.AuthCode = value.String + _m.AuthCode = value.String } case player.FieldProfileCreated: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field profile_created", values[i]) } else if value.Valid { - pl.ProfileCreated = value.Time + _m.ProfileCreated = value.Time } case player.FieldOldestSharecodeSeen: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field oldest_sharecode_seen", values[i]) } else if value.Valid { - pl.OldestSharecodeSeen = value.String + _m.OldestSharecodeSeen = value.String } case player.FieldWins: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field wins", values[i]) } else if value.Valid { - pl.Wins = int(value.Int64) + _m.Wins = int(value.Int64) } case player.FieldLooses: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field looses", values[i]) } else if value.Valid { - pl.Looses = int(value.Int64) + _m.Looses = int(value.Int64) } case player.FieldTies: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field ties", values[i]) } else if value.Valid { - pl.Ties = int(value.Int64) + _m.Ties = int(value.Int64) } default: - pl.selectValues.Set(columns[i], values[i]) + _m.selectValues.Set(columns[i], values[i]) } } return nil @@ -221,89 +221,89 @@ func (pl *Player) assignValues(columns []string, values []any) error { // Value returns the ent.Value that was dynamically selected and assigned to the Player. // This includes values selected through modifiers, order, etc. -func (pl *Player) Value(name string) (ent.Value, error) { - return pl.selectValues.Get(name) +func (_m *Player) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) } // QueryStats queries the "stats" edge of the Player entity. -func (pl *Player) QueryStats() *MatchPlayerQuery { - return NewPlayerClient(pl.config).QueryStats(pl) +func (_m *Player) QueryStats() *MatchPlayerQuery { + return NewPlayerClient(_m.config).QueryStats(_m) } // QueryMatches queries the "matches" edge of the Player entity. -func (pl *Player) QueryMatches() *MatchQuery { - return NewPlayerClient(pl.config).QueryMatches(pl) +func (_m *Player) QueryMatches() *MatchQuery { + return NewPlayerClient(_m.config).QueryMatches(_m) } // Update returns a builder for updating this Player. // Note that you need to call Player.Unwrap() before calling this method if this Player // was returned from a transaction, and the transaction was committed or rolled back. -func (pl *Player) Update() *PlayerUpdateOne { - return NewPlayerClient(pl.config).UpdateOne(pl) +func (_m *Player) Update() *PlayerUpdateOne { + return NewPlayerClient(_m.config).UpdateOne(_m) } // 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) +func (_m *Player) Unwrap() *Player { + _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: Player is not a transactional entity") } - pl.config.driver = _tx.drv - return pl + _m.config.driver = _tx.drv + return _m } // String implements the fmt.Stringer. -func (pl *Player) String() string { +func (_m *Player) String() string { var builder strings.Builder builder.WriteString("Player(") - builder.WriteString(fmt.Sprintf("id=%v, ", pl.ID)) + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("name=") - builder.WriteString(pl.Name) + builder.WriteString(_m.Name) builder.WriteString(", ") builder.WriteString("avatar=") - builder.WriteString(pl.Avatar) + builder.WriteString(_m.Avatar) builder.WriteString(", ") builder.WriteString("vanity_url=") - builder.WriteString(pl.VanityURL) + builder.WriteString(_m.VanityURL) builder.WriteString(", ") builder.WriteString("vanity_url_real=") - builder.WriteString(pl.VanityURLReal) + builder.WriteString(_m.VanityURLReal) builder.WriteString(", ") builder.WriteString("vac_date=") - builder.WriteString(pl.VacDate.Format(time.ANSIC)) + builder.WriteString(_m.VacDate.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("vac_count=") - builder.WriteString(fmt.Sprintf("%v", pl.VacCount)) + builder.WriteString(fmt.Sprintf("%v", _m.VacCount)) builder.WriteString(", ") builder.WriteString("game_ban_date=") - builder.WriteString(pl.GameBanDate.Format(time.ANSIC)) + builder.WriteString(_m.GameBanDate.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("game_ban_count=") - builder.WriteString(fmt.Sprintf("%v", pl.GameBanCount)) + builder.WriteString(fmt.Sprintf("%v", _m.GameBanCount)) builder.WriteString(", ") builder.WriteString("steam_updated=") - builder.WriteString(pl.SteamUpdated.Format(time.ANSIC)) + builder.WriteString(_m.SteamUpdated.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("sharecode_updated=") - builder.WriteString(pl.SharecodeUpdated.Format(time.ANSIC)) + builder.WriteString(_m.SharecodeUpdated.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("auth_code=") builder.WriteString(", ") builder.WriteString("profile_created=") - builder.WriteString(pl.ProfileCreated.Format(time.ANSIC)) + builder.WriteString(_m.ProfileCreated.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("oldest_sharecode_seen=") - builder.WriteString(pl.OldestSharecodeSeen) + builder.WriteString(_m.OldestSharecodeSeen) builder.WriteString(", ") builder.WriteString("wins=") - builder.WriteString(fmt.Sprintf("%v", pl.Wins)) + builder.WriteString(fmt.Sprintf("%v", _m.Wins)) builder.WriteString(", ") builder.WriteString("looses=") - builder.WriteString(fmt.Sprintf("%v", pl.Looses)) + builder.WriteString(fmt.Sprintf("%v", _m.Looses)) builder.WriteString(", ") builder.WriteString("ties=") - builder.WriteString(fmt.Sprintf("%v", pl.Ties)) + builder.WriteString(fmt.Sprintf("%v", _m.Ties)) builder.WriteByte(')') return builder.String() } diff --git a/ent/player/where.go b/ent/player/where.go index 63dc8ed..349277f 100644 --- a/ent/player/where.go +++ b/ent/player/where.go @@ -1123,32 +1123,15 @@ func HasMatchesWith(preds ...predicate.Match) predicate.Player { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Player) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Player(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Player) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Player(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Player) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Player(sql.NotPredicates(p)) } diff --git a/ent/player_create.go b/ent/player_create.go index 71c2f9f..d227a5f 100644 --- a/ent/player_create.go +++ b/ent/player_create.go @@ -23,279 +23,279 @@ type PlayerCreate struct { } // SetName sets the "name" field. -func (pc *PlayerCreate) SetName(s string) *PlayerCreate { - pc.mutation.SetName(s) - return pc +func (_c *PlayerCreate) SetName(v string) *PlayerCreate { + _c.mutation.SetName(v) + return _c } // SetNillableName sets the "name" field if the given value is not nil. -func (pc *PlayerCreate) SetNillableName(s *string) *PlayerCreate { - if s != nil { - pc.SetName(*s) +func (_c *PlayerCreate) SetNillableName(v *string) *PlayerCreate { + if v != nil { + _c.SetName(*v) } - return pc + return _c } // SetAvatar sets the "avatar" field. -func (pc *PlayerCreate) SetAvatar(s string) *PlayerCreate { - pc.mutation.SetAvatar(s) - return pc +func (_c *PlayerCreate) SetAvatar(v string) *PlayerCreate { + _c.mutation.SetAvatar(v) + return _c } // SetNillableAvatar sets the "avatar" field if the given value is not nil. -func (pc *PlayerCreate) SetNillableAvatar(s *string) *PlayerCreate { - if s != nil { - pc.SetAvatar(*s) +func (_c *PlayerCreate) SetNillableAvatar(v *string) *PlayerCreate { + if v != nil { + _c.SetAvatar(*v) } - return pc + return _c } // SetVanityURL sets the "vanity_url" field. -func (pc *PlayerCreate) SetVanityURL(s string) *PlayerCreate { - pc.mutation.SetVanityURL(s) - return pc +func (_c *PlayerCreate) SetVanityURL(v string) *PlayerCreate { + _c.mutation.SetVanityURL(v) + return _c } // SetNillableVanityURL sets the "vanity_url" field if the given value is not nil. -func (pc *PlayerCreate) SetNillableVanityURL(s *string) *PlayerCreate { - if s != nil { - pc.SetVanityURL(*s) +func (_c *PlayerCreate) SetNillableVanityURL(v *string) *PlayerCreate { + if v != nil { + _c.SetVanityURL(*v) } - return pc + return _c } // SetVanityURLReal sets the "vanity_url_real" field. -func (pc *PlayerCreate) SetVanityURLReal(s string) *PlayerCreate { - pc.mutation.SetVanityURLReal(s) - return pc +func (_c *PlayerCreate) SetVanityURLReal(v string) *PlayerCreate { + _c.mutation.SetVanityURLReal(v) + return _c } // SetNillableVanityURLReal sets the "vanity_url_real" field if the given value is not nil. -func (pc *PlayerCreate) SetNillableVanityURLReal(s *string) *PlayerCreate { - if s != nil { - pc.SetVanityURLReal(*s) +func (_c *PlayerCreate) SetNillableVanityURLReal(v *string) *PlayerCreate { + if v != nil { + _c.SetVanityURLReal(*v) } - return pc + return _c } // SetVacDate sets the "vac_date" field. -func (pc *PlayerCreate) SetVacDate(t time.Time) *PlayerCreate { - pc.mutation.SetVacDate(t) - return pc +func (_c *PlayerCreate) SetVacDate(v time.Time) *PlayerCreate { + _c.mutation.SetVacDate(v) + return _c } // SetNillableVacDate sets the "vac_date" field if the given value is not nil. -func (pc *PlayerCreate) SetNillableVacDate(t *time.Time) *PlayerCreate { - if t != nil { - pc.SetVacDate(*t) +func (_c *PlayerCreate) SetNillableVacDate(v *time.Time) *PlayerCreate { + if v != nil { + _c.SetVacDate(*v) } - return pc + return _c } // SetVacCount sets the "vac_count" field. -func (pc *PlayerCreate) SetVacCount(i int) *PlayerCreate { - pc.mutation.SetVacCount(i) - return pc +func (_c *PlayerCreate) SetVacCount(v int) *PlayerCreate { + _c.mutation.SetVacCount(v) + return _c } // SetNillableVacCount sets the "vac_count" field if the given value is not nil. -func (pc *PlayerCreate) SetNillableVacCount(i *int) *PlayerCreate { - if i != nil { - pc.SetVacCount(*i) +func (_c *PlayerCreate) SetNillableVacCount(v *int) *PlayerCreate { + if v != nil { + _c.SetVacCount(*v) } - return pc + return _c } // SetGameBanDate sets the "game_ban_date" field. -func (pc *PlayerCreate) SetGameBanDate(t time.Time) *PlayerCreate { - pc.mutation.SetGameBanDate(t) - return pc +func (_c *PlayerCreate) SetGameBanDate(v time.Time) *PlayerCreate { + _c.mutation.SetGameBanDate(v) + return _c } // SetNillableGameBanDate sets the "game_ban_date" field if the given value is not nil. -func (pc *PlayerCreate) SetNillableGameBanDate(t *time.Time) *PlayerCreate { - if t != nil { - pc.SetGameBanDate(*t) +func (_c *PlayerCreate) SetNillableGameBanDate(v *time.Time) *PlayerCreate { + if v != nil { + _c.SetGameBanDate(*v) } - return pc + return _c } // SetGameBanCount sets the "game_ban_count" field. -func (pc *PlayerCreate) SetGameBanCount(i int) *PlayerCreate { - pc.mutation.SetGameBanCount(i) - return pc +func (_c *PlayerCreate) SetGameBanCount(v int) *PlayerCreate { + _c.mutation.SetGameBanCount(v) + return _c } // SetNillableGameBanCount sets the "game_ban_count" field if the given value is not nil. -func (pc *PlayerCreate) SetNillableGameBanCount(i *int) *PlayerCreate { - if i != nil { - pc.SetGameBanCount(*i) +func (_c *PlayerCreate) SetNillableGameBanCount(v *int) *PlayerCreate { + if v != nil { + _c.SetGameBanCount(*v) } - return pc + return _c } // SetSteamUpdated sets the "steam_updated" field. -func (pc *PlayerCreate) SetSteamUpdated(t time.Time) *PlayerCreate { - pc.mutation.SetSteamUpdated(t) - return pc +func (_c *PlayerCreate) SetSteamUpdated(v time.Time) *PlayerCreate { + _c.mutation.SetSteamUpdated(v) + return _c } // SetNillableSteamUpdated sets the "steam_updated" field if the given value is not nil. -func (pc *PlayerCreate) SetNillableSteamUpdated(t *time.Time) *PlayerCreate { - if t != nil { - pc.SetSteamUpdated(*t) +func (_c *PlayerCreate) SetNillableSteamUpdated(v *time.Time) *PlayerCreate { + if v != nil { + _c.SetSteamUpdated(*v) } - return pc + return _c } // SetSharecodeUpdated sets the "sharecode_updated" field. -func (pc *PlayerCreate) SetSharecodeUpdated(t time.Time) *PlayerCreate { - pc.mutation.SetSharecodeUpdated(t) - return pc +func (_c *PlayerCreate) SetSharecodeUpdated(v time.Time) *PlayerCreate { + _c.mutation.SetSharecodeUpdated(v) + return _c } // SetNillableSharecodeUpdated sets the "sharecode_updated" field if the given value is not nil. -func (pc *PlayerCreate) SetNillableSharecodeUpdated(t *time.Time) *PlayerCreate { - if t != nil { - pc.SetSharecodeUpdated(*t) +func (_c *PlayerCreate) SetNillableSharecodeUpdated(v *time.Time) *PlayerCreate { + if v != nil { + _c.SetSharecodeUpdated(*v) } - return pc + return _c } // SetAuthCode sets the "auth_code" field. -func (pc *PlayerCreate) SetAuthCode(s string) *PlayerCreate { - pc.mutation.SetAuthCode(s) - return pc +func (_c *PlayerCreate) SetAuthCode(v string) *PlayerCreate { + _c.mutation.SetAuthCode(v) + return _c } // SetNillableAuthCode sets the "auth_code" field if the given value is not nil. -func (pc *PlayerCreate) SetNillableAuthCode(s *string) *PlayerCreate { - if s != nil { - pc.SetAuthCode(*s) +func (_c *PlayerCreate) SetNillableAuthCode(v *string) *PlayerCreate { + if v != nil { + _c.SetAuthCode(*v) } - return pc + return _c } // SetProfileCreated sets the "profile_created" field. -func (pc *PlayerCreate) SetProfileCreated(t time.Time) *PlayerCreate { - pc.mutation.SetProfileCreated(t) - return pc +func (_c *PlayerCreate) SetProfileCreated(v time.Time) *PlayerCreate { + _c.mutation.SetProfileCreated(v) + return _c } // SetNillableProfileCreated sets the "profile_created" field if the given value is not nil. -func (pc *PlayerCreate) SetNillableProfileCreated(t *time.Time) *PlayerCreate { - if t != nil { - pc.SetProfileCreated(*t) +func (_c *PlayerCreate) SetNillableProfileCreated(v *time.Time) *PlayerCreate { + if v != nil { + _c.SetProfileCreated(*v) } - return pc + return _c } // SetOldestSharecodeSeen sets the "oldest_sharecode_seen" field. -func (pc *PlayerCreate) SetOldestSharecodeSeen(s string) *PlayerCreate { - pc.mutation.SetOldestSharecodeSeen(s) - return pc +func (_c *PlayerCreate) SetOldestSharecodeSeen(v string) *PlayerCreate { + _c.mutation.SetOldestSharecodeSeen(v) + return _c } // SetNillableOldestSharecodeSeen sets the "oldest_sharecode_seen" field if the given value is not nil. -func (pc *PlayerCreate) SetNillableOldestSharecodeSeen(s *string) *PlayerCreate { - if s != nil { - pc.SetOldestSharecodeSeen(*s) +func (_c *PlayerCreate) SetNillableOldestSharecodeSeen(v *string) *PlayerCreate { + if v != nil { + _c.SetOldestSharecodeSeen(*v) } - return pc + return _c } // SetWins sets the "wins" field. -func (pc *PlayerCreate) SetWins(i int) *PlayerCreate { - pc.mutation.SetWins(i) - return pc +func (_c *PlayerCreate) SetWins(v int) *PlayerCreate { + _c.mutation.SetWins(v) + return _c } // SetNillableWins sets the "wins" field if the given value is not nil. -func (pc *PlayerCreate) SetNillableWins(i *int) *PlayerCreate { - if i != nil { - pc.SetWins(*i) +func (_c *PlayerCreate) SetNillableWins(v *int) *PlayerCreate { + if v != nil { + _c.SetWins(*v) } - return pc + return _c } // SetLooses sets the "looses" field. -func (pc *PlayerCreate) SetLooses(i int) *PlayerCreate { - pc.mutation.SetLooses(i) - return pc +func (_c *PlayerCreate) SetLooses(v int) *PlayerCreate { + _c.mutation.SetLooses(v) + return _c } // SetNillableLooses sets the "looses" field if the given value is not nil. -func (pc *PlayerCreate) SetNillableLooses(i *int) *PlayerCreate { - if i != nil { - pc.SetLooses(*i) +func (_c *PlayerCreate) SetNillableLooses(v *int) *PlayerCreate { + if v != nil { + _c.SetLooses(*v) } - return pc + return _c } // SetTies sets the "ties" field. -func (pc *PlayerCreate) SetTies(i int) *PlayerCreate { - pc.mutation.SetTies(i) - return pc +func (_c *PlayerCreate) SetTies(v int) *PlayerCreate { + _c.mutation.SetTies(v) + return _c } // SetNillableTies sets the "ties" field if the given value is not nil. -func (pc *PlayerCreate) SetNillableTies(i *int) *PlayerCreate { - if i != nil { - pc.SetTies(*i) +func (_c *PlayerCreate) SetNillableTies(v *int) *PlayerCreate { + if v != nil { + _c.SetTies(*v) } - return pc + return _c } // SetID sets the "id" field. -func (pc *PlayerCreate) SetID(u uint64) *PlayerCreate { - pc.mutation.SetID(u) - return pc +func (_c *PlayerCreate) SetID(v uint64) *PlayerCreate { + _c.mutation.SetID(v) + return _c } // AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs. -func (pc *PlayerCreate) AddStatIDs(ids ...int) *PlayerCreate { - pc.mutation.AddStatIDs(ids...) - return pc +func (_c *PlayerCreate) AddStatIDs(ids ...int) *PlayerCreate { + _c.mutation.AddStatIDs(ids...) + return _c } // AddStats adds the "stats" edges to the MatchPlayer entity. -func (pc *PlayerCreate) AddStats(m ...*MatchPlayer) *PlayerCreate { - ids := make([]int, len(m)) - for i := range m { - ids[i] = m[i].ID +func (_c *PlayerCreate) AddStats(v ...*MatchPlayer) *PlayerCreate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pc.AddStatIDs(ids...) + return _c.AddStatIDs(ids...) } // AddMatchIDs adds the "matches" edge to the Match entity by IDs. -func (pc *PlayerCreate) AddMatchIDs(ids ...uint64) *PlayerCreate { - pc.mutation.AddMatchIDs(ids...) - return pc +func (_c *PlayerCreate) AddMatchIDs(ids ...uint64) *PlayerCreate { + _c.mutation.AddMatchIDs(ids...) + return _c } // AddMatches adds the "matches" edges to the Match entity. -func (pc *PlayerCreate) AddMatches(m ...*Match) *PlayerCreate { - ids := make([]uint64, len(m)) - for i := range m { - ids[i] = m[i].ID +func (_c *PlayerCreate) AddMatches(v ...*Match) *PlayerCreate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pc.AddMatchIDs(ids...) + return _c.AddMatchIDs(ids...) } // Mutation returns the PlayerMutation object of the builder. -func (pc *PlayerCreate) Mutation() *PlayerMutation { - return pc.mutation +func (_c *PlayerCreate) Mutation() *PlayerMutation { + return _c.mutation } // Save creates the Player in the database. -func (pc *PlayerCreate) Save(ctx context.Context) (*Player, error) { - pc.defaults() - return withHooks(ctx, pc.sqlSave, pc.mutation, pc.hooks) +func (_c *PlayerCreate) Save(ctx context.Context) (*Player, error) { + _c.defaults() + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. -func (pc *PlayerCreate) SaveX(ctx context.Context) *Player { - v, err := pc.Save(ctx) +func (_c *PlayerCreate) SaveX(ctx context.Context) *Player { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -303,40 +303,40 @@ func (pc *PlayerCreate) SaveX(ctx context.Context) *Player { } // Exec executes the query. -func (pc *PlayerCreate) Exec(ctx context.Context) error { - _, err := pc.Save(ctx) +func (_c *PlayerCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (pc *PlayerCreate) ExecX(ctx context.Context) { - if err := pc.Exec(ctx); err != nil { +func (_c *PlayerCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } // defaults sets the default values of the builder before save. -func (pc *PlayerCreate) defaults() { - if _, ok := pc.mutation.SteamUpdated(); !ok { +func (_c *PlayerCreate) defaults() { + if _, ok := _c.mutation.SteamUpdated(); !ok { v := player.DefaultSteamUpdated() - pc.mutation.SetSteamUpdated(v) + _c.mutation.SetSteamUpdated(v) } } // check runs all checks and user-defined validators on the builder. -func (pc *PlayerCreate) check() error { - if _, ok := pc.mutation.SteamUpdated(); !ok { +func (_c *PlayerCreate) check() error { + if _, ok := _c.mutation.SteamUpdated(); !ok { return &ValidationError{Name: "steam_updated", err: errors.New(`ent: missing required field "Player.steam_updated"`)} } return nil } -func (pc *PlayerCreate) sqlSave(ctx context.Context) (*Player, error) { - if err := pc.check(); err != nil { +func (_c *PlayerCreate) sqlSave(ctx context.Context) (*Player, error) { + if err := _c.check(); err != nil { return nil, err } - _node, _spec := pc.createSpec() - if err := sqlgraph.CreateNode(ctx, pc.driver, _spec); err != nil { + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -346,85 +346,85 @@ func (pc *PlayerCreate) sqlSave(ctx context.Context) (*Player, error) { id := _spec.ID.Value.(int64) _node.ID = uint64(id) } - pc.mutation.id = &_node.ID - pc.mutation.done = true + _c.mutation.id = &_node.ID + _c.mutation.done = true return _node, nil } -func (pc *PlayerCreate) createSpec() (*Player, *sqlgraph.CreateSpec) { +func (_c *PlayerCreate) createSpec() (*Player, *sqlgraph.CreateSpec) { var ( - _node = &Player{config: pc.config} + _node = &Player{config: _c.config} _spec = sqlgraph.NewCreateSpec(player.Table, sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64)) ) - if id, ok := pc.mutation.ID(); ok { + if id, ok := _c.mutation.ID(); ok { _node.ID = id _spec.ID.Value = id } - if value, ok := pc.mutation.Name(); ok { + if value, ok := _c.mutation.Name(); ok { _spec.SetField(player.FieldName, field.TypeString, value) _node.Name = value } - if value, ok := pc.mutation.Avatar(); ok { + if value, ok := _c.mutation.Avatar(); ok { _spec.SetField(player.FieldAvatar, field.TypeString, value) _node.Avatar = value } - if value, ok := pc.mutation.VanityURL(); ok { + if value, ok := _c.mutation.VanityURL(); ok { _spec.SetField(player.FieldVanityURL, field.TypeString, value) _node.VanityURL = value } - if value, ok := pc.mutation.VanityURLReal(); ok { + if value, ok := _c.mutation.VanityURLReal(); ok { _spec.SetField(player.FieldVanityURLReal, field.TypeString, value) _node.VanityURLReal = value } - if value, ok := pc.mutation.VacDate(); ok { + if value, ok := _c.mutation.VacDate(); ok { _spec.SetField(player.FieldVacDate, field.TypeTime, value) _node.VacDate = value } - if value, ok := pc.mutation.VacCount(); ok { + if value, ok := _c.mutation.VacCount(); ok { _spec.SetField(player.FieldVacCount, field.TypeInt, value) _node.VacCount = value } - if value, ok := pc.mutation.GameBanDate(); ok { + if value, ok := _c.mutation.GameBanDate(); ok { _spec.SetField(player.FieldGameBanDate, field.TypeTime, value) _node.GameBanDate = value } - if value, ok := pc.mutation.GameBanCount(); ok { + if value, ok := _c.mutation.GameBanCount(); ok { _spec.SetField(player.FieldGameBanCount, field.TypeInt, value) _node.GameBanCount = value } - if value, ok := pc.mutation.SteamUpdated(); ok { + if value, ok := _c.mutation.SteamUpdated(); ok { _spec.SetField(player.FieldSteamUpdated, field.TypeTime, value) _node.SteamUpdated = value } - if value, ok := pc.mutation.SharecodeUpdated(); ok { + if value, ok := _c.mutation.SharecodeUpdated(); ok { _spec.SetField(player.FieldSharecodeUpdated, field.TypeTime, value) _node.SharecodeUpdated = value } - if value, ok := pc.mutation.AuthCode(); ok { + if value, ok := _c.mutation.AuthCode(); ok { _spec.SetField(player.FieldAuthCode, field.TypeString, value) _node.AuthCode = value } - if value, ok := pc.mutation.ProfileCreated(); ok { + if value, ok := _c.mutation.ProfileCreated(); ok { _spec.SetField(player.FieldProfileCreated, field.TypeTime, value) _node.ProfileCreated = value } - if value, ok := pc.mutation.OldestSharecodeSeen(); ok { + if value, ok := _c.mutation.OldestSharecodeSeen(); ok { _spec.SetField(player.FieldOldestSharecodeSeen, field.TypeString, value) _node.OldestSharecodeSeen = value } - if value, ok := pc.mutation.Wins(); ok { + if value, ok := _c.mutation.Wins(); ok { _spec.SetField(player.FieldWins, field.TypeInt, value) _node.Wins = value } - if value, ok := pc.mutation.Looses(); ok { + if value, ok := _c.mutation.Looses(); ok { _spec.SetField(player.FieldLooses, field.TypeInt, value) _node.Looses = value } - if value, ok := pc.mutation.Ties(); ok { + if value, ok := _c.mutation.Ties(); ok { _spec.SetField(player.FieldTies, field.TypeInt, value) _node.Ties = value } - if nodes := pc.mutation.StatsIDs(); len(nodes) > 0 { + if nodes := _c.mutation.StatsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -440,7 +440,7 @@ func (pc *PlayerCreate) createSpec() (*Player, *sqlgraph.CreateSpec) { } _spec.Edges = append(_spec.Edges, edge) } - if nodes := pc.mutation.MatchesIDs(); len(nodes) > 0 { + if nodes := _c.mutation.MatchesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -462,17 +462,21 @@ func (pc *PlayerCreate) createSpec() (*Player, *sqlgraph.CreateSpec) { // PlayerCreateBulk is the builder for creating many Player entities in bulk. type PlayerCreateBulk struct { config + err error builders []*PlayerCreate } // Save creates the Player entities in the database. -func (pcb *PlayerCreateBulk) Save(ctx context.Context) ([]*Player, error) { - specs := make([]*sqlgraph.CreateSpec, len(pcb.builders)) - nodes := make([]*Player, len(pcb.builders)) - mutators := make([]Mutator, len(pcb.builders)) - for i := range pcb.builders { +func (_c *PlayerCreateBulk) Save(ctx context.Context) ([]*Player, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*Player, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { func(i int, root context.Context) { - builder := pcb.builders[i] + builder := _c.builders[i] builder.defaults() var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*PlayerMutation) @@ -486,11 +490,11 @@ func (pcb *PlayerCreateBulk) Save(ctx context.Context) ([]*Player, error) { var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, pcb.builders[i+1].mutation) + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, pcb.driver, spec); err != nil { + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -514,7 +518,7 @@ func (pcb *PlayerCreateBulk) Save(ctx context.Context) ([]*Player, error) { }(i, ctx) } if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, pcb.builders[0].mutation); err != nil { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { return nil, err } } @@ -522,8 +526,8 @@ func (pcb *PlayerCreateBulk) Save(ctx context.Context) ([]*Player, error) { } // SaveX is like Save, but panics if an error occurs. -func (pcb *PlayerCreateBulk) SaveX(ctx context.Context) []*Player { - v, err := pcb.Save(ctx) +func (_c *PlayerCreateBulk) SaveX(ctx context.Context) []*Player { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -531,14 +535,14 @@ func (pcb *PlayerCreateBulk) SaveX(ctx context.Context) []*Player { } // Exec executes the query. -func (pcb *PlayerCreateBulk) Exec(ctx context.Context) error { - _, err := pcb.Save(ctx) +func (_c *PlayerCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (pcb *PlayerCreateBulk) ExecX(ctx context.Context) { - if err := pcb.Exec(ctx); err != nil { +func (_c *PlayerCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } diff --git a/ent/player_delete.go b/ent/player_delete.go index 6eb0c03..176e0fb 100644 --- a/ent/player_delete.go +++ b/ent/player_delete.go @@ -20,56 +20,56 @@ type PlayerDelete struct { } // Where appends a list predicates to the PlayerDelete builder. -func (pd *PlayerDelete) Where(ps ...predicate.Player) *PlayerDelete { - pd.mutation.Where(ps...) - return pd +func (_d *PlayerDelete) Where(ps ...predicate.Player) *PlayerDelete { + _d.mutation.Where(ps...) + return _d } // Exec executes the deletion query and returns how many vertices were deleted. -func (pd *PlayerDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, pd.sqlExec, pd.mutation, pd.hooks) +func (_d *PlayerDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) } // ExecX is like Exec, but panics if an error occurs. -func (pd *PlayerDelete) ExecX(ctx context.Context) int { - n, err := pd.Exec(ctx) +func (_d *PlayerDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) if err != nil { panic(err) } return n } -func (pd *PlayerDelete) sqlExec(ctx context.Context) (int, error) { +func (_d *PlayerDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(player.Table, sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64)) - if ps := pd.mutation.predicates; len(ps) > 0 { + if ps := _d.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - affected, err := sqlgraph.DeleteNodes(ctx, pd.driver, _spec) + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } - pd.mutation.done = true + _d.mutation.done = true return affected, err } // PlayerDeleteOne is the builder for deleting a single Player entity. type PlayerDeleteOne struct { - pd *PlayerDelete + _d *PlayerDelete } // Where appends a list predicates to the PlayerDelete builder. -func (pdo *PlayerDeleteOne) Where(ps ...predicate.Player) *PlayerDeleteOne { - pdo.pd.mutation.Where(ps...) - return pdo +func (_d *PlayerDeleteOne) Where(ps ...predicate.Player) *PlayerDeleteOne { + _d._d.mutation.Where(ps...) + return _d } // Exec executes the deletion query. -func (pdo *PlayerDeleteOne) Exec(ctx context.Context) error { - n, err := pdo.pd.Exec(ctx) +func (_d *PlayerDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) switch { case err != nil: return err @@ -81,8 +81,8 @@ func (pdo *PlayerDeleteOne) Exec(ctx context.Context) error { } // ExecX is like Exec, but panics if an error occurs. -func (pdo *PlayerDeleteOne) ExecX(ctx context.Context) { - if err := pdo.Exec(ctx); err != nil { +func (_d *PlayerDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { panic(err) } } diff --git a/ent/player_query.go b/ent/player_query.go index 5d8cbcd..d3f38a1 100644 --- a/ent/player_query.go +++ b/ent/player_query.go @@ -8,6 +8,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -33,44 +34,44 @@ type PlayerQuery struct { } // Where adds a new predicate for the PlayerQuery builder. -func (pq *PlayerQuery) Where(ps ...predicate.Player) *PlayerQuery { - pq.predicates = append(pq.predicates, ps...) - return pq +func (_q *PlayerQuery) Where(ps ...predicate.Player) *PlayerQuery { + _q.predicates = append(_q.predicates, ps...) + return _q } // Limit the number of records to be returned by this query. -func (pq *PlayerQuery) Limit(limit int) *PlayerQuery { - pq.ctx.Limit = &limit - return pq +func (_q *PlayerQuery) Limit(limit int) *PlayerQuery { + _q.ctx.Limit = &limit + return _q } // Offset to start from. -func (pq *PlayerQuery) Offset(offset int) *PlayerQuery { - pq.ctx.Offset = &offset - return pq +func (_q *PlayerQuery) Offset(offset int) *PlayerQuery { + _q.ctx.Offset = &offset + return _q } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. -func (pq *PlayerQuery) Unique(unique bool) *PlayerQuery { - pq.ctx.Unique = &unique - return pq +func (_q *PlayerQuery) Unique(unique bool) *PlayerQuery { + _q.ctx.Unique = &unique + return _q } // Order specifies how the records should be ordered. -func (pq *PlayerQuery) Order(o ...player.OrderOption) *PlayerQuery { - pq.order = append(pq.order, o...) - return pq +func (_q *PlayerQuery) Order(o ...player.OrderOption) *PlayerQuery { + _q.order = append(_q.order, o...) + return _q } // QueryStats chains the current query on the "stats" edge. -func (pq *PlayerQuery) QueryStats() *MatchPlayerQuery { - query := (&MatchPlayerClient{config: pq.config}).Query() +func (_q *PlayerQuery) QueryStats() *MatchPlayerQuery { + query := (&MatchPlayerClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := pq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := pq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -79,20 +80,20 @@ func (pq *PlayerQuery) QueryStats() *MatchPlayerQuery { sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.Edge(sqlgraph.O2M, false, player.StatsTable, player.StatsColumn), ) - fromU = sqlgraph.SetNeighbors(pq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query } // QueryMatches chains the current query on the "matches" edge. -func (pq *PlayerQuery) QueryMatches() *MatchQuery { - query := (&MatchClient{config: pq.config}).Query() +func (_q *PlayerQuery) QueryMatches() *MatchQuery { + query := (&MatchClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := pq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := pq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -101,7 +102,7 @@ func (pq *PlayerQuery) QueryMatches() *MatchQuery { sqlgraph.To(match.Table, match.FieldID), sqlgraph.Edge(sqlgraph.M2M, false, player.MatchesTable, player.MatchesPrimaryKey...), ) - fromU = sqlgraph.SetNeighbors(pq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query @@ -109,8 +110,8 @@ func (pq *PlayerQuery) QueryMatches() *MatchQuery { // First returns the first Player entity from the query. // Returns a *NotFoundError when no Player was found. -func (pq *PlayerQuery) First(ctx context.Context) (*Player, error) { - nodes, err := pq.Limit(1).All(setContextOp(ctx, pq.ctx, "First")) +func (_q *PlayerQuery) First(ctx context.Context) (*Player, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -121,8 +122,8 @@ func (pq *PlayerQuery) First(ctx context.Context) (*Player, error) { } // FirstX is like First, but panics if an error occurs. -func (pq *PlayerQuery) FirstX(ctx context.Context) *Player { - node, err := pq.First(ctx) +func (_q *PlayerQuery) FirstX(ctx context.Context) *Player { + node, err := _q.First(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -131,9 +132,9 @@ func (pq *PlayerQuery) FirstX(ctx context.Context) *Player { // FirstID returns the first Player ID from the query. // Returns a *NotFoundError when no Player ID was found. -func (pq *PlayerQuery) FirstID(ctx context.Context) (id uint64, err error) { +func (_q *PlayerQuery) FirstID(ctx context.Context) (id uint64, err error) { var ids []uint64 - if ids, err = pq.Limit(1).IDs(setContextOp(ctx, pq.ctx, "FirstID")); err != nil { + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -144,8 +145,8 @@ func (pq *PlayerQuery) FirstID(ctx context.Context) (id uint64, err error) { } // FirstIDX is like FirstID, but panics if an error occurs. -func (pq *PlayerQuery) FirstIDX(ctx context.Context) uint64 { - id, err := pq.FirstID(ctx) +func (_q *PlayerQuery) FirstIDX(ctx context.Context) uint64 { + id, err := _q.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -155,8 +156,8 @@ func (pq *PlayerQuery) FirstIDX(ctx context.Context) uint64 { // Only returns a single Player entity found by the query, ensuring it only returns one. // Returns a *NotSingularError when more than one Player entity is found. // Returns a *NotFoundError when no Player entities are found. -func (pq *PlayerQuery) Only(ctx context.Context) (*Player, error) { - nodes, err := pq.Limit(2).All(setContextOp(ctx, pq.ctx, "Only")) +func (_q *PlayerQuery) Only(ctx context.Context) (*Player, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -171,8 +172,8 @@ func (pq *PlayerQuery) Only(ctx context.Context) (*Player, error) { } // OnlyX is like Only, but panics if an error occurs. -func (pq *PlayerQuery) OnlyX(ctx context.Context) *Player { - node, err := pq.Only(ctx) +func (_q *PlayerQuery) OnlyX(ctx context.Context) *Player { + node, err := _q.Only(ctx) if err != nil { panic(err) } @@ -182,9 +183,9 @@ func (pq *PlayerQuery) OnlyX(ctx context.Context) *Player { // OnlyID is like Only, but returns the only Player ID in the query. // Returns a *NotSingularError when more than one Player ID is found. // Returns a *NotFoundError when no entities are found. -func (pq *PlayerQuery) OnlyID(ctx context.Context) (id uint64, err error) { +func (_q *PlayerQuery) OnlyID(ctx context.Context) (id uint64, err error) { var ids []uint64 - if ids, err = pq.Limit(2).IDs(setContextOp(ctx, pq.ctx, "OnlyID")); err != nil { + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -199,8 +200,8 @@ func (pq *PlayerQuery) OnlyID(ctx context.Context) (id uint64, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (pq *PlayerQuery) OnlyIDX(ctx context.Context) uint64 { - id, err := pq.OnlyID(ctx) +func (_q *PlayerQuery) OnlyIDX(ctx context.Context) uint64 { + id, err := _q.OnlyID(ctx) if err != nil { panic(err) } @@ -208,18 +209,18 @@ func (pq *PlayerQuery) OnlyIDX(ctx context.Context) uint64 { } // All executes the query and returns a list of Players. -func (pq *PlayerQuery) All(ctx context.Context) ([]*Player, error) { - ctx = setContextOp(ctx, pq.ctx, "All") - if err := pq.prepareQuery(ctx); err != nil { +func (_q *PlayerQuery) All(ctx context.Context) ([]*Player, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { return nil, err } qr := querierAll[[]*Player, *PlayerQuery]() - return withInterceptors[[]*Player](ctx, pq, qr, pq.inters) + return withInterceptors[[]*Player](ctx, _q, qr, _q.inters) } // AllX is like All, but panics if an error occurs. -func (pq *PlayerQuery) AllX(ctx context.Context) []*Player { - nodes, err := pq.All(ctx) +func (_q *PlayerQuery) AllX(ctx context.Context) []*Player { + nodes, err := _q.All(ctx) if err != nil { panic(err) } @@ -227,20 +228,20 @@ func (pq *PlayerQuery) AllX(ctx context.Context) []*Player { } // IDs executes the query and returns a list of Player IDs. -func (pq *PlayerQuery) IDs(ctx context.Context) (ids []uint64, err error) { - if pq.ctx.Unique == nil && pq.path != nil { - pq.Unique(true) +func (_q *PlayerQuery) IDs(ctx context.Context) (ids []uint64, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) } - ctx = setContextOp(ctx, pq.ctx, "IDs") - if err = pq.Select(player.FieldID).Scan(ctx, &ids); err != nil { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(player.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. -func (pq *PlayerQuery) IDsX(ctx context.Context) []uint64 { - ids, err := pq.IDs(ctx) +func (_q *PlayerQuery) IDsX(ctx context.Context) []uint64 { + ids, err := _q.IDs(ctx) if err != nil { panic(err) } @@ -248,17 +249,17 @@ func (pq *PlayerQuery) IDsX(ctx context.Context) []uint64 { } // Count returns the count of the given query. -func (pq *PlayerQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, pq.ctx, "Count") - if err := pq.prepareQuery(ctx); err != nil { +func (_q *PlayerQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { return 0, err } - return withInterceptors[int](ctx, pq, querierCount[*PlayerQuery](), pq.inters) + return withInterceptors[int](ctx, _q, querierCount[*PlayerQuery](), _q.inters) } // CountX is like Count, but panics if an error occurs. -func (pq *PlayerQuery) CountX(ctx context.Context) int { - count, err := pq.Count(ctx) +func (_q *PlayerQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) if err != nil { panic(err) } @@ -266,9 +267,9 @@ func (pq *PlayerQuery) CountX(ctx context.Context) int { } // Exist returns true if the query has elements in the graph. -func (pq *PlayerQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, pq.ctx, "Exist") - switch _, err := pq.FirstID(ctx); { +func (_q *PlayerQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { case IsNotFound(err): return false, nil case err != nil: @@ -279,8 +280,8 @@ func (pq *PlayerQuery) Exist(ctx context.Context) (bool, error) { } // ExistX is like Exist, but panics if an error occurs. -func (pq *PlayerQuery) ExistX(ctx context.Context) bool { - exist, err := pq.Exist(ctx) +func (_q *PlayerQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) if err != nil { panic(err) } @@ -289,44 +290,45 @@ func (pq *PlayerQuery) ExistX(ctx context.Context) bool { // Clone returns a duplicate of the PlayerQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. -func (pq *PlayerQuery) Clone() *PlayerQuery { - if pq == nil { +func (_q *PlayerQuery) Clone() *PlayerQuery { + if _q == nil { return nil } return &PlayerQuery{ - config: pq.config, - ctx: pq.ctx.Clone(), - order: append([]player.OrderOption{}, pq.order...), - inters: append([]Interceptor{}, pq.inters...), - predicates: append([]predicate.Player{}, pq.predicates...), - withStats: pq.withStats.Clone(), - withMatches: pq.withMatches.Clone(), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]player.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.Player{}, _q.predicates...), + withStats: _q.withStats.Clone(), + withMatches: _q.withMatches.Clone(), // clone intermediate query. - sql: pq.sql.Clone(), - path: pq.path, + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), } } // WithStats tells the query-builder to eager-load the nodes that are connected to // the "stats" edge. The optional arguments are used to configure the query builder of the edge. -func (pq *PlayerQuery) WithStats(opts ...func(*MatchPlayerQuery)) *PlayerQuery { - query := (&MatchPlayerClient{config: pq.config}).Query() +func (_q *PlayerQuery) WithStats(opts ...func(*MatchPlayerQuery)) *PlayerQuery { + query := (&MatchPlayerClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - pq.withStats = query - return pq + _q.withStats = query + return _q } // WithMatches tells the query-builder to eager-load the nodes that are connected to // the "matches" edge. The optional arguments are used to configure the query builder of the edge. -func (pq *PlayerQuery) WithMatches(opts ...func(*MatchQuery)) *PlayerQuery { - query := (&MatchClient{config: pq.config}).Query() +func (_q *PlayerQuery) WithMatches(opts ...func(*MatchQuery)) *PlayerQuery { + query := (&MatchClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - pq.withMatches = query - return pq + _q.withMatches = query + return _q } // GroupBy is used to group vertices by one or more fields/columns. @@ -343,10 +345,10 @@ 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 { - pq.ctx.Fields = append([]string{field}, fields...) - grbuild := &PlayerGroupBy{build: pq} - grbuild.flds = &pq.ctx.Fields +func (_q *PlayerQuery) GroupBy(field string, fields ...string) *PlayerGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &PlayerGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields grbuild.label = player.Label grbuild.scan = grbuild.Scan return grbuild @@ -364,84 +366,84 @@ 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.ctx.Fields = append(pq.ctx.Fields, fields...) - sbuild := &PlayerSelect{PlayerQuery: pq} +func (_q *PlayerQuery) Select(fields ...string) *PlayerSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &PlayerSelect{PlayerQuery: _q} sbuild.label = player.Label - sbuild.flds, sbuild.scan = &pq.ctx.Fields, sbuild.Scan + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan return sbuild } // Aggregate returns a PlayerSelect configured with the given aggregations. -func (pq *PlayerQuery) Aggregate(fns ...AggregateFunc) *PlayerSelect { - return pq.Select().Aggregate(fns...) +func (_q *PlayerQuery) Aggregate(fns ...AggregateFunc) *PlayerSelect { + return _q.Select().Aggregate(fns...) } -func (pq *PlayerQuery) prepareQuery(ctx context.Context) error { - for _, inter := range pq.inters { +func (_q *PlayerQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { if inter == nil { return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") } if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, pq); err != nil { + if err := trv.Traverse(ctx, _q); err != nil { return err } } } - for _, f := range pq.ctx.Fields { + for _, f := range _q.ctx.Fields { if !player.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } - if pq.path != nil { - prev, err := pq.path(ctx) + if _q.path != nil { + prev, err := _q.path(ctx) if err != nil { return err } - pq.sql = prev + _q.sql = prev } return nil } -func (pq *PlayerQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Player, error) { +func (_q *PlayerQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Player, error) { var ( nodes = []*Player{} - _spec = pq.querySpec() + _spec = _q.querySpec() loadedTypes = [2]bool{ - pq.withStats != nil, - pq.withMatches != nil, + _q.withStats != nil, + _q.withMatches != nil, } ) _spec.ScanValues = func(columns []string) ([]any, error) { return (*Player).scanValues(nil, columns) } _spec.Assign = func(columns []string, values []any) error { - node := &Player{config: pq.config} + node := &Player{config: _q.config} nodes = append(nodes, node) node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) } - if len(pq.modifiers) > 0 { - _spec.Modifiers = pq.modifiers + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } for i := range hooks { hooks[i](ctx, _spec) } - if err := sqlgraph.QueryNodes(ctx, pq.driver, _spec); err != nil { + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { return nil, err } if len(nodes) == 0 { return nodes, nil } - if query := pq.withStats; query != nil { - if err := pq.loadStats(ctx, query, nodes, + if query := _q.withStats; query != nil { + if err := _q.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 } } - if query := pq.withMatches; query != nil { - if err := pq.loadMatches(ctx, query, nodes, + if query := _q.withMatches; query != nil { + if err := _q.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 @@ -450,7 +452,7 @@ func (pq *PlayerQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Playe return nodes, nil } -func (pq *PlayerQuery) loadStats(ctx context.Context, query *MatchPlayerQuery, nodes []*Player, init func(*Player), assign func(*Player, *MatchPlayer)) error { +func (_q *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 { @@ -480,7 +482,7 @@ func (pq *PlayerQuery) loadStats(ctx context.Context, query *MatchPlayerQuery, n } return nil } -func (pq *PlayerQuery) loadMatches(ctx context.Context, query *MatchQuery, nodes []*Player, init func(*Player), assign func(*Player, *Match)) error { +func (_q *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{}) @@ -542,27 +544,27 @@ func (pq *PlayerQuery) loadMatches(ctx context.Context, query *MatchQuery, nodes return nil } -func (pq *PlayerQuery) sqlCount(ctx context.Context) (int, error) { - _spec := pq.querySpec() - if len(pq.modifiers) > 0 { - _spec.Modifiers = pq.modifiers +func (_q *PlayerQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } - _spec.Node.Columns = pq.ctx.Fields - if len(pq.ctx.Fields) > 0 { - _spec.Unique = pq.ctx.Unique != nil && *pq.ctx.Unique + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique } - return sqlgraph.CountNodes(ctx, pq.driver, _spec) + return sqlgraph.CountNodes(ctx, _q.driver, _spec) } -func (pq *PlayerQuery) querySpec() *sqlgraph.QuerySpec { +func (_q *PlayerQuery) querySpec() *sqlgraph.QuerySpec { _spec := sqlgraph.NewQuerySpec(player.Table, player.Columns, sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64)) - _spec.From = pq.sql - if unique := pq.ctx.Unique; unique != nil { + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { _spec.Unique = *unique - } else if pq.path != nil { + } else if _q.path != nil { _spec.Unique = true } - if fields := pq.ctx.Fields; len(fields) > 0 { + if fields := _q.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, player.FieldID) for i := range fields { @@ -571,20 +573,20 @@ func (pq *PlayerQuery) querySpec() *sqlgraph.QuerySpec { } } } - if ps := pq.predicates; len(ps) > 0 { + if ps := _q.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if limit := pq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := pq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { _spec.Offset = *offset } - if ps := pq.order; len(ps) > 0 { + if ps := _q.order; len(ps) > 0 { _spec.Order = func(selector *sql.Selector) { for i := range ps { ps[i](selector) @@ -594,45 +596,45 @@ func (pq *PlayerQuery) querySpec() *sqlgraph.QuerySpec { return _spec } -func (pq *PlayerQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(pq.driver.Dialect()) +func (_q *PlayerQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) t1 := builder.Table(player.Table) - columns := pq.ctx.Fields + columns := _q.ctx.Fields if len(columns) == 0 { columns = player.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) - if pq.sql != nil { - selector = pq.sql + if _q.sql != nil { + selector = _q.sql selector.Select(selector.Columns(columns...)...) } - if pq.ctx.Unique != nil && *pq.ctx.Unique { + if _q.ctx.Unique != nil && *_q.ctx.Unique { selector.Distinct() } - for _, m := range pq.modifiers { + for _, m := range _q.modifiers { m(selector) } - for _, p := range pq.predicates { + for _, p := range _q.predicates { p(selector) } - for _, p := range pq.order { + for _, p := range _q.order { p(selector) } - if offset := pq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { // limit is mandatory for offset clause. We start // with default value, and override it below if needed. selector.Offset(*offset).Limit(math.MaxInt32) } - if limit := pq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector } // Modify adds a query modifier for attaching custom logic to queries. -func (pq *PlayerQuery) Modify(modifiers ...func(s *sql.Selector)) *PlayerSelect { - pq.modifiers = append(pq.modifiers, modifiers...) - return pq.Select() +func (_q *PlayerQuery) Modify(modifiers ...func(s *sql.Selector)) *PlayerSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() } // PlayerGroupBy is the group-by builder for Player entities. @@ -642,41 +644,41 @@ type PlayerGroupBy struct { } // Aggregate adds the given aggregation functions to the group-by query. -func (pgb *PlayerGroupBy) Aggregate(fns ...AggregateFunc) *PlayerGroupBy { - pgb.fns = append(pgb.fns, fns...) - return pgb +func (_g *PlayerGroupBy) Aggregate(fns ...AggregateFunc) *PlayerGroupBy { + _g.fns = append(_g.fns, fns...) + return _g } // Scan applies the selector query and scans the result into the given value. -func (pgb *PlayerGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, pgb.build.ctx, "GroupBy") - if err := pgb.build.prepareQuery(ctx); err != nil { +func (_g *PlayerGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*PlayerQuery, *PlayerGroupBy](ctx, pgb.build, pgb, pgb.build.inters, v) + return scanWithInterceptors[*PlayerQuery, *PlayerGroupBy](ctx, _g.build, _g, _g.build.inters, v) } -func (pgb *PlayerGroupBy) sqlScan(ctx context.Context, root *PlayerQuery, v any) error { +func (_g *PlayerGroupBy) sqlScan(ctx context.Context, root *PlayerQuery, v any) error { selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(pgb.fns)) - for _, fn := range pgb.fns { + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { aggregation = append(aggregation, fn(selector)) } if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*pgb.flds)+len(pgb.fns)) - for _, f := range *pgb.flds { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { columns = append(columns, selector.C(f)) } columns = append(columns, aggregation...) selector.Select(columns...) } - selector.GroupBy(selector.Columns(*pgb.flds...)...) + selector.GroupBy(selector.Columns(*_g.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := pgb.build.driver.Query(ctx, query, args, rows); err != nil { + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -690,27 +692,27 @@ type PlayerSelect struct { } // Aggregate adds the given aggregation functions to the selector query. -func (ps *PlayerSelect) Aggregate(fns ...AggregateFunc) *PlayerSelect { - ps.fns = append(ps.fns, fns...) - return ps +func (_s *PlayerSelect) Aggregate(fns ...AggregateFunc) *PlayerSelect { + _s.fns = append(_s.fns, fns...) + return _s } // Scan applies the selector query and scans the result into the given value. -func (ps *PlayerSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ps.ctx, "Select") - if err := ps.prepareQuery(ctx); err != nil { +func (_s *PlayerSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*PlayerQuery, *PlayerSelect](ctx, ps.PlayerQuery, ps, ps.inters, v) + return scanWithInterceptors[*PlayerQuery, *PlayerSelect](ctx, _s.PlayerQuery, _s, _s.inters, v) } -func (ps *PlayerSelect) sqlScan(ctx context.Context, root *PlayerQuery, v any) error { +func (_s *PlayerSelect) sqlScan(ctx context.Context, root *PlayerQuery, v any) error { selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(ps.fns)) - for _, fn := range ps.fns { + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { aggregation = append(aggregation, fn(selector)) } - switch n := len(*ps.selector.flds); { + switch n := len(*_s.selector.flds); { case n == 0 && len(aggregation) > 0: selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: @@ -718,7 +720,7 @@ func (ps *PlayerSelect) sqlScan(ctx context.Context, root *PlayerQuery, v any) e } rows := &sql.Rows{} query, args := selector.Query() - if err := ps.driver.Query(ctx, query, args, rows); err != nil { + if err := _s.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -726,7 +728,7 @@ func (ps *PlayerSelect) sqlScan(ctx context.Context, root *PlayerQuery, v any) e } // Modify adds a query modifier for attaching custom logic to queries. -func (ps *PlayerSelect) Modify(modifiers ...func(s *sql.Selector)) *PlayerSelect { - ps.modifiers = append(ps.modifiers, modifiers...) - return ps +func (_s *PlayerSelect) Modify(modifiers ...func(s *sql.Selector)) *PlayerSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s } diff --git a/ent/player_update.go b/ent/player_update.go index 2110606..ae1ff55 100644 --- a/ent/player_update.go +++ b/ent/player_update.go @@ -26,445 +26,445 @@ type PlayerUpdate struct { } // Where appends a list predicates to the PlayerUpdate builder. -func (pu *PlayerUpdate) Where(ps ...predicate.Player) *PlayerUpdate { - pu.mutation.Where(ps...) - return pu +func (_u *PlayerUpdate) Where(ps ...predicate.Player) *PlayerUpdate { + _u.mutation.Where(ps...) + return _u } // SetName sets the "name" field. -func (pu *PlayerUpdate) SetName(s string) *PlayerUpdate { - pu.mutation.SetName(s) - return pu +func (_u *PlayerUpdate) SetName(v string) *PlayerUpdate { + _u.mutation.SetName(v) + return _u } // SetNillableName sets the "name" field if the given value is not nil. -func (pu *PlayerUpdate) SetNillableName(s *string) *PlayerUpdate { - if s != nil { - pu.SetName(*s) +func (_u *PlayerUpdate) SetNillableName(v *string) *PlayerUpdate { + if v != nil { + _u.SetName(*v) } - return pu + return _u } // ClearName clears the value of the "name" field. -func (pu *PlayerUpdate) ClearName() *PlayerUpdate { - pu.mutation.ClearName() - return pu +func (_u *PlayerUpdate) ClearName() *PlayerUpdate { + _u.mutation.ClearName() + return _u } // SetAvatar sets the "avatar" field. -func (pu *PlayerUpdate) SetAvatar(s string) *PlayerUpdate { - pu.mutation.SetAvatar(s) - return pu +func (_u *PlayerUpdate) SetAvatar(v string) *PlayerUpdate { + _u.mutation.SetAvatar(v) + return _u } // SetNillableAvatar sets the "avatar" field if the given value is not nil. -func (pu *PlayerUpdate) SetNillableAvatar(s *string) *PlayerUpdate { - if s != nil { - pu.SetAvatar(*s) +func (_u *PlayerUpdate) SetNillableAvatar(v *string) *PlayerUpdate { + if v != nil { + _u.SetAvatar(*v) } - return pu + return _u } // ClearAvatar clears the value of the "avatar" field. -func (pu *PlayerUpdate) ClearAvatar() *PlayerUpdate { - pu.mutation.ClearAvatar() - return pu +func (_u *PlayerUpdate) ClearAvatar() *PlayerUpdate { + _u.mutation.ClearAvatar() + return _u } // SetVanityURL sets the "vanity_url" field. -func (pu *PlayerUpdate) SetVanityURL(s string) *PlayerUpdate { - pu.mutation.SetVanityURL(s) - return pu +func (_u *PlayerUpdate) SetVanityURL(v string) *PlayerUpdate { + _u.mutation.SetVanityURL(v) + return _u } // SetNillableVanityURL sets the "vanity_url" field if the given value is not nil. -func (pu *PlayerUpdate) SetNillableVanityURL(s *string) *PlayerUpdate { - if s != nil { - pu.SetVanityURL(*s) +func (_u *PlayerUpdate) SetNillableVanityURL(v *string) *PlayerUpdate { + if v != nil { + _u.SetVanityURL(*v) } - return pu + return _u } // ClearVanityURL clears the value of the "vanity_url" field. -func (pu *PlayerUpdate) ClearVanityURL() *PlayerUpdate { - pu.mutation.ClearVanityURL() - return pu +func (_u *PlayerUpdate) ClearVanityURL() *PlayerUpdate { + _u.mutation.ClearVanityURL() + return _u } // SetVanityURLReal sets the "vanity_url_real" field. -func (pu *PlayerUpdate) SetVanityURLReal(s string) *PlayerUpdate { - pu.mutation.SetVanityURLReal(s) - return pu +func (_u *PlayerUpdate) SetVanityURLReal(v string) *PlayerUpdate { + _u.mutation.SetVanityURLReal(v) + return _u } // SetNillableVanityURLReal sets the "vanity_url_real" field if the given value is not nil. -func (pu *PlayerUpdate) SetNillableVanityURLReal(s *string) *PlayerUpdate { - if s != nil { - pu.SetVanityURLReal(*s) +func (_u *PlayerUpdate) SetNillableVanityURLReal(v *string) *PlayerUpdate { + if v != nil { + _u.SetVanityURLReal(*v) } - return pu + return _u } // ClearVanityURLReal clears the value of the "vanity_url_real" field. -func (pu *PlayerUpdate) ClearVanityURLReal() *PlayerUpdate { - pu.mutation.ClearVanityURLReal() - return pu +func (_u *PlayerUpdate) ClearVanityURLReal() *PlayerUpdate { + _u.mutation.ClearVanityURLReal() + return _u } // SetVacDate sets the "vac_date" field. -func (pu *PlayerUpdate) SetVacDate(t time.Time) *PlayerUpdate { - pu.mutation.SetVacDate(t) - return pu +func (_u *PlayerUpdate) SetVacDate(v time.Time) *PlayerUpdate { + _u.mutation.SetVacDate(v) + return _u } // SetNillableVacDate sets the "vac_date" field if the given value is not nil. -func (pu *PlayerUpdate) SetNillableVacDate(t *time.Time) *PlayerUpdate { - if t != nil { - pu.SetVacDate(*t) +func (_u *PlayerUpdate) SetNillableVacDate(v *time.Time) *PlayerUpdate { + if v != nil { + _u.SetVacDate(*v) } - return pu + return _u } // ClearVacDate clears the value of the "vac_date" field. -func (pu *PlayerUpdate) ClearVacDate() *PlayerUpdate { - pu.mutation.ClearVacDate() - return pu +func (_u *PlayerUpdate) ClearVacDate() *PlayerUpdate { + _u.mutation.ClearVacDate() + return _u } // SetVacCount sets the "vac_count" field. -func (pu *PlayerUpdate) SetVacCount(i int) *PlayerUpdate { - pu.mutation.ResetVacCount() - pu.mutation.SetVacCount(i) - return pu +func (_u *PlayerUpdate) SetVacCount(v int) *PlayerUpdate { + _u.mutation.ResetVacCount() + _u.mutation.SetVacCount(v) + return _u } // SetNillableVacCount sets the "vac_count" field if the given value is not nil. -func (pu *PlayerUpdate) SetNillableVacCount(i *int) *PlayerUpdate { - if i != nil { - pu.SetVacCount(*i) +func (_u *PlayerUpdate) SetNillableVacCount(v *int) *PlayerUpdate { + if v != nil { + _u.SetVacCount(*v) } - return pu + return _u } -// AddVacCount adds i to the "vac_count" field. -func (pu *PlayerUpdate) AddVacCount(i int) *PlayerUpdate { - pu.mutation.AddVacCount(i) - return pu +// AddVacCount adds value to the "vac_count" field. +func (_u *PlayerUpdate) AddVacCount(v int) *PlayerUpdate { + _u.mutation.AddVacCount(v) + return _u } // ClearVacCount clears the value of the "vac_count" field. -func (pu *PlayerUpdate) ClearVacCount() *PlayerUpdate { - pu.mutation.ClearVacCount() - return pu +func (_u *PlayerUpdate) ClearVacCount() *PlayerUpdate { + _u.mutation.ClearVacCount() + return _u } // SetGameBanDate sets the "game_ban_date" field. -func (pu *PlayerUpdate) SetGameBanDate(t time.Time) *PlayerUpdate { - pu.mutation.SetGameBanDate(t) - return pu +func (_u *PlayerUpdate) SetGameBanDate(v time.Time) *PlayerUpdate { + _u.mutation.SetGameBanDate(v) + return _u } // SetNillableGameBanDate sets the "game_ban_date" field if the given value is not nil. -func (pu *PlayerUpdate) SetNillableGameBanDate(t *time.Time) *PlayerUpdate { - if t != nil { - pu.SetGameBanDate(*t) +func (_u *PlayerUpdate) SetNillableGameBanDate(v *time.Time) *PlayerUpdate { + if v != nil { + _u.SetGameBanDate(*v) } - return pu + return _u } // ClearGameBanDate clears the value of the "game_ban_date" field. -func (pu *PlayerUpdate) ClearGameBanDate() *PlayerUpdate { - pu.mutation.ClearGameBanDate() - return pu +func (_u *PlayerUpdate) ClearGameBanDate() *PlayerUpdate { + _u.mutation.ClearGameBanDate() + return _u } // SetGameBanCount sets the "game_ban_count" field. -func (pu *PlayerUpdate) SetGameBanCount(i int) *PlayerUpdate { - pu.mutation.ResetGameBanCount() - pu.mutation.SetGameBanCount(i) - return pu +func (_u *PlayerUpdate) SetGameBanCount(v int) *PlayerUpdate { + _u.mutation.ResetGameBanCount() + _u.mutation.SetGameBanCount(v) + return _u } // SetNillableGameBanCount sets the "game_ban_count" field if the given value is not nil. -func (pu *PlayerUpdate) SetNillableGameBanCount(i *int) *PlayerUpdate { - if i != nil { - pu.SetGameBanCount(*i) +func (_u *PlayerUpdate) SetNillableGameBanCount(v *int) *PlayerUpdate { + if v != nil { + _u.SetGameBanCount(*v) } - return pu + return _u } -// AddGameBanCount adds i to the "game_ban_count" field. -func (pu *PlayerUpdate) AddGameBanCount(i int) *PlayerUpdate { - pu.mutation.AddGameBanCount(i) - return pu +// AddGameBanCount adds value to the "game_ban_count" field. +func (_u *PlayerUpdate) AddGameBanCount(v int) *PlayerUpdate { + _u.mutation.AddGameBanCount(v) + return _u } // ClearGameBanCount clears the value of the "game_ban_count" field. -func (pu *PlayerUpdate) ClearGameBanCount() *PlayerUpdate { - pu.mutation.ClearGameBanCount() - return pu +func (_u *PlayerUpdate) ClearGameBanCount() *PlayerUpdate { + _u.mutation.ClearGameBanCount() + return _u } // SetSteamUpdated sets the "steam_updated" field. -func (pu *PlayerUpdate) SetSteamUpdated(t time.Time) *PlayerUpdate { - pu.mutation.SetSteamUpdated(t) - return pu +func (_u *PlayerUpdate) SetSteamUpdated(v time.Time) *PlayerUpdate { + _u.mutation.SetSteamUpdated(v) + return _u } // SetNillableSteamUpdated sets the "steam_updated" field if the given value is not nil. -func (pu *PlayerUpdate) SetNillableSteamUpdated(t *time.Time) *PlayerUpdate { - if t != nil { - pu.SetSteamUpdated(*t) +func (_u *PlayerUpdate) SetNillableSteamUpdated(v *time.Time) *PlayerUpdate { + if v != nil { + _u.SetSteamUpdated(*v) } - return pu + return _u } // SetSharecodeUpdated sets the "sharecode_updated" field. -func (pu *PlayerUpdate) SetSharecodeUpdated(t time.Time) *PlayerUpdate { - pu.mutation.SetSharecodeUpdated(t) - return pu +func (_u *PlayerUpdate) SetSharecodeUpdated(v time.Time) *PlayerUpdate { + _u.mutation.SetSharecodeUpdated(v) + return _u } // SetNillableSharecodeUpdated sets the "sharecode_updated" field if the given value is not nil. -func (pu *PlayerUpdate) SetNillableSharecodeUpdated(t *time.Time) *PlayerUpdate { - if t != nil { - pu.SetSharecodeUpdated(*t) +func (_u *PlayerUpdate) SetNillableSharecodeUpdated(v *time.Time) *PlayerUpdate { + if v != nil { + _u.SetSharecodeUpdated(*v) } - return pu + return _u } // ClearSharecodeUpdated clears the value of the "sharecode_updated" field. -func (pu *PlayerUpdate) ClearSharecodeUpdated() *PlayerUpdate { - pu.mutation.ClearSharecodeUpdated() - return pu +func (_u *PlayerUpdate) ClearSharecodeUpdated() *PlayerUpdate { + _u.mutation.ClearSharecodeUpdated() + return _u } // SetAuthCode sets the "auth_code" field. -func (pu *PlayerUpdate) SetAuthCode(s string) *PlayerUpdate { - pu.mutation.SetAuthCode(s) - return pu +func (_u *PlayerUpdate) SetAuthCode(v string) *PlayerUpdate { + _u.mutation.SetAuthCode(v) + return _u } // SetNillableAuthCode sets the "auth_code" field if the given value is not nil. -func (pu *PlayerUpdate) SetNillableAuthCode(s *string) *PlayerUpdate { - if s != nil { - pu.SetAuthCode(*s) +func (_u *PlayerUpdate) SetNillableAuthCode(v *string) *PlayerUpdate { + if v != nil { + _u.SetAuthCode(*v) } - return pu + return _u } // ClearAuthCode clears the value of the "auth_code" field. -func (pu *PlayerUpdate) ClearAuthCode() *PlayerUpdate { - pu.mutation.ClearAuthCode() - return pu +func (_u *PlayerUpdate) ClearAuthCode() *PlayerUpdate { + _u.mutation.ClearAuthCode() + return _u } // SetProfileCreated sets the "profile_created" field. -func (pu *PlayerUpdate) SetProfileCreated(t time.Time) *PlayerUpdate { - pu.mutation.SetProfileCreated(t) - return pu +func (_u *PlayerUpdate) SetProfileCreated(v time.Time) *PlayerUpdate { + _u.mutation.SetProfileCreated(v) + return _u } // SetNillableProfileCreated sets the "profile_created" field if the given value is not nil. -func (pu *PlayerUpdate) SetNillableProfileCreated(t *time.Time) *PlayerUpdate { - if t != nil { - pu.SetProfileCreated(*t) +func (_u *PlayerUpdate) SetNillableProfileCreated(v *time.Time) *PlayerUpdate { + if v != nil { + _u.SetProfileCreated(*v) } - return pu + return _u } // ClearProfileCreated clears the value of the "profile_created" field. -func (pu *PlayerUpdate) ClearProfileCreated() *PlayerUpdate { - pu.mutation.ClearProfileCreated() - return pu +func (_u *PlayerUpdate) ClearProfileCreated() *PlayerUpdate { + _u.mutation.ClearProfileCreated() + return _u } // SetOldestSharecodeSeen sets the "oldest_sharecode_seen" field. -func (pu *PlayerUpdate) SetOldestSharecodeSeen(s string) *PlayerUpdate { - pu.mutation.SetOldestSharecodeSeen(s) - return pu +func (_u *PlayerUpdate) SetOldestSharecodeSeen(v string) *PlayerUpdate { + _u.mutation.SetOldestSharecodeSeen(v) + return _u } // SetNillableOldestSharecodeSeen sets the "oldest_sharecode_seen" field if the given value is not nil. -func (pu *PlayerUpdate) SetNillableOldestSharecodeSeen(s *string) *PlayerUpdate { - if s != nil { - pu.SetOldestSharecodeSeen(*s) +func (_u *PlayerUpdate) SetNillableOldestSharecodeSeen(v *string) *PlayerUpdate { + if v != nil { + _u.SetOldestSharecodeSeen(*v) } - return pu + return _u } // ClearOldestSharecodeSeen clears the value of the "oldest_sharecode_seen" field. -func (pu *PlayerUpdate) ClearOldestSharecodeSeen() *PlayerUpdate { - pu.mutation.ClearOldestSharecodeSeen() - return pu +func (_u *PlayerUpdate) ClearOldestSharecodeSeen() *PlayerUpdate { + _u.mutation.ClearOldestSharecodeSeen() + return _u } // SetWins sets the "wins" field. -func (pu *PlayerUpdate) SetWins(i int) *PlayerUpdate { - pu.mutation.ResetWins() - pu.mutation.SetWins(i) - return pu +func (_u *PlayerUpdate) SetWins(v int) *PlayerUpdate { + _u.mutation.ResetWins() + _u.mutation.SetWins(v) + return _u } // SetNillableWins sets the "wins" field if the given value is not nil. -func (pu *PlayerUpdate) SetNillableWins(i *int) *PlayerUpdate { - if i != nil { - pu.SetWins(*i) +func (_u *PlayerUpdate) SetNillableWins(v *int) *PlayerUpdate { + if v != nil { + _u.SetWins(*v) } - return pu + return _u } -// AddWins adds i to the "wins" field. -func (pu *PlayerUpdate) AddWins(i int) *PlayerUpdate { - pu.mutation.AddWins(i) - return pu +// AddWins adds value to the "wins" field. +func (_u *PlayerUpdate) AddWins(v int) *PlayerUpdate { + _u.mutation.AddWins(v) + return _u } // ClearWins clears the value of the "wins" field. -func (pu *PlayerUpdate) ClearWins() *PlayerUpdate { - pu.mutation.ClearWins() - return pu +func (_u *PlayerUpdate) ClearWins() *PlayerUpdate { + _u.mutation.ClearWins() + return _u } // SetLooses sets the "looses" field. -func (pu *PlayerUpdate) SetLooses(i int) *PlayerUpdate { - pu.mutation.ResetLooses() - pu.mutation.SetLooses(i) - return pu +func (_u *PlayerUpdate) SetLooses(v int) *PlayerUpdate { + _u.mutation.ResetLooses() + _u.mutation.SetLooses(v) + return _u } // SetNillableLooses sets the "looses" field if the given value is not nil. -func (pu *PlayerUpdate) SetNillableLooses(i *int) *PlayerUpdate { - if i != nil { - pu.SetLooses(*i) +func (_u *PlayerUpdate) SetNillableLooses(v *int) *PlayerUpdate { + if v != nil { + _u.SetLooses(*v) } - return pu + return _u } -// AddLooses adds i to the "looses" field. -func (pu *PlayerUpdate) AddLooses(i int) *PlayerUpdate { - pu.mutation.AddLooses(i) - return pu +// AddLooses adds value to the "looses" field. +func (_u *PlayerUpdate) AddLooses(v int) *PlayerUpdate { + _u.mutation.AddLooses(v) + return _u } // ClearLooses clears the value of the "looses" field. -func (pu *PlayerUpdate) ClearLooses() *PlayerUpdate { - pu.mutation.ClearLooses() - return pu +func (_u *PlayerUpdate) ClearLooses() *PlayerUpdate { + _u.mutation.ClearLooses() + return _u } // SetTies sets the "ties" field. -func (pu *PlayerUpdate) SetTies(i int) *PlayerUpdate { - pu.mutation.ResetTies() - pu.mutation.SetTies(i) - return pu +func (_u *PlayerUpdate) SetTies(v int) *PlayerUpdate { + _u.mutation.ResetTies() + _u.mutation.SetTies(v) + return _u } // SetNillableTies sets the "ties" field if the given value is not nil. -func (pu *PlayerUpdate) SetNillableTies(i *int) *PlayerUpdate { - if i != nil { - pu.SetTies(*i) +func (_u *PlayerUpdate) SetNillableTies(v *int) *PlayerUpdate { + if v != nil { + _u.SetTies(*v) } - return pu + return _u } -// AddTies adds i to the "ties" field. -func (pu *PlayerUpdate) AddTies(i int) *PlayerUpdate { - pu.mutation.AddTies(i) - return pu +// AddTies adds value to the "ties" field. +func (_u *PlayerUpdate) AddTies(v int) *PlayerUpdate { + _u.mutation.AddTies(v) + return _u } // ClearTies clears the value of the "ties" field. -func (pu *PlayerUpdate) ClearTies() *PlayerUpdate { - pu.mutation.ClearTies() - return pu +func (_u *PlayerUpdate) ClearTies() *PlayerUpdate { + _u.mutation.ClearTies() + return _u } // AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs. -func (pu *PlayerUpdate) AddStatIDs(ids ...int) *PlayerUpdate { - pu.mutation.AddStatIDs(ids...) - return pu +func (_u *PlayerUpdate) AddStatIDs(ids ...int) *PlayerUpdate { + _u.mutation.AddStatIDs(ids...) + return _u } // AddStats adds the "stats" edges to the MatchPlayer entity. -func (pu *PlayerUpdate) AddStats(m ...*MatchPlayer) *PlayerUpdate { - ids := make([]int, len(m)) - for i := range m { - ids[i] = m[i].ID +func (_u *PlayerUpdate) AddStats(v ...*MatchPlayer) *PlayerUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pu.AddStatIDs(ids...) + return _u.AddStatIDs(ids...) } // AddMatchIDs adds the "matches" edge to the Match entity by IDs. -func (pu *PlayerUpdate) AddMatchIDs(ids ...uint64) *PlayerUpdate { - pu.mutation.AddMatchIDs(ids...) - return pu +func (_u *PlayerUpdate) AddMatchIDs(ids ...uint64) *PlayerUpdate { + _u.mutation.AddMatchIDs(ids...) + return _u } // AddMatches adds the "matches" edges to the Match entity. -func (pu *PlayerUpdate) AddMatches(m ...*Match) *PlayerUpdate { - ids := make([]uint64, len(m)) - for i := range m { - ids[i] = m[i].ID +func (_u *PlayerUpdate) AddMatches(v ...*Match) *PlayerUpdate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pu.AddMatchIDs(ids...) + return _u.AddMatchIDs(ids...) } // Mutation returns the PlayerMutation object of the builder. -func (pu *PlayerUpdate) Mutation() *PlayerMutation { - return pu.mutation +func (_u *PlayerUpdate) Mutation() *PlayerMutation { + return _u.mutation } // ClearStats clears all "stats" edges to the MatchPlayer entity. -func (pu *PlayerUpdate) ClearStats() *PlayerUpdate { - pu.mutation.ClearStats() - return pu +func (_u *PlayerUpdate) ClearStats() *PlayerUpdate { + _u.mutation.ClearStats() + return _u } // RemoveStatIDs removes the "stats" edge to MatchPlayer entities by IDs. -func (pu *PlayerUpdate) RemoveStatIDs(ids ...int) *PlayerUpdate { - pu.mutation.RemoveStatIDs(ids...) - return pu +func (_u *PlayerUpdate) RemoveStatIDs(ids ...int) *PlayerUpdate { + _u.mutation.RemoveStatIDs(ids...) + return _u } // RemoveStats removes "stats" edges to MatchPlayer entities. -func (pu *PlayerUpdate) RemoveStats(m ...*MatchPlayer) *PlayerUpdate { - ids := make([]int, len(m)) - for i := range m { - ids[i] = m[i].ID +func (_u *PlayerUpdate) RemoveStats(v ...*MatchPlayer) *PlayerUpdate { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pu.RemoveStatIDs(ids...) + return _u.RemoveStatIDs(ids...) } // ClearMatches clears all "matches" edges to the Match entity. -func (pu *PlayerUpdate) ClearMatches() *PlayerUpdate { - pu.mutation.ClearMatches() - return pu +func (_u *PlayerUpdate) ClearMatches() *PlayerUpdate { + _u.mutation.ClearMatches() + return _u } // RemoveMatchIDs removes the "matches" edge to Match entities by IDs. -func (pu *PlayerUpdate) RemoveMatchIDs(ids ...uint64) *PlayerUpdate { - pu.mutation.RemoveMatchIDs(ids...) - return pu +func (_u *PlayerUpdate) RemoveMatchIDs(ids ...uint64) *PlayerUpdate { + _u.mutation.RemoveMatchIDs(ids...) + return _u } // RemoveMatches removes "matches" edges to Match entities. -func (pu *PlayerUpdate) RemoveMatches(m ...*Match) *PlayerUpdate { - ids := make([]uint64, len(m)) - for i := range m { - ids[i] = m[i].ID +func (_u *PlayerUpdate) RemoveMatches(v ...*Match) *PlayerUpdate { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return pu.RemoveMatchIDs(ids...) + return _u.RemoveMatchIDs(ids...) } // Save executes the query and returns the number of nodes affected by the update operation. -func (pu *PlayerUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, pu.sqlSave, pu.mutation, pu.hooks) +func (_u *PlayerUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (pu *PlayerUpdate) SaveX(ctx context.Context) int { - affected, err := pu.Save(ctx) +func (_u *PlayerUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) if err != nil { panic(err) } @@ -472,142 +472,142 @@ func (pu *PlayerUpdate) SaveX(ctx context.Context) int { } // Exec executes the query. -func (pu *PlayerUpdate) Exec(ctx context.Context) error { - _, err := pu.Save(ctx) +func (_u *PlayerUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (pu *PlayerUpdate) ExecX(ctx context.Context) { - if err := pu.Exec(ctx); err != nil { +func (_u *PlayerUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // 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 (_u *PlayerUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PlayerUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { +func (_u *PlayerUpdate) sqlSave(ctx context.Context) (_node int, err error) { _spec := sqlgraph.NewUpdateSpec(player.Table, player.Columns, sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64)) - if ps := pu.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := pu.mutation.Name(); ok { + if value, ok := _u.mutation.Name(); ok { _spec.SetField(player.FieldName, field.TypeString, value) } - if pu.mutation.NameCleared() { + if _u.mutation.NameCleared() { _spec.ClearField(player.FieldName, field.TypeString) } - if value, ok := pu.mutation.Avatar(); ok { + if value, ok := _u.mutation.Avatar(); ok { _spec.SetField(player.FieldAvatar, field.TypeString, value) } - if pu.mutation.AvatarCleared() { + if _u.mutation.AvatarCleared() { _spec.ClearField(player.FieldAvatar, field.TypeString) } - if value, ok := pu.mutation.VanityURL(); ok { + if value, ok := _u.mutation.VanityURL(); ok { _spec.SetField(player.FieldVanityURL, field.TypeString, value) } - if pu.mutation.VanityURLCleared() { + if _u.mutation.VanityURLCleared() { _spec.ClearField(player.FieldVanityURL, field.TypeString) } - if value, ok := pu.mutation.VanityURLReal(); ok { + if value, ok := _u.mutation.VanityURLReal(); ok { _spec.SetField(player.FieldVanityURLReal, field.TypeString, value) } - if pu.mutation.VanityURLRealCleared() { + if _u.mutation.VanityURLRealCleared() { _spec.ClearField(player.FieldVanityURLReal, field.TypeString) } - if value, ok := pu.mutation.VacDate(); ok { + if value, ok := _u.mutation.VacDate(); ok { _spec.SetField(player.FieldVacDate, field.TypeTime, value) } - if pu.mutation.VacDateCleared() { + if _u.mutation.VacDateCleared() { _spec.ClearField(player.FieldVacDate, field.TypeTime) } - if value, ok := pu.mutation.VacCount(); ok { + if value, ok := _u.mutation.VacCount(); ok { _spec.SetField(player.FieldVacCount, field.TypeInt, value) } - if value, ok := pu.mutation.AddedVacCount(); ok { + if value, ok := _u.mutation.AddedVacCount(); ok { _spec.AddField(player.FieldVacCount, field.TypeInt, value) } - if pu.mutation.VacCountCleared() { + if _u.mutation.VacCountCleared() { _spec.ClearField(player.FieldVacCount, field.TypeInt) } - if value, ok := pu.mutation.GameBanDate(); ok { + if value, ok := _u.mutation.GameBanDate(); ok { _spec.SetField(player.FieldGameBanDate, field.TypeTime, value) } - if pu.mutation.GameBanDateCleared() { + if _u.mutation.GameBanDateCleared() { _spec.ClearField(player.FieldGameBanDate, field.TypeTime) } - if value, ok := pu.mutation.GameBanCount(); ok { + if value, ok := _u.mutation.GameBanCount(); ok { _spec.SetField(player.FieldGameBanCount, field.TypeInt, value) } - if value, ok := pu.mutation.AddedGameBanCount(); ok { + if value, ok := _u.mutation.AddedGameBanCount(); ok { _spec.AddField(player.FieldGameBanCount, field.TypeInt, value) } - if pu.mutation.GameBanCountCleared() { + if _u.mutation.GameBanCountCleared() { _spec.ClearField(player.FieldGameBanCount, field.TypeInt) } - if value, ok := pu.mutation.SteamUpdated(); ok { + if value, ok := _u.mutation.SteamUpdated(); ok { _spec.SetField(player.FieldSteamUpdated, field.TypeTime, value) } - if value, ok := pu.mutation.SharecodeUpdated(); ok { + if value, ok := _u.mutation.SharecodeUpdated(); ok { _spec.SetField(player.FieldSharecodeUpdated, field.TypeTime, value) } - if pu.mutation.SharecodeUpdatedCleared() { + if _u.mutation.SharecodeUpdatedCleared() { _spec.ClearField(player.FieldSharecodeUpdated, field.TypeTime) } - if value, ok := pu.mutation.AuthCode(); ok { + if value, ok := _u.mutation.AuthCode(); ok { _spec.SetField(player.FieldAuthCode, field.TypeString, value) } - if pu.mutation.AuthCodeCleared() { + if _u.mutation.AuthCodeCleared() { _spec.ClearField(player.FieldAuthCode, field.TypeString) } - if value, ok := pu.mutation.ProfileCreated(); ok { + if value, ok := _u.mutation.ProfileCreated(); ok { _spec.SetField(player.FieldProfileCreated, field.TypeTime, value) } - if pu.mutation.ProfileCreatedCleared() { + if _u.mutation.ProfileCreatedCleared() { _spec.ClearField(player.FieldProfileCreated, field.TypeTime) } - if value, ok := pu.mutation.OldestSharecodeSeen(); ok { + if value, ok := _u.mutation.OldestSharecodeSeen(); ok { _spec.SetField(player.FieldOldestSharecodeSeen, field.TypeString, value) } - if pu.mutation.OldestSharecodeSeenCleared() { + if _u.mutation.OldestSharecodeSeenCleared() { _spec.ClearField(player.FieldOldestSharecodeSeen, field.TypeString) } - if value, ok := pu.mutation.Wins(); ok { + if value, ok := _u.mutation.Wins(); ok { _spec.SetField(player.FieldWins, field.TypeInt, value) } - if value, ok := pu.mutation.AddedWins(); ok { + if value, ok := _u.mutation.AddedWins(); ok { _spec.AddField(player.FieldWins, field.TypeInt, value) } - if pu.mutation.WinsCleared() { + if _u.mutation.WinsCleared() { _spec.ClearField(player.FieldWins, field.TypeInt) } - if value, ok := pu.mutation.Looses(); ok { + if value, ok := _u.mutation.Looses(); ok { _spec.SetField(player.FieldLooses, field.TypeInt, value) } - if value, ok := pu.mutation.AddedLooses(); ok { + if value, ok := _u.mutation.AddedLooses(); ok { _spec.AddField(player.FieldLooses, field.TypeInt, value) } - if pu.mutation.LoosesCleared() { + if _u.mutation.LoosesCleared() { _spec.ClearField(player.FieldLooses, field.TypeInt) } - if value, ok := pu.mutation.Ties(); ok { + if value, ok := _u.mutation.Ties(); ok { _spec.SetField(player.FieldTies, field.TypeInt, value) } - if value, ok := pu.mutation.AddedTies(); ok { + if value, ok := _u.mutation.AddedTies(); ok { _spec.AddField(player.FieldTies, field.TypeInt, value) } - if pu.mutation.TiesCleared() { + if _u.mutation.TiesCleared() { _spec.ClearField(player.FieldTies, field.TypeInt) } - if pu.mutation.StatsCleared() { + if _u.mutation.StatsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -620,7 +620,7 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.RemovedStatsIDs(); len(nodes) > 0 && !pu.mutation.StatsCleared() { + if nodes := _u.mutation.RemovedStatsIDs(); len(nodes) > 0 && !_u.mutation.StatsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -636,7 +636,7 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.StatsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.StatsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -652,7 +652,7 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if pu.mutation.MatchesCleared() { + if _u.mutation.MatchesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -665,7 +665,7 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.RemovedMatchesIDs(); len(nodes) > 0 && !pu.mutation.MatchesCleared() { + if nodes := _u.mutation.RemovedMatchesIDs(); len(nodes) > 0 && !_u.mutation.MatchesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -681,7 +681,7 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := pu.mutation.MatchesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.MatchesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -697,8 +697,8 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(pu.modifiers...) - if n, err = sqlgraph.UpdateNodes(ctx, pu.driver, _spec); err != nil { + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{player.Label} } else if sqlgraph.IsConstraintError(err) { @@ -706,8 +706,8 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } return 0, err } - pu.mutation.done = true - return n, nil + _u.mutation.done = true + return _node, nil } // PlayerUpdateOne is the builder for updating a single Player entity. @@ -720,452 +720,452 @@ type PlayerUpdateOne struct { } // SetName sets the "name" field. -func (puo *PlayerUpdateOne) SetName(s string) *PlayerUpdateOne { - puo.mutation.SetName(s) - return puo +func (_u *PlayerUpdateOne) SetName(v string) *PlayerUpdateOne { + _u.mutation.SetName(v) + return _u } // SetNillableName sets the "name" field if the given value is not nil. -func (puo *PlayerUpdateOne) SetNillableName(s *string) *PlayerUpdateOne { - if s != nil { - puo.SetName(*s) +func (_u *PlayerUpdateOne) SetNillableName(v *string) *PlayerUpdateOne { + if v != nil { + _u.SetName(*v) } - return puo + return _u } // ClearName clears the value of the "name" field. -func (puo *PlayerUpdateOne) ClearName() *PlayerUpdateOne { - puo.mutation.ClearName() - return puo +func (_u *PlayerUpdateOne) ClearName() *PlayerUpdateOne { + _u.mutation.ClearName() + return _u } // SetAvatar sets the "avatar" field. -func (puo *PlayerUpdateOne) SetAvatar(s string) *PlayerUpdateOne { - puo.mutation.SetAvatar(s) - return puo +func (_u *PlayerUpdateOne) SetAvatar(v string) *PlayerUpdateOne { + _u.mutation.SetAvatar(v) + return _u } // SetNillableAvatar sets the "avatar" field if the given value is not nil. -func (puo *PlayerUpdateOne) SetNillableAvatar(s *string) *PlayerUpdateOne { - if s != nil { - puo.SetAvatar(*s) +func (_u *PlayerUpdateOne) SetNillableAvatar(v *string) *PlayerUpdateOne { + if v != nil { + _u.SetAvatar(*v) } - return puo + return _u } // ClearAvatar clears the value of the "avatar" field. -func (puo *PlayerUpdateOne) ClearAvatar() *PlayerUpdateOne { - puo.mutation.ClearAvatar() - return puo +func (_u *PlayerUpdateOne) ClearAvatar() *PlayerUpdateOne { + _u.mutation.ClearAvatar() + return _u } // SetVanityURL sets the "vanity_url" field. -func (puo *PlayerUpdateOne) SetVanityURL(s string) *PlayerUpdateOne { - puo.mutation.SetVanityURL(s) - return puo +func (_u *PlayerUpdateOne) SetVanityURL(v string) *PlayerUpdateOne { + _u.mutation.SetVanityURL(v) + return _u } // SetNillableVanityURL sets the "vanity_url" field if the given value is not nil. -func (puo *PlayerUpdateOne) SetNillableVanityURL(s *string) *PlayerUpdateOne { - if s != nil { - puo.SetVanityURL(*s) +func (_u *PlayerUpdateOne) SetNillableVanityURL(v *string) *PlayerUpdateOne { + if v != nil { + _u.SetVanityURL(*v) } - return puo + return _u } // ClearVanityURL clears the value of the "vanity_url" field. -func (puo *PlayerUpdateOne) ClearVanityURL() *PlayerUpdateOne { - puo.mutation.ClearVanityURL() - return puo +func (_u *PlayerUpdateOne) ClearVanityURL() *PlayerUpdateOne { + _u.mutation.ClearVanityURL() + return _u } // SetVanityURLReal sets the "vanity_url_real" field. -func (puo *PlayerUpdateOne) SetVanityURLReal(s string) *PlayerUpdateOne { - puo.mutation.SetVanityURLReal(s) - return puo +func (_u *PlayerUpdateOne) SetVanityURLReal(v string) *PlayerUpdateOne { + _u.mutation.SetVanityURLReal(v) + return _u } // SetNillableVanityURLReal sets the "vanity_url_real" field if the given value is not nil. -func (puo *PlayerUpdateOne) SetNillableVanityURLReal(s *string) *PlayerUpdateOne { - if s != nil { - puo.SetVanityURLReal(*s) +func (_u *PlayerUpdateOne) SetNillableVanityURLReal(v *string) *PlayerUpdateOne { + if v != nil { + _u.SetVanityURLReal(*v) } - return puo + return _u } // ClearVanityURLReal clears the value of the "vanity_url_real" field. -func (puo *PlayerUpdateOne) ClearVanityURLReal() *PlayerUpdateOne { - puo.mutation.ClearVanityURLReal() - return puo +func (_u *PlayerUpdateOne) ClearVanityURLReal() *PlayerUpdateOne { + _u.mutation.ClearVanityURLReal() + return _u } // SetVacDate sets the "vac_date" field. -func (puo *PlayerUpdateOne) SetVacDate(t time.Time) *PlayerUpdateOne { - puo.mutation.SetVacDate(t) - return puo +func (_u *PlayerUpdateOne) SetVacDate(v time.Time) *PlayerUpdateOne { + _u.mutation.SetVacDate(v) + return _u } // SetNillableVacDate sets the "vac_date" field if the given value is not nil. -func (puo *PlayerUpdateOne) SetNillableVacDate(t *time.Time) *PlayerUpdateOne { - if t != nil { - puo.SetVacDate(*t) +func (_u *PlayerUpdateOne) SetNillableVacDate(v *time.Time) *PlayerUpdateOne { + if v != nil { + _u.SetVacDate(*v) } - return puo + return _u } // ClearVacDate clears the value of the "vac_date" field. -func (puo *PlayerUpdateOne) ClearVacDate() *PlayerUpdateOne { - puo.mutation.ClearVacDate() - return puo +func (_u *PlayerUpdateOne) ClearVacDate() *PlayerUpdateOne { + _u.mutation.ClearVacDate() + return _u } // SetVacCount sets the "vac_count" field. -func (puo *PlayerUpdateOne) SetVacCount(i int) *PlayerUpdateOne { - puo.mutation.ResetVacCount() - puo.mutation.SetVacCount(i) - return puo +func (_u *PlayerUpdateOne) SetVacCount(v int) *PlayerUpdateOne { + _u.mutation.ResetVacCount() + _u.mutation.SetVacCount(v) + return _u } // SetNillableVacCount sets the "vac_count" field if the given value is not nil. -func (puo *PlayerUpdateOne) SetNillableVacCount(i *int) *PlayerUpdateOne { - if i != nil { - puo.SetVacCount(*i) +func (_u *PlayerUpdateOne) SetNillableVacCount(v *int) *PlayerUpdateOne { + if v != nil { + _u.SetVacCount(*v) } - return puo + return _u } -// AddVacCount adds i to the "vac_count" field. -func (puo *PlayerUpdateOne) AddVacCount(i int) *PlayerUpdateOne { - puo.mutation.AddVacCount(i) - return puo +// AddVacCount adds value to the "vac_count" field. +func (_u *PlayerUpdateOne) AddVacCount(v int) *PlayerUpdateOne { + _u.mutation.AddVacCount(v) + return _u } // ClearVacCount clears the value of the "vac_count" field. -func (puo *PlayerUpdateOne) ClearVacCount() *PlayerUpdateOne { - puo.mutation.ClearVacCount() - return puo +func (_u *PlayerUpdateOne) ClearVacCount() *PlayerUpdateOne { + _u.mutation.ClearVacCount() + return _u } // SetGameBanDate sets the "game_ban_date" field. -func (puo *PlayerUpdateOne) SetGameBanDate(t time.Time) *PlayerUpdateOne { - puo.mutation.SetGameBanDate(t) - return puo +func (_u *PlayerUpdateOne) SetGameBanDate(v time.Time) *PlayerUpdateOne { + _u.mutation.SetGameBanDate(v) + return _u } // SetNillableGameBanDate sets the "game_ban_date" field if the given value is not nil. -func (puo *PlayerUpdateOne) SetNillableGameBanDate(t *time.Time) *PlayerUpdateOne { - if t != nil { - puo.SetGameBanDate(*t) +func (_u *PlayerUpdateOne) SetNillableGameBanDate(v *time.Time) *PlayerUpdateOne { + if v != nil { + _u.SetGameBanDate(*v) } - return puo + return _u } // ClearGameBanDate clears the value of the "game_ban_date" field. -func (puo *PlayerUpdateOne) ClearGameBanDate() *PlayerUpdateOne { - puo.mutation.ClearGameBanDate() - return puo +func (_u *PlayerUpdateOne) ClearGameBanDate() *PlayerUpdateOne { + _u.mutation.ClearGameBanDate() + return _u } // SetGameBanCount sets the "game_ban_count" field. -func (puo *PlayerUpdateOne) SetGameBanCount(i int) *PlayerUpdateOne { - puo.mutation.ResetGameBanCount() - puo.mutation.SetGameBanCount(i) - return puo +func (_u *PlayerUpdateOne) SetGameBanCount(v int) *PlayerUpdateOne { + _u.mutation.ResetGameBanCount() + _u.mutation.SetGameBanCount(v) + return _u } // SetNillableGameBanCount sets the "game_ban_count" field if the given value is not nil. -func (puo *PlayerUpdateOne) SetNillableGameBanCount(i *int) *PlayerUpdateOne { - if i != nil { - puo.SetGameBanCount(*i) +func (_u *PlayerUpdateOne) SetNillableGameBanCount(v *int) *PlayerUpdateOne { + if v != nil { + _u.SetGameBanCount(*v) } - return puo + return _u } -// AddGameBanCount adds i to the "game_ban_count" field. -func (puo *PlayerUpdateOne) AddGameBanCount(i int) *PlayerUpdateOne { - puo.mutation.AddGameBanCount(i) - return puo +// AddGameBanCount adds value to the "game_ban_count" field. +func (_u *PlayerUpdateOne) AddGameBanCount(v int) *PlayerUpdateOne { + _u.mutation.AddGameBanCount(v) + return _u } // ClearGameBanCount clears the value of the "game_ban_count" field. -func (puo *PlayerUpdateOne) ClearGameBanCount() *PlayerUpdateOne { - puo.mutation.ClearGameBanCount() - return puo +func (_u *PlayerUpdateOne) ClearGameBanCount() *PlayerUpdateOne { + _u.mutation.ClearGameBanCount() + return _u } // SetSteamUpdated sets the "steam_updated" field. -func (puo *PlayerUpdateOne) SetSteamUpdated(t time.Time) *PlayerUpdateOne { - puo.mutation.SetSteamUpdated(t) - return puo +func (_u *PlayerUpdateOne) SetSteamUpdated(v time.Time) *PlayerUpdateOne { + _u.mutation.SetSteamUpdated(v) + return _u } // SetNillableSteamUpdated sets the "steam_updated" field if the given value is not nil. -func (puo *PlayerUpdateOne) SetNillableSteamUpdated(t *time.Time) *PlayerUpdateOne { - if t != nil { - puo.SetSteamUpdated(*t) +func (_u *PlayerUpdateOne) SetNillableSteamUpdated(v *time.Time) *PlayerUpdateOne { + if v != nil { + _u.SetSteamUpdated(*v) } - return puo + return _u } // SetSharecodeUpdated sets the "sharecode_updated" field. -func (puo *PlayerUpdateOne) SetSharecodeUpdated(t time.Time) *PlayerUpdateOne { - puo.mutation.SetSharecodeUpdated(t) - return puo +func (_u *PlayerUpdateOne) SetSharecodeUpdated(v time.Time) *PlayerUpdateOne { + _u.mutation.SetSharecodeUpdated(v) + return _u } // SetNillableSharecodeUpdated sets the "sharecode_updated" field if the given value is not nil. -func (puo *PlayerUpdateOne) SetNillableSharecodeUpdated(t *time.Time) *PlayerUpdateOne { - if t != nil { - puo.SetSharecodeUpdated(*t) +func (_u *PlayerUpdateOne) SetNillableSharecodeUpdated(v *time.Time) *PlayerUpdateOne { + if v != nil { + _u.SetSharecodeUpdated(*v) } - return puo + return _u } // ClearSharecodeUpdated clears the value of the "sharecode_updated" field. -func (puo *PlayerUpdateOne) ClearSharecodeUpdated() *PlayerUpdateOne { - puo.mutation.ClearSharecodeUpdated() - return puo +func (_u *PlayerUpdateOne) ClearSharecodeUpdated() *PlayerUpdateOne { + _u.mutation.ClearSharecodeUpdated() + return _u } // SetAuthCode sets the "auth_code" field. -func (puo *PlayerUpdateOne) SetAuthCode(s string) *PlayerUpdateOne { - puo.mutation.SetAuthCode(s) - return puo +func (_u *PlayerUpdateOne) SetAuthCode(v string) *PlayerUpdateOne { + _u.mutation.SetAuthCode(v) + return _u } // SetNillableAuthCode sets the "auth_code" field if the given value is not nil. -func (puo *PlayerUpdateOne) SetNillableAuthCode(s *string) *PlayerUpdateOne { - if s != nil { - puo.SetAuthCode(*s) +func (_u *PlayerUpdateOne) SetNillableAuthCode(v *string) *PlayerUpdateOne { + if v != nil { + _u.SetAuthCode(*v) } - return puo + return _u } // ClearAuthCode clears the value of the "auth_code" field. -func (puo *PlayerUpdateOne) ClearAuthCode() *PlayerUpdateOne { - puo.mutation.ClearAuthCode() - return puo +func (_u *PlayerUpdateOne) ClearAuthCode() *PlayerUpdateOne { + _u.mutation.ClearAuthCode() + return _u } // SetProfileCreated sets the "profile_created" field. -func (puo *PlayerUpdateOne) SetProfileCreated(t time.Time) *PlayerUpdateOne { - puo.mutation.SetProfileCreated(t) - return puo +func (_u *PlayerUpdateOne) SetProfileCreated(v time.Time) *PlayerUpdateOne { + _u.mutation.SetProfileCreated(v) + return _u } // SetNillableProfileCreated sets the "profile_created" field if the given value is not nil. -func (puo *PlayerUpdateOne) SetNillableProfileCreated(t *time.Time) *PlayerUpdateOne { - if t != nil { - puo.SetProfileCreated(*t) +func (_u *PlayerUpdateOne) SetNillableProfileCreated(v *time.Time) *PlayerUpdateOne { + if v != nil { + _u.SetProfileCreated(*v) } - return puo + return _u } // ClearProfileCreated clears the value of the "profile_created" field. -func (puo *PlayerUpdateOne) ClearProfileCreated() *PlayerUpdateOne { - puo.mutation.ClearProfileCreated() - return puo +func (_u *PlayerUpdateOne) ClearProfileCreated() *PlayerUpdateOne { + _u.mutation.ClearProfileCreated() + return _u } // SetOldestSharecodeSeen sets the "oldest_sharecode_seen" field. -func (puo *PlayerUpdateOne) SetOldestSharecodeSeen(s string) *PlayerUpdateOne { - puo.mutation.SetOldestSharecodeSeen(s) - return puo +func (_u *PlayerUpdateOne) SetOldestSharecodeSeen(v string) *PlayerUpdateOne { + _u.mutation.SetOldestSharecodeSeen(v) + return _u } // SetNillableOldestSharecodeSeen sets the "oldest_sharecode_seen" field if the given value is not nil. -func (puo *PlayerUpdateOne) SetNillableOldestSharecodeSeen(s *string) *PlayerUpdateOne { - if s != nil { - puo.SetOldestSharecodeSeen(*s) +func (_u *PlayerUpdateOne) SetNillableOldestSharecodeSeen(v *string) *PlayerUpdateOne { + if v != nil { + _u.SetOldestSharecodeSeen(*v) } - return puo + return _u } // ClearOldestSharecodeSeen clears the value of the "oldest_sharecode_seen" field. -func (puo *PlayerUpdateOne) ClearOldestSharecodeSeen() *PlayerUpdateOne { - puo.mutation.ClearOldestSharecodeSeen() - return puo +func (_u *PlayerUpdateOne) ClearOldestSharecodeSeen() *PlayerUpdateOne { + _u.mutation.ClearOldestSharecodeSeen() + return _u } // SetWins sets the "wins" field. -func (puo *PlayerUpdateOne) SetWins(i int) *PlayerUpdateOne { - puo.mutation.ResetWins() - puo.mutation.SetWins(i) - return puo +func (_u *PlayerUpdateOne) SetWins(v int) *PlayerUpdateOne { + _u.mutation.ResetWins() + _u.mutation.SetWins(v) + return _u } // SetNillableWins sets the "wins" field if the given value is not nil. -func (puo *PlayerUpdateOne) SetNillableWins(i *int) *PlayerUpdateOne { - if i != nil { - puo.SetWins(*i) +func (_u *PlayerUpdateOne) SetNillableWins(v *int) *PlayerUpdateOne { + if v != nil { + _u.SetWins(*v) } - return puo + return _u } -// AddWins adds i to the "wins" field. -func (puo *PlayerUpdateOne) AddWins(i int) *PlayerUpdateOne { - puo.mutation.AddWins(i) - return puo +// AddWins adds value to the "wins" field. +func (_u *PlayerUpdateOne) AddWins(v int) *PlayerUpdateOne { + _u.mutation.AddWins(v) + return _u } // ClearWins clears the value of the "wins" field. -func (puo *PlayerUpdateOne) ClearWins() *PlayerUpdateOne { - puo.mutation.ClearWins() - return puo +func (_u *PlayerUpdateOne) ClearWins() *PlayerUpdateOne { + _u.mutation.ClearWins() + return _u } // SetLooses sets the "looses" field. -func (puo *PlayerUpdateOne) SetLooses(i int) *PlayerUpdateOne { - puo.mutation.ResetLooses() - puo.mutation.SetLooses(i) - return puo +func (_u *PlayerUpdateOne) SetLooses(v int) *PlayerUpdateOne { + _u.mutation.ResetLooses() + _u.mutation.SetLooses(v) + return _u } // SetNillableLooses sets the "looses" field if the given value is not nil. -func (puo *PlayerUpdateOne) SetNillableLooses(i *int) *PlayerUpdateOne { - if i != nil { - puo.SetLooses(*i) +func (_u *PlayerUpdateOne) SetNillableLooses(v *int) *PlayerUpdateOne { + if v != nil { + _u.SetLooses(*v) } - return puo + return _u } -// AddLooses adds i to the "looses" field. -func (puo *PlayerUpdateOne) AddLooses(i int) *PlayerUpdateOne { - puo.mutation.AddLooses(i) - return puo +// AddLooses adds value to the "looses" field. +func (_u *PlayerUpdateOne) AddLooses(v int) *PlayerUpdateOne { + _u.mutation.AddLooses(v) + return _u } // ClearLooses clears the value of the "looses" field. -func (puo *PlayerUpdateOne) ClearLooses() *PlayerUpdateOne { - puo.mutation.ClearLooses() - return puo +func (_u *PlayerUpdateOne) ClearLooses() *PlayerUpdateOne { + _u.mutation.ClearLooses() + return _u } // SetTies sets the "ties" field. -func (puo *PlayerUpdateOne) SetTies(i int) *PlayerUpdateOne { - puo.mutation.ResetTies() - puo.mutation.SetTies(i) - return puo +func (_u *PlayerUpdateOne) SetTies(v int) *PlayerUpdateOne { + _u.mutation.ResetTies() + _u.mutation.SetTies(v) + return _u } // SetNillableTies sets the "ties" field if the given value is not nil. -func (puo *PlayerUpdateOne) SetNillableTies(i *int) *PlayerUpdateOne { - if i != nil { - puo.SetTies(*i) +func (_u *PlayerUpdateOne) SetNillableTies(v *int) *PlayerUpdateOne { + if v != nil { + _u.SetTies(*v) } - return puo + return _u } -// AddTies adds i to the "ties" field. -func (puo *PlayerUpdateOne) AddTies(i int) *PlayerUpdateOne { - puo.mutation.AddTies(i) - return puo +// AddTies adds value to the "ties" field. +func (_u *PlayerUpdateOne) AddTies(v int) *PlayerUpdateOne { + _u.mutation.AddTies(v) + return _u } // ClearTies clears the value of the "ties" field. -func (puo *PlayerUpdateOne) ClearTies() *PlayerUpdateOne { - puo.mutation.ClearTies() - return puo +func (_u *PlayerUpdateOne) ClearTies() *PlayerUpdateOne { + _u.mutation.ClearTies() + return _u } // AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs. -func (puo *PlayerUpdateOne) AddStatIDs(ids ...int) *PlayerUpdateOne { - puo.mutation.AddStatIDs(ids...) - return puo +func (_u *PlayerUpdateOne) AddStatIDs(ids ...int) *PlayerUpdateOne { + _u.mutation.AddStatIDs(ids...) + return _u } // AddStats adds the "stats" edges to the MatchPlayer entity. -func (puo *PlayerUpdateOne) AddStats(m ...*MatchPlayer) *PlayerUpdateOne { - ids := make([]int, len(m)) - for i := range m { - ids[i] = m[i].ID +func (_u *PlayerUpdateOne) AddStats(v ...*MatchPlayer) *PlayerUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return puo.AddStatIDs(ids...) + return _u.AddStatIDs(ids...) } // AddMatchIDs adds the "matches" edge to the Match entity by IDs. -func (puo *PlayerUpdateOne) AddMatchIDs(ids ...uint64) *PlayerUpdateOne { - puo.mutation.AddMatchIDs(ids...) - return puo +func (_u *PlayerUpdateOne) AddMatchIDs(ids ...uint64) *PlayerUpdateOne { + _u.mutation.AddMatchIDs(ids...) + return _u } // AddMatches adds the "matches" edges to the Match entity. -func (puo *PlayerUpdateOne) AddMatches(m ...*Match) *PlayerUpdateOne { - ids := make([]uint64, len(m)) - for i := range m { - ids[i] = m[i].ID +func (_u *PlayerUpdateOne) AddMatches(v ...*Match) *PlayerUpdateOne { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return puo.AddMatchIDs(ids...) + return _u.AddMatchIDs(ids...) } // Mutation returns the PlayerMutation object of the builder. -func (puo *PlayerUpdateOne) Mutation() *PlayerMutation { - return puo.mutation +func (_u *PlayerUpdateOne) Mutation() *PlayerMutation { + return _u.mutation } // ClearStats clears all "stats" edges to the MatchPlayer entity. -func (puo *PlayerUpdateOne) ClearStats() *PlayerUpdateOne { - puo.mutation.ClearStats() - return puo +func (_u *PlayerUpdateOne) ClearStats() *PlayerUpdateOne { + _u.mutation.ClearStats() + return _u } // RemoveStatIDs removes the "stats" edge to MatchPlayer entities by IDs. -func (puo *PlayerUpdateOne) RemoveStatIDs(ids ...int) *PlayerUpdateOne { - puo.mutation.RemoveStatIDs(ids...) - return puo +func (_u *PlayerUpdateOne) RemoveStatIDs(ids ...int) *PlayerUpdateOne { + _u.mutation.RemoveStatIDs(ids...) + return _u } // RemoveStats removes "stats" edges to MatchPlayer entities. -func (puo *PlayerUpdateOne) RemoveStats(m ...*MatchPlayer) *PlayerUpdateOne { - ids := make([]int, len(m)) - for i := range m { - ids[i] = m[i].ID +func (_u *PlayerUpdateOne) RemoveStats(v ...*MatchPlayer) *PlayerUpdateOne { + ids := make([]int, len(v)) + for i := range v { + ids[i] = v[i].ID } - return puo.RemoveStatIDs(ids...) + return _u.RemoveStatIDs(ids...) } // ClearMatches clears all "matches" edges to the Match entity. -func (puo *PlayerUpdateOne) ClearMatches() *PlayerUpdateOne { - puo.mutation.ClearMatches() - return puo +func (_u *PlayerUpdateOne) ClearMatches() *PlayerUpdateOne { + _u.mutation.ClearMatches() + return _u } // RemoveMatchIDs removes the "matches" edge to Match entities by IDs. -func (puo *PlayerUpdateOne) RemoveMatchIDs(ids ...uint64) *PlayerUpdateOne { - puo.mutation.RemoveMatchIDs(ids...) - return puo +func (_u *PlayerUpdateOne) RemoveMatchIDs(ids ...uint64) *PlayerUpdateOne { + _u.mutation.RemoveMatchIDs(ids...) + return _u } // RemoveMatches removes "matches" edges to Match entities. -func (puo *PlayerUpdateOne) RemoveMatches(m ...*Match) *PlayerUpdateOne { - ids := make([]uint64, len(m)) - for i := range m { - ids[i] = m[i].ID +func (_u *PlayerUpdateOne) RemoveMatches(v ...*Match) *PlayerUpdateOne { + ids := make([]uint64, len(v)) + for i := range v { + ids[i] = v[i].ID } - return puo.RemoveMatchIDs(ids...) + return _u.RemoveMatchIDs(ids...) } // Where appends a list predicates to the PlayerUpdate builder. -func (puo *PlayerUpdateOne) Where(ps ...predicate.Player) *PlayerUpdateOne { - puo.mutation.Where(ps...) - return puo +func (_u *PlayerUpdateOne) Where(ps ...predicate.Player) *PlayerUpdateOne { + _u.mutation.Where(ps...) + return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. -func (puo *PlayerUpdateOne) Select(field string, fields ...string) *PlayerUpdateOne { - puo.fields = append([]string{field}, fields...) - return puo +func (_u *PlayerUpdateOne) Select(field string, fields ...string) *PlayerUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u } // Save executes the query and returns the updated Player entity. -func (puo *PlayerUpdateOne) Save(ctx context.Context) (*Player, error) { - return withHooks(ctx, puo.sqlSave, puo.mutation, puo.hooks) +func (_u *PlayerUpdateOne) Save(ctx context.Context) (*Player, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (puo *PlayerUpdateOne) SaveX(ctx context.Context) *Player { - node, err := puo.Save(ctx) +func (_u *PlayerUpdateOne) SaveX(ctx context.Context) *Player { + node, err := _u.Save(ctx) if err != nil { panic(err) } @@ -1173,32 +1173,32 @@ func (puo *PlayerUpdateOne) SaveX(ctx context.Context) *Player { } // Exec executes the query on the entity. -func (puo *PlayerUpdateOne) Exec(ctx context.Context) error { - _, err := puo.Save(ctx) +func (_u *PlayerUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (puo *PlayerUpdateOne) ExecX(ctx context.Context) { - if err := puo.Exec(ctx); err != nil { +func (_u *PlayerUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // 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 (_u *PlayerUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PlayerUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err error) { +func (_u *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err error) { _spec := sqlgraph.NewUpdateSpec(player.Table, player.Columns, sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64)) - id, ok := puo.mutation.ID() + id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Player.id" for update`)} } _spec.Node.ID.Value = id - if fields := puo.fields; len(fields) > 0 { + if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, player.FieldID) for _, f := range fields { @@ -1210,122 +1210,122 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err } } } - if ps := puo.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := puo.mutation.Name(); ok { + if value, ok := _u.mutation.Name(); ok { _spec.SetField(player.FieldName, field.TypeString, value) } - if puo.mutation.NameCleared() { + if _u.mutation.NameCleared() { _spec.ClearField(player.FieldName, field.TypeString) } - if value, ok := puo.mutation.Avatar(); ok { + if value, ok := _u.mutation.Avatar(); ok { _spec.SetField(player.FieldAvatar, field.TypeString, value) } - if puo.mutation.AvatarCleared() { + if _u.mutation.AvatarCleared() { _spec.ClearField(player.FieldAvatar, field.TypeString) } - if value, ok := puo.mutation.VanityURL(); ok { + if value, ok := _u.mutation.VanityURL(); ok { _spec.SetField(player.FieldVanityURL, field.TypeString, value) } - if puo.mutation.VanityURLCleared() { + if _u.mutation.VanityURLCleared() { _spec.ClearField(player.FieldVanityURL, field.TypeString) } - if value, ok := puo.mutation.VanityURLReal(); ok { + if value, ok := _u.mutation.VanityURLReal(); ok { _spec.SetField(player.FieldVanityURLReal, field.TypeString, value) } - if puo.mutation.VanityURLRealCleared() { + if _u.mutation.VanityURLRealCleared() { _spec.ClearField(player.FieldVanityURLReal, field.TypeString) } - if value, ok := puo.mutation.VacDate(); ok { + if value, ok := _u.mutation.VacDate(); ok { _spec.SetField(player.FieldVacDate, field.TypeTime, value) } - if puo.mutation.VacDateCleared() { + if _u.mutation.VacDateCleared() { _spec.ClearField(player.FieldVacDate, field.TypeTime) } - if value, ok := puo.mutation.VacCount(); ok { + if value, ok := _u.mutation.VacCount(); ok { _spec.SetField(player.FieldVacCount, field.TypeInt, value) } - if value, ok := puo.mutation.AddedVacCount(); ok { + if value, ok := _u.mutation.AddedVacCount(); ok { _spec.AddField(player.FieldVacCount, field.TypeInt, value) } - if puo.mutation.VacCountCleared() { + if _u.mutation.VacCountCleared() { _spec.ClearField(player.FieldVacCount, field.TypeInt) } - if value, ok := puo.mutation.GameBanDate(); ok { + if value, ok := _u.mutation.GameBanDate(); ok { _spec.SetField(player.FieldGameBanDate, field.TypeTime, value) } - if puo.mutation.GameBanDateCleared() { + if _u.mutation.GameBanDateCleared() { _spec.ClearField(player.FieldGameBanDate, field.TypeTime) } - if value, ok := puo.mutation.GameBanCount(); ok { + if value, ok := _u.mutation.GameBanCount(); ok { _spec.SetField(player.FieldGameBanCount, field.TypeInt, value) } - if value, ok := puo.mutation.AddedGameBanCount(); ok { + if value, ok := _u.mutation.AddedGameBanCount(); ok { _spec.AddField(player.FieldGameBanCount, field.TypeInt, value) } - if puo.mutation.GameBanCountCleared() { + if _u.mutation.GameBanCountCleared() { _spec.ClearField(player.FieldGameBanCount, field.TypeInt) } - if value, ok := puo.mutation.SteamUpdated(); ok { + if value, ok := _u.mutation.SteamUpdated(); ok { _spec.SetField(player.FieldSteamUpdated, field.TypeTime, value) } - if value, ok := puo.mutation.SharecodeUpdated(); ok { + if value, ok := _u.mutation.SharecodeUpdated(); ok { _spec.SetField(player.FieldSharecodeUpdated, field.TypeTime, value) } - if puo.mutation.SharecodeUpdatedCleared() { + if _u.mutation.SharecodeUpdatedCleared() { _spec.ClearField(player.FieldSharecodeUpdated, field.TypeTime) } - if value, ok := puo.mutation.AuthCode(); ok { + if value, ok := _u.mutation.AuthCode(); ok { _spec.SetField(player.FieldAuthCode, field.TypeString, value) } - if puo.mutation.AuthCodeCleared() { + if _u.mutation.AuthCodeCleared() { _spec.ClearField(player.FieldAuthCode, field.TypeString) } - if value, ok := puo.mutation.ProfileCreated(); ok { + if value, ok := _u.mutation.ProfileCreated(); ok { _spec.SetField(player.FieldProfileCreated, field.TypeTime, value) } - if puo.mutation.ProfileCreatedCleared() { + if _u.mutation.ProfileCreatedCleared() { _spec.ClearField(player.FieldProfileCreated, field.TypeTime) } - if value, ok := puo.mutation.OldestSharecodeSeen(); ok { + if value, ok := _u.mutation.OldestSharecodeSeen(); ok { _spec.SetField(player.FieldOldestSharecodeSeen, field.TypeString, value) } - if puo.mutation.OldestSharecodeSeenCleared() { + if _u.mutation.OldestSharecodeSeenCleared() { _spec.ClearField(player.FieldOldestSharecodeSeen, field.TypeString) } - if value, ok := puo.mutation.Wins(); ok { + if value, ok := _u.mutation.Wins(); ok { _spec.SetField(player.FieldWins, field.TypeInt, value) } - if value, ok := puo.mutation.AddedWins(); ok { + if value, ok := _u.mutation.AddedWins(); ok { _spec.AddField(player.FieldWins, field.TypeInt, value) } - if puo.mutation.WinsCleared() { + if _u.mutation.WinsCleared() { _spec.ClearField(player.FieldWins, field.TypeInt) } - if value, ok := puo.mutation.Looses(); ok { + if value, ok := _u.mutation.Looses(); ok { _spec.SetField(player.FieldLooses, field.TypeInt, value) } - if value, ok := puo.mutation.AddedLooses(); ok { + if value, ok := _u.mutation.AddedLooses(); ok { _spec.AddField(player.FieldLooses, field.TypeInt, value) } - if puo.mutation.LoosesCleared() { + if _u.mutation.LoosesCleared() { _spec.ClearField(player.FieldLooses, field.TypeInt) } - if value, ok := puo.mutation.Ties(); ok { + if value, ok := _u.mutation.Ties(); ok { _spec.SetField(player.FieldTies, field.TypeInt, value) } - if value, ok := puo.mutation.AddedTies(); ok { + if value, ok := _u.mutation.AddedTies(); ok { _spec.AddField(player.FieldTies, field.TypeInt, value) } - if puo.mutation.TiesCleared() { + if _u.mutation.TiesCleared() { _spec.ClearField(player.FieldTies, field.TypeInt) } - if puo.mutation.StatsCleared() { + if _u.mutation.StatsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -1338,7 +1338,7 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.RemovedStatsIDs(); len(nodes) > 0 && !puo.mutation.StatsCleared() { + if nodes := _u.mutation.RemovedStatsIDs(); len(nodes) > 0 && !_u.mutation.StatsCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -1354,7 +1354,7 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.StatsIDs(); len(nodes) > 0 { + if nodes := _u.mutation.StatsIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.O2M, Inverse: false, @@ -1370,7 +1370,7 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - if puo.mutation.MatchesCleared() { + if _u.mutation.MatchesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -1383,7 +1383,7 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.RemovedMatchesIDs(); len(nodes) > 0 && !puo.mutation.MatchesCleared() { + if nodes := _u.mutation.RemovedMatchesIDs(); len(nodes) > 0 && !_u.mutation.MatchesCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -1399,7 +1399,7 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := puo.mutation.MatchesIDs(); len(nodes) > 0 { + if nodes := _u.mutation.MatchesIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2M, Inverse: false, @@ -1415,11 +1415,11 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(puo.modifiers...) - _node = &Player{config: puo.config} + _spec.AddModifiers(_u.modifiers...) + _node = &Player{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, puo.driver, _spec); err != nil { + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{player.Label} } else if sqlgraph.IsConstraintError(err) { @@ -1427,6 +1427,6 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err } return nil, err } - puo.mutation.done = true + _u.mutation.done = true return _node, nil } diff --git a/ent/roundstats.go b/ent/roundstats.go index d10c764..9550870 100644 --- a/ent/roundstats.go +++ b/ent/roundstats.go @@ -44,12 +44,10 @@ type RoundStatsEdges struct { // MatchPlayerOrErr returns the MatchPlayer value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e RoundStatsEdges) MatchPlayerOrErr() (*MatchPlayer, error) { - if e.loadedTypes[0] { - if e.MatchPlayer == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: matchplayer.Label} - } + if e.MatchPlayer != nil { return e.MatchPlayer, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: matchplayer.Label} } return nil, &NotLoadedError{edge: "match_player"} } @@ -72,7 +70,7 @@ func (*RoundStats) scanValues(columns []string) ([]any, error) { // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the RoundStats fields. -func (rs *RoundStats) assignValues(columns []string, values []any) error { +func (_m *RoundStats) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } @@ -83,40 +81,40 @@ func (rs *RoundStats) assignValues(columns []string, values []any) error { if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - rs.ID = int(value.Int64) + _m.ID = int(value.Int64) case roundstats.FieldRound: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field round", values[i]) } else if value.Valid { - rs.Round = uint(value.Int64) + _m.Round = uint(value.Int64) } case roundstats.FieldBank: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field bank", values[i]) } else if value.Valid { - rs.Bank = uint(value.Int64) + _m.Bank = uint(value.Int64) } case roundstats.FieldEquipment: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field equipment", values[i]) } else if value.Valid { - rs.Equipment = uint(value.Int64) + _m.Equipment = uint(value.Int64) } case roundstats.FieldSpent: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field spent", values[i]) } else if value.Valid { - rs.Spent = uint(value.Int64) + _m.Spent = uint(value.Int64) } case roundstats.ForeignKeys[0]: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for edge-field match_player_round_stats", value) } else if value.Valid { - rs.match_player_round_stats = new(int) - *rs.match_player_round_stats = int(value.Int64) + _m.match_player_round_stats = new(int) + *_m.match_player_round_stats = int(value.Int64) } default: - rs.selectValues.Set(columns[i], values[i]) + _m.selectValues.Set(columns[i], values[i]) } } return nil @@ -124,49 +122,49 @@ func (rs *RoundStats) assignValues(columns []string, values []any) error { // Value returns the ent.Value that was dynamically selected and assigned to the RoundStats. // This includes values selected through modifiers, order, etc. -func (rs *RoundStats) Value(name string) (ent.Value, error) { - return rs.selectValues.Get(name) +func (_m *RoundStats) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) } // QueryMatchPlayer queries the "match_player" edge of the RoundStats entity. -func (rs *RoundStats) QueryMatchPlayer() *MatchPlayerQuery { - return NewRoundStatsClient(rs.config).QueryMatchPlayer(rs) +func (_m *RoundStats) QueryMatchPlayer() *MatchPlayerQuery { + return NewRoundStatsClient(_m.config).QueryMatchPlayer(_m) } // Update returns a builder for updating this RoundStats. // Note that you need to call RoundStats.Unwrap() before calling this method if this RoundStats // was returned from a transaction, and the transaction was committed or rolled back. -func (rs *RoundStats) Update() *RoundStatsUpdateOne { - return NewRoundStatsClient(rs.config).UpdateOne(rs) +func (_m *RoundStats) Update() *RoundStatsUpdateOne { + return NewRoundStatsClient(_m.config).UpdateOne(_m) } // 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) +func (_m *RoundStats) Unwrap() *RoundStats { + _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: RoundStats is not a transactional entity") } - rs.config.driver = _tx.drv - return rs + _m.config.driver = _tx.drv + return _m } // String implements the fmt.Stringer. -func (rs *RoundStats) String() string { +func (_m *RoundStats) String() string { var builder strings.Builder builder.WriteString("RoundStats(") - builder.WriteString(fmt.Sprintf("id=%v, ", rs.ID)) + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("round=") - builder.WriteString(fmt.Sprintf("%v", rs.Round)) + builder.WriteString(fmt.Sprintf("%v", _m.Round)) builder.WriteString(", ") builder.WriteString("bank=") - builder.WriteString(fmt.Sprintf("%v", rs.Bank)) + builder.WriteString(fmt.Sprintf("%v", _m.Bank)) builder.WriteString(", ") builder.WriteString("equipment=") - builder.WriteString(fmt.Sprintf("%v", rs.Equipment)) + builder.WriteString(fmt.Sprintf("%v", _m.Equipment)) builder.WriteString(", ") builder.WriteString("spent=") - builder.WriteString(fmt.Sprintf("%v", rs.Spent)) + builder.WriteString(fmt.Sprintf("%v", _m.Spent)) builder.WriteByte(')') return builder.String() } diff --git a/ent/roundstats/where.go b/ent/roundstats/where.go index 071fea6..ea842c8 100644 --- a/ent/roundstats/where.go +++ b/ent/roundstats/where.go @@ -258,32 +258,15 @@ func HasMatchPlayerWith(preds ...predicate.MatchPlayer) predicate.RoundStats { // And groups predicates with the AND operator between them. func And(predicates ...predicate.RoundStats) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.RoundStats(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.RoundStats) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.RoundStats(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.RoundStats) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.RoundStats(sql.NotPredicates(p)) } diff --git a/ent/roundstats_create.go b/ent/roundstats_create.go index 5dfd744..920e943 100644 --- a/ent/roundstats_create.go +++ b/ent/roundstats_create.go @@ -21,61 +21,61 @@ type RoundStatsCreate struct { } // SetRound sets the "round" field. -func (rsc *RoundStatsCreate) SetRound(u uint) *RoundStatsCreate { - rsc.mutation.SetRound(u) - return rsc +func (_c *RoundStatsCreate) SetRound(v uint) *RoundStatsCreate { + _c.mutation.SetRound(v) + return _c } // SetBank sets the "bank" field. -func (rsc *RoundStatsCreate) SetBank(u uint) *RoundStatsCreate { - rsc.mutation.SetBank(u) - return rsc +func (_c *RoundStatsCreate) SetBank(v uint) *RoundStatsCreate { + _c.mutation.SetBank(v) + return _c } // SetEquipment sets the "equipment" field. -func (rsc *RoundStatsCreate) SetEquipment(u uint) *RoundStatsCreate { - rsc.mutation.SetEquipment(u) - return rsc +func (_c *RoundStatsCreate) SetEquipment(v uint) *RoundStatsCreate { + _c.mutation.SetEquipment(v) + return _c } // SetSpent sets the "spent" field. -func (rsc *RoundStatsCreate) SetSpent(u uint) *RoundStatsCreate { - rsc.mutation.SetSpent(u) - return rsc +func (_c *RoundStatsCreate) SetSpent(v uint) *RoundStatsCreate { + _c.mutation.SetSpent(v) + return _c } // SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID. -func (rsc *RoundStatsCreate) SetMatchPlayerID(id int) *RoundStatsCreate { - rsc.mutation.SetMatchPlayerID(id) - return rsc +func (_c *RoundStatsCreate) SetMatchPlayerID(id int) *RoundStatsCreate { + _c.mutation.SetMatchPlayerID(id) + return _c } // SetNillableMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID if the given value is not nil. -func (rsc *RoundStatsCreate) SetNillableMatchPlayerID(id *int) *RoundStatsCreate { +func (_c *RoundStatsCreate) SetNillableMatchPlayerID(id *int) *RoundStatsCreate { if id != nil { - rsc = rsc.SetMatchPlayerID(*id) + _c = _c.SetMatchPlayerID(*id) } - return rsc + return _c } // SetMatchPlayer sets the "match_player" edge to the MatchPlayer entity. -func (rsc *RoundStatsCreate) SetMatchPlayer(m *MatchPlayer) *RoundStatsCreate { - return rsc.SetMatchPlayerID(m.ID) +func (_c *RoundStatsCreate) SetMatchPlayer(v *MatchPlayer) *RoundStatsCreate { + return _c.SetMatchPlayerID(v.ID) } // Mutation returns the RoundStatsMutation object of the builder. -func (rsc *RoundStatsCreate) Mutation() *RoundStatsMutation { - return rsc.mutation +func (_c *RoundStatsCreate) Mutation() *RoundStatsMutation { + return _c.mutation } // Save creates the RoundStats in the database. -func (rsc *RoundStatsCreate) Save(ctx context.Context) (*RoundStats, error) { - return withHooks(ctx, rsc.sqlSave, rsc.mutation, rsc.hooks) +func (_c *RoundStatsCreate) Save(ctx context.Context) (*RoundStats, error) { + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. -func (rsc *RoundStatsCreate) SaveX(ctx context.Context) *RoundStats { - v, err := rsc.Save(ctx) +func (_c *RoundStatsCreate) SaveX(ctx context.Context) *RoundStats { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -83,41 +83,41 @@ func (rsc *RoundStatsCreate) SaveX(ctx context.Context) *RoundStats { } // Exec executes the query. -func (rsc *RoundStatsCreate) Exec(ctx context.Context) error { - _, err := rsc.Save(ctx) +func (_c *RoundStatsCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (rsc *RoundStatsCreate) ExecX(ctx context.Context) { - if err := rsc.Exec(ctx); err != nil { +func (_c *RoundStatsCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (rsc *RoundStatsCreate) check() error { - if _, ok := rsc.mutation.Round(); !ok { +func (_c *RoundStatsCreate) check() error { + if _, ok := _c.mutation.Round(); !ok { return &ValidationError{Name: "round", err: errors.New(`ent: missing required field "RoundStats.round"`)} } - if _, ok := rsc.mutation.Bank(); !ok { + if _, ok := _c.mutation.Bank(); !ok { return &ValidationError{Name: "bank", err: errors.New(`ent: missing required field "RoundStats.bank"`)} } - if _, ok := rsc.mutation.Equipment(); !ok { + if _, ok := _c.mutation.Equipment(); !ok { return &ValidationError{Name: "equipment", err: errors.New(`ent: missing required field "RoundStats.equipment"`)} } - if _, ok := rsc.mutation.Spent(); !ok { + if _, ok := _c.mutation.Spent(); !ok { return &ValidationError{Name: "spent", err: errors.New(`ent: missing required field "RoundStats.spent"`)} } return nil } -func (rsc *RoundStatsCreate) sqlSave(ctx context.Context) (*RoundStats, error) { - if err := rsc.check(); err != nil { +func (_c *RoundStatsCreate) sqlSave(ctx context.Context) (*RoundStats, error) { + if err := _c.check(); err != nil { return nil, err } - _node, _spec := rsc.createSpec() - if err := sqlgraph.CreateNode(ctx, rsc.driver, _spec); err != nil { + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -125,33 +125,33 @@ func (rsc *RoundStatsCreate) sqlSave(ctx context.Context) (*RoundStats, error) { } id := _spec.ID.Value.(int64) _node.ID = int(id) - rsc.mutation.id = &_node.ID - rsc.mutation.done = true + _c.mutation.id = &_node.ID + _c.mutation.done = true return _node, nil } -func (rsc *RoundStatsCreate) createSpec() (*RoundStats, *sqlgraph.CreateSpec) { +func (_c *RoundStatsCreate) createSpec() (*RoundStats, *sqlgraph.CreateSpec) { var ( - _node = &RoundStats{config: rsc.config} + _node = &RoundStats{config: _c.config} _spec = sqlgraph.NewCreateSpec(roundstats.Table, sqlgraph.NewFieldSpec(roundstats.FieldID, field.TypeInt)) ) - if value, ok := rsc.mutation.Round(); ok { + if value, ok := _c.mutation.Round(); ok { _spec.SetField(roundstats.FieldRound, field.TypeUint, value) _node.Round = value } - if value, ok := rsc.mutation.Bank(); ok { + if value, ok := _c.mutation.Bank(); ok { _spec.SetField(roundstats.FieldBank, field.TypeUint, value) _node.Bank = value } - if value, ok := rsc.mutation.Equipment(); ok { + if value, ok := _c.mutation.Equipment(); ok { _spec.SetField(roundstats.FieldEquipment, field.TypeUint, value) _node.Equipment = value } - if value, ok := rsc.mutation.Spent(); ok { + if value, ok := _c.mutation.Spent(); ok { _spec.SetField(roundstats.FieldSpent, field.TypeUint, value) _node.Spent = value } - if nodes := rsc.mutation.MatchPlayerIDs(); len(nodes) > 0 { + if nodes := _c.mutation.MatchPlayerIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -174,17 +174,21 @@ func (rsc *RoundStatsCreate) createSpec() (*RoundStats, *sqlgraph.CreateSpec) { // RoundStatsCreateBulk is the builder for creating many RoundStats entities in bulk. type RoundStatsCreateBulk struct { config + err error builders []*RoundStatsCreate } // Save creates the RoundStats entities in the database. -func (rscb *RoundStatsCreateBulk) Save(ctx context.Context) ([]*RoundStats, error) { - specs := make([]*sqlgraph.CreateSpec, len(rscb.builders)) - nodes := make([]*RoundStats, len(rscb.builders)) - mutators := make([]Mutator, len(rscb.builders)) - for i := range rscb.builders { +func (_c *RoundStatsCreateBulk) Save(ctx context.Context) ([]*RoundStats, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*RoundStats, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { func(i int, root context.Context) { - builder := rscb.builders[i] + builder := _c.builders[i] var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*RoundStatsMutation) if !ok { @@ -197,11 +201,11 @@ func (rscb *RoundStatsCreateBulk) Save(ctx context.Context) ([]*RoundStats, erro var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, rscb.builders[i+1].mutation) + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, rscb.driver, spec); err != nil { + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -225,7 +229,7 @@ func (rscb *RoundStatsCreateBulk) Save(ctx context.Context) ([]*RoundStats, erro }(i, ctx) } if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, rscb.builders[0].mutation); err != nil { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { return nil, err } } @@ -233,8 +237,8 @@ func (rscb *RoundStatsCreateBulk) Save(ctx context.Context) ([]*RoundStats, erro } // SaveX is like Save, but panics if an error occurs. -func (rscb *RoundStatsCreateBulk) SaveX(ctx context.Context) []*RoundStats { - v, err := rscb.Save(ctx) +func (_c *RoundStatsCreateBulk) SaveX(ctx context.Context) []*RoundStats { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -242,14 +246,14 @@ func (rscb *RoundStatsCreateBulk) SaveX(ctx context.Context) []*RoundStats { } // Exec executes the query. -func (rscb *RoundStatsCreateBulk) Exec(ctx context.Context) error { - _, err := rscb.Save(ctx) +func (_c *RoundStatsCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (rscb *RoundStatsCreateBulk) ExecX(ctx context.Context) { - if err := rscb.Exec(ctx); err != nil { +func (_c *RoundStatsCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } diff --git a/ent/roundstats_delete.go b/ent/roundstats_delete.go index cffc536..8f151a1 100644 --- a/ent/roundstats_delete.go +++ b/ent/roundstats_delete.go @@ -20,56 +20,56 @@ type RoundStatsDelete struct { } // Where appends a list predicates to the RoundStatsDelete builder. -func (rsd *RoundStatsDelete) Where(ps ...predicate.RoundStats) *RoundStatsDelete { - rsd.mutation.Where(ps...) - return rsd +func (_d *RoundStatsDelete) Where(ps ...predicate.RoundStats) *RoundStatsDelete { + _d.mutation.Where(ps...) + return _d } // Exec executes the deletion query and returns how many vertices were deleted. -func (rsd *RoundStatsDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, rsd.sqlExec, rsd.mutation, rsd.hooks) +func (_d *RoundStatsDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) } // ExecX is like Exec, but panics if an error occurs. -func (rsd *RoundStatsDelete) ExecX(ctx context.Context) int { - n, err := rsd.Exec(ctx) +func (_d *RoundStatsDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) if err != nil { panic(err) } return n } -func (rsd *RoundStatsDelete) sqlExec(ctx context.Context) (int, error) { +func (_d *RoundStatsDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(roundstats.Table, sqlgraph.NewFieldSpec(roundstats.FieldID, field.TypeInt)) - if ps := rsd.mutation.predicates; len(ps) > 0 { + if ps := _d.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - affected, err := sqlgraph.DeleteNodes(ctx, rsd.driver, _spec) + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } - rsd.mutation.done = true + _d.mutation.done = true return affected, err } // RoundStatsDeleteOne is the builder for deleting a single RoundStats entity. type RoundStatsDeleteOne struct { - rsd *RoundStatsDelete + _d *RoundStatsDelete } // Where appends a list predicates to the RoundStatsDelete builder. -func (rsdo *RoundStatsDeleteOne) Where(ps ...predicate.RoundStats) *RoundStatsDeleteOne { - rsdo.rsd.mutation.Where(ps...) - return rsdo +func (_d *RoundStatsDeleteOne) Where(ps ...predicate.RoundStats) *RoundStatsDeleteOne { + _d._d.mutation.Where(ps...) + return _d } // Exec executes the deletion query. -func (rsdo *RoundStatsDeleteOne) Exec(ctx context.Context) error { - n, err := rsdo.rsd.Exec(ctx) +func (_d *RoundStatsDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) switch { case err != nil: return err @@ -81,8 +81,8 @@ func (rsdo *RoundStatsDeleteOne) Exec(ctx context.Context) error { } // ExecX is like Exec, but panics if an error occurs. -func (rsdo *RoundStatsDeleteOne) ExecX(ctx context.Context) { - if err := rsdo.Exec(ctx); err != nil { +func (_d *RoundStatsDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { panic(err) } } diff --git a/ent/roundstats_query.go b/ent/roundstats_query.go index 8b26063..c65d35e 100644 --- a/ent/roundstats_query.go +++ b/ent/roundstats_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -31,44 +32,44 @@ type RoundStatsQuery struct { } // Where adds a new predicate for the RoundStatsQuery builder. -func (rsq *RoundStatsQuery) Where(ps ...predicate.RoundStats) *RoundStatsQuery { - rsq.predicates = append(rsq.predicates, ps...) - return rsq +func (_q *RoundStatsQuery) Where(ps ...predicate.RoundStats) *RoundStatsQuery { + _q.predicates = append(_q.predicates, ps...) + return _q } // Limit the number of records to be returned by this query. -func (rsq *RoundStatsQuery) Limit(limit int) *RoundStatsQuery { - rsq.ctx.Limit = &limit - return rsq +func (_q *RoundStatsQuery) Limit(limit int) *RoundStatsQuery { + _q.ctx.Limit = &limit + return _q } // Offset to start from. -func (rsq *RoundStatsQuery) Offset(offset int) *RoundStatsQuery { - rsq.ctx.Offset = &offset - return rsq +func (_q *RoundStatsQuery) Offset(offset int) *RoundStatsQuery { + _q.ctx.Offset = &offset + return _q } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. -func (rsq *RoundStatsQuery) Unique(unique bool) *RoundStatsQuery { - rsq.ctx.Unique = &unique - return rsq +func (_q *RoundStatsQuery) Unique(unique bool) *RoundStatsQuery { + _q.ctx.Unique = &unique + return _q } // Order specifies how the records should be ordered. -func (rsq *RoundStatsQuery) Order(o ...roundstats.OrderOption) *RoundStatsQuery { - rsq.order = append(rsq.order, o...) - return rsq +func (_q *RoundStatsQuery) Order(o ...roundstats.OrderOption) *RoundStatsQuery { + _q.order = append(_q.order, o...) + return _q } // QueryMatchPlayer chains the current query on the "match_player" edge. -func (rsq *RoundStatsQuery) QueryMatchPlayer() *MatchPlayerQuery { - query := (&MatchPlayerClient{config: rsq.config}).Query() +func (_q *RoundStatsQuery) QueryMatchPlayer() *MatchPlayerQuery { + query := (&MatchPlayerClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := rsq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := rsq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -77,7 +78,7 @@ func (rsq *RoundStatsQuery) QueryMatchPlayer() *MatchPlayerQuery { sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, roundstats.MatchPlayerTable, roundstats.MatchPlayerColumn), ) - fromU = sqlgraph.SetNeighbors(rsq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query @@ -85,8 +86,8 @@ func (rsq *RoundStatsQuery) QueryMatchPlayer() *MatchPlayerQuery { // First returns the first RoundStats entity from the query. // Returns a *NotFoundError when no RoundStats was found. -func (rsq *RoundStatsQuery) First(ctx context.Context) (*RoundStats, error) { - nodes, err := rsq.Limit(1).All(setContextOp(ctx, rsq.ctx, "First")) +func (_q *RoundStatsQuery) First(ctx context.Context) (*RoundStats, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -97,8 +98,8 @@ func (rsq *RoundStatsQuery) First(ctx context.Context) (*RoundStats, error) { } // FirstX is like First, but panics if an error occurs. -func (rsq *RoundStatsQuery) FirstX(ctx context.Context) *RoundStats { - node, err := rsq.First(ctx) +func (_q *RoundStatsQuery) FirstX(ctx context.Context) *RoundStats { + node, err := _q.First(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -107,9 +108,9 @@ func (rsq *RoundStatsQuery) FirstX(ctx context.Context) *RoundStats { // FirstID returns the first RoundStats ID from the query. // Returns a *NotFoundError when no RoundStats ID was found. -func (rsq *RoundStatsQuery) FirstID(ctx context.Context) (id int, err error) { +func (_q *RoundStatsQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = rsq.Limit(1).IDs(setContextOp(ctx, rsq.ctx, "FirstID")); err != nil { + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -120,8 +121,8 @@ func (rsq *RoundStatsQuery) FirstID(ctx context.Context) (id int, err error) { } // FirstIDX is like FirstID, but panics if an error occurs. -func (rsq *RoundStatsQuery) FirstIDX(ctx context.Context) int { - id, err := rsq.FirstID(ctx) +func (_q *RoundStatsQuery) FirstIDX(ctx context.Context) int { + id, err := _q.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -131,8 +132,8 @@ func (rsq *RoundStatsQuery) FirstIDX(ctx context.Context) int { // Only returns a single RoundStats entity found by the query, ensuring it only returns one. // Returns a *NotSingularError when more than one RoundStats entity is found. // Returns a *NotFoundError when no RoundStats entities are found. -func (rsq *RoundStatsQuery) Only(ctx context.Context) (*RoundStats, error) { - nodes, err := rsq.Limit(2).All(setContextOp(ctx, rsq.ctx, "Only")) +func (_q *RoundStatsQuery) Only(ctx context.Context) (*RoundStats, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -147,8 +148,8 @@ func (rsq *RoundStatsQuery) Only(ctx context.Context) (*RoundStats, error) { } // OnlyX is like Only, but panics if an error occurs. -func (rsq *RoundStatsQuery) OnlyX(ctx context.Context) *RoundStats { - node, err := rsq.Only(ctx) +func (_q *RoundStatsQuery) OnlyX(ctx context.Context) *RoundStats { + node, err := _q.Only(ctx) if err != nil { panic(err) } @@ -158,9 +159,9 @@ func (rsq *RoundStatsQuery) OnlyX(ctx context.Context) *RoundStats { // OnlyID is like Only, but returns the only RoundStats ID in the query. // Returns a *NotSingularError when more than one RoundStats ID is found. // Returns a *NotFoundError when no entities are found. -func (rsq *RoundStatsQuery) OnlyID(ctx context.Context) (id int, err error) { +func (_q *RoundStatsQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = rsq.Limit(2).IDs(setContextOp(ctx, rsq.ctx, "OnlyID")); err != nil { + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -175,8 +176,8 @@ func (rsq *RoundStatsQuery) OnlyID(ctx context.Context) (id int, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (rsq *RoundStatsQuery) OnlyIDX(ctx context.Context) int { - id, err := rsq.OnlyID(ctx) +func (_q *RoundStatsQuery) OnlyIDX(ctx context.Context) int { + id, err := _q.OnlyID(ctx) if err != nil { panic(err) } @@ -184,18 +185,18 @@ func (rsq *RoundStatsQuery) OnlyIDX(ctx context.Context) int { } // All executes the query and returns a list of RoundStatsSlice. -func (rsq *RoundStatsQuery) All(ctx context.Context) ([]*RoundStats, error) { - ctx = setContextOp(ctx, rsq.ctx, "All") - if err := rsq.prepareQuery(ctx); err != nil { +func (_q *RoundStatsQuery) All(ctx context.Context) ([]*RoundStats, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { return nil, err } qr := querierAll[[]*RoundStats, *RoundStatsQuery]() - return withInterceptors[[]*RoundStats](ctx, rsq, qr, rsq.inters) + return withInterceptors[[]*RoundStats](ctx, _q, qr, _q.inters) } // AllX is like All, but panics if an error occurs. -func (rsq *RoundStatsQuery) AllX(ctx context.Context) []*RoundStats { - nodes, err := rsq.All(ctx) +func (_q *RoundStatsQuery) AllX(ctx context.Context) []*RoundStats { + nodes, err := _q.All(ctx) if err != nil { panic(err) } @@ -203,20 +204,20 @@ func (rsq *RoundStatsQuery) AllX(ctx context.Context) []*RoundStats { } // IDs executes the query and returns a list of RoundStats IDs. -func (rsq *RoundStatsQuery) IDs(ctx context.Context) (ids []int, err error) { - if rsq.ctx.Unique == nil && rsq.path != nil { - rsq.Unique(true) +func (_q *RoundStatsQuery) IDs(ctx context.Context) (ids []int, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) } - ctx = setContextOp(ctx, rsq.ctx, "IDs") - if err = rsq.Select(roundstats.FieldID).Scan(ctx, &ids); err != nil { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(roundstats.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. -func (rsq *RoundStatsQuery) IDsX(ctx context.Context) []int { - ids, err := rsq.IDs(ctx) +func (_q *RoundStatsQuery) IDsX(ctx context.Context) []int { + ids, err := _q.IDs(ctx) if err != nil { panic(err) } @@ -224,17 +225,17 @@ func (rsq *RoundStatsQuery) IDsX(ctx context.Context) []int { } // Count returns the count of the given query. -func (rsq *RoundStatsQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, rsq.ctx, "Count") - if err := rsq.prepareQuery(ctx); err != nil { +func (_q *RoundStatsQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { return 0, err } - return withInterceptors[int](ctx, rsq, querierCount[*RoundStatsQuery](), rsq.inters) + return withInterceptors[int](ctx, _q, querierCount[*RoundStatsQuery](), _q.inters) } // CountX is like Count, but panics if an error occurs. -func (rsq *RoundStatsQuery) CountX(ctx context.Context) int { - count, err := rsq.Count(ctx) +func (_q *RoundStatsQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) if err != nil { panic(err) } @@ -242,9 +243,9 @@ func (rsq *RoundStatsQuery) CountX(ctx context.Context) int { } // Exist returns true if the query has elements in the graph. -func (rsq *RoundStatsQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, rsq.ctx, "Exist") - switch _, err := rsq.FirstID(ctx); { +func (_q *RoundStatsQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { case IsNotFound(err): return false, nil case err != nil: @@ -255,8 +256,8 @@ func (rsq *RoundStatsQuery) Exist(ctx context.Context) (bool, error) { } // ExistX is like Exist, but panics if an error occurs. -func (rsq *RoundStatsQuery) ExistX(ctx context.Context) bool { - exist, err := rsq.Exist(ctx) +func (_q *RoundStatsQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) if err != nil { panic(err) } @@ -265,32 +266,33 @@ func (rsq *RoundStatsQuery) ExistX(ctx context.Context) bool { // Clone returns a duplicate of the RoundStatsQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. -func (rsq *RoundStatsQuery) Clone() *RoundStatsQuery { - if rsq == nil { +func (_q *RoundStatsQuery) Clone() *RoundStatsQuery { + if _q == nil { return nil } return &RoundStatsQuery{ - config: rsq.config, - ctx: rsq.ctx.Clone(), - order: append([]roundstats.OrderOption{}, rsq.order...), - inters: append([]Interceptor{}, rsq.inters...), - predicates: append([]predicate.RoundStats{}, rsq.predicates...), - withMatchPlayer: rsq.withMatchPlayer.Clone(), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]roundstats.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.RoundStats{}, _q.predicates...), + withMatchPlayer: _q.withMatchPlayer.Clone(), // clone intermediate query. - sql: rsq.sql.Clone(), - path: rsq.path, + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), } } // WithMatchPlayer tells the query-builder to eager-load the nodes that are connected to // the "match_player" edge. The optional arguments are used to configure the query builder of the edge. -func (rsq *RoundStatsQuery) WithMatchPlayer(opts ...func(*MatchPlayerQuery)) *RoundStatsQuery { - query := (&MatchPlayerClient{config: rsq.config}).Query() +func (_q *RoundStatsQuery) WithMatchPlayer(opts ...func(*MatchPlayerQuery)) *RoundStatsQuery { + query := (&MatchPlayerClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - rsq.withMatchPlayer = query - return rsq + _q.withMatchPlayer = query + return _q } // GroupBy is used to group vertices by one or more fields/columns. @@ -307,10 +309,10 @@ 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 { - rsq.ctx.Fields = append([]string{field}, fields...) - grbuild := &RoundStatsGroupBy{build: rsq} - grbuild.flds = &rsq.ctx.Fields +func (_q *RoundStatsQuery) GroupBy(field string, fields ...string) *RoundStatsGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &RoundStatsGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields grbuild.label = roundstats.Label grbuild.scan = grbuild.Scan return grbuild @@ -328,55 +330,55 @@ 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.ctx.Fields = append(rsq.ctx.Fields, fields...) - sbuild := &RoundStatsSelect{RoundStatsQuery: rsq} +func (_q *RoundStatsQuery) Select(fields ...string) *RoundStatsSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &RoundStatsSelect{RoundStatsQuery: _q} sbuild.label = roundstats.Label - sbuild.flds, sbuild.scan = &rsq.ctx.Fields, sbuild.Scan + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan return sbuild } // Aggregate returns a RoundStatsSelect configured with the given aggregations. -func (rsq *RoundStatsQuery) Aggregate(fns ...AggregateFunc) *RoundStatsSelect { - return rsq.Select().Aggregate(fns...) +func (_q *RoundStatsQuery) Aggregate(fns ...AggregateFunc) *RoundStatsSelect { + return _q.Select().Aggregate(fns...) } -func (rsq *RoundStatsQuery) prepareQuery(ctx context.Context) error { - for _, inter := range rsq.inters { +func (_q *RoundStatsQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { if inter == nil { return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") } if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, rsq); err != nil { + if err := trv.Traverse(ctx, _q); err != nil { return err } } } - for _, f := range rsq.ctx.Fields { + for _, f := range _q.ctx.Fields { if !roundstats.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } - if rsq.path != nil { - prev, err := rsq.path(ctx) + if _q.path != nil { + prev, err := _q.path(ctx) if err != nil { return err } - rsq.sql = prev + _q.sql = prev } return nil } -func (rsq *RoundStatsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*RoundStats, error) { +func (_q *RoundStatsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*RoundStats, error) { var ( nodes = []*RoundStats{} - withFKs = rsq.withFKs - _spec = rsq.querySpec() + withFKs = _q.withFKs + _spec = _q.querySpec() loadedTypes = [1]bool{ - rsq.withMatchPlayer != nil, + _q.withMatchPlayer != nil, } ) - if rsq.withMatchPlayer != nil { + if _q.withMatchPlayer != nil { withFKs = true } if withFKs { @@ -386,25 +388,25 @@ func (rsq *RoundStatsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]* return (*RoundStats).scanValues(nil, columns) } _spec.Assign = func(columns []string, values []any) error { - node := &RoundStats{config: rsq.config} + node := &RoundStats{config: _q.config} nodes = append(nodes, node) node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) } - if len(rsq.modifiers) > 0 { - _spec.Modifiers = rsq.modifiers + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } for i := range hooks { hooks[i](ctx, _spec) } - if err := sqlgraph.QueryNodes(ctx, rsq.driver, _spec); err != nil { + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { return nil, err } if len(nodes) == 0 { return nodes, nil } - if query := rsq.withMatchPlayer; query != nil { - if err := rsq.loadMatchPlayer(ctx, query, nodes, nil, + if query := _q.withMatchPlayer; query != nil { + if err := _q.loadMatchPlayer(ctx, query, nodes, nil, func(n *RoundStats, e *MatchPlayer) { n.Edges.MatchPlayer = e }); err != nil { return nil, err } @@ -412,7 +414,7 @@ func (rsq *RoundStatsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]* return nodes, nil } -func (rsq *RoundStatsQuery) loadMatchPlayer(ctx context.Context, query *MatchPlayerQuery, nodes []*RoundStats, init func(*RoundStats), assign func(*RoundStats, *MatchPlayer)) error { +func (_q *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 { @@ -445,27 +447,27 @@ func (rsq *RoundStatsQuery) loadMatchPlayer(ctx context.Context, query *MatchPla return nil } -func (rsq *RoundStatsQuery) sqlCount(ctx context.Context) (int, error) { - _spec := rsq.querySpec() - if len(rsq.modifiers) > 0 { - _spec.Modifiers = rsq.modifiers +func (_q *RoundStatsQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } - _spec.Node.Columns = rsq.ctx.Fields - if len(rsq.ctx.Fields) > 0 { - _spec.Unique = rsq.ctx.Unique != nil && *rsq.ctx.Unique + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique } - return sqlgraph.CountNodes(ctx, rsq.driver, _spec) + return sqlgraph.CountNodes(ctx, _q.driver, _spec) } -func (rsq *RoundStatsQuery) querySpec() *sqlgraph.QuerySpec { +func (_q *RoundStatsQuery) querySpec() *sqlgraph.QuerySpec { _spec := sqlgraph.NewQuerySpec(roundstats.Table, roundstats.Columns, sqlgraph.NewFieldSpec(roundstats.FieldID, field.TypeInt)) - _spec.From = rsq.sql - if unique := rsq.ctx.Unique; unique != nil { + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { _spec.Unique = *unique - } else if rsq.path != nil { + } else if _q.path != nil { _spec.Unique = true } - if fields := rsq.ctx.Fields; len(fields) > 0 { + if fields := _q.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, roundstats.FieldID) for i := range fields { @@ -474,20 +476,20 @@ func (rsq *RoundStatsQuery) querySpec() *sqlgraph.QuerySpec { } } } - if ps := rsq.predicates; len(ps) > 0 { + if ps := _q.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if limit := rsq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := rsq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { _spec.Offset = *offset } - if ps := rsq.order; len(ps) > 0 { + if ps := _q.order; len(ps) > 0 { _spec.Order = func(selector *sql.Selector) { for i := range ps { ps[i](selector) @@ -497,45 +499,45 @@ func (rsq *RoundStatsQuery) querySpec() *sqlgraph.QuerySpec { return _spec } -func (rsq *RoundStatsQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(rsq.driver.Dialect()) +func (_q *RoundStatsQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) t1 := builder.Table(roundstats.Table) - columns := rsq.ctx.Fields + columns := _q.ctx.Fields if len(columns) == 0 { columns = roundstats.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) - if rsq.sql != nil { - selector = rsq.sql + if _q.sql != nil { + selector = _q.sql selector.Select(selector.Columns(columns...)...) } - if rsq.ctx.Unique != nil && *rsq.ctx.Unique { + if _q.ctx.Unique != nil && *_q.ctx.Unique { selector.Distinct() } - for _, m := range rsq.modifiers { + for _, m := range _q.modifiers { m(selector) } - for _, p := range rsq.predicates { + for _, p := range _q.predicates { p(selector) } - for _, p := range rsq.order { + for _, p := range _q.order { p(selector) } - if offset := rsq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { // limit is mandatory for offset clause. We start // with default value, and override it below if needed. selector.Offset(*offset).Limit(math.MaxInt32) } - if limit := rsq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector } // Modify adds a query modifier for attaching custom logic to queries. -func (rsq *RoundStatsQuery) Modify(modifiers ...func(s *sql.Selector)) *RoundStatsSelect { - rsq.modifiers = append(rsq.modifiers, modifiers...) - return rsq.Select() +func (_q *RoundStatsQuery) Modify(modifiers ...func(s *sql.Selector)) *RoundStatsSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() } // RoundStatsGroupBy is the group-by builder for RoundStats entities. @@ -545,41 +547,41 @@ type RoundStatsGroupBy struct { } // Aggregate adds the given aggregation functions to the group-by query. -func (rsgb *RoundStatsGroupBy) Aggregate(fns ...AggregateFunc) *RoundStatsGroupBy { - rsgb.fns = append(rsgb.fns, fns...) - return rsgb +func (_g *RoundStatsGroupBy) Aggregate(fns ...AggregateFunc) *RoundStatsGroupBy { + _g.fns = append(_g.fns, fns...) + return _g } // Scan applies the selector query and scans the result into the given value. -func (rsgb *RoundStatsGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, rsgb.build.ctx, "GroupBy") - if err := rsgb.build.prepareQuery(ctx); err != nil { +func (_g *RoundStatsGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*RoundStatsQuery, *RoundStatsGroupBy](ctx, rsgb.build, rsgb, rsgb.build.inters, v) + return scanWithInterceptors[*RoundStatsQuery, *RoundStatsGroupBy](ctx, _g.build, _g, _g.build.inters, v) } -func (rsgb *RoundStatsGroupBy) sqlScan(ctx context.Context, root *RoundStatsQuery, v any) error { +func (_g *RoundStatsGroupBy) sqlScan(ctx context.Context, root *RoundStatsQuery, v any) error { selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(rsgb.fns)) - for _, fn := range rsgb.fns { + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { aggregation = append(aggregation, fn(selector)) } if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*rsgb.flds)+len(rsgb.fns)) - for _, f := range *rsgb.flds { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { columns = append(columns, selector.C(f)) } columns = append(columns, aggregation...) selector.Select(columns...) } - selector.GroupBy(selector.Columns(*rsgb.flds...)...) + selector.GroupBy(selector.Columns(*_g.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := rsgb.build.driver.Query(ctx, query, args, rows); err != nil { + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -593,27 +595,27 @@ type RoundStatsSelect struct { } // Aggregate adds the given aggregation functions to the selector query. -func (rss *RoundStatsSelect) Aggregate(fns ...AggregateFunc) *RoundStatsSelect { - rss.fns = append(rss.fns, fns...) - return rss +func (_s *RoundStatsSelect) Aggregate(fns ...AggregateFunc) *RoundStatsSelect { + _s.fns = append(_s.fns, fns...) + return _s } // Scan applies the selector query and scans the result into the given value. -func (rss *RoundStatsSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, rss.ctx, "Select") - if err := rss.prepareQuery(ctx); err != nil { +func (_s *RoundStatsSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*RoundStatsQuery, *RoundStatsSelect](ctx, rss.RoundStatsQuery, rss, rss.inters, v) + return scanWithInterceptors[*RoundStatsQuery, *RoundStatsSelect](ctx, _s.RoundStatsQuery, _s, _s.inters, v) } -func (rss *RoundStatsSelect) sqlScan(ctx context.Context, root *RoundStatsQuery, v any) error { +func (_s *RoundStatsSelect) sqlScan(ctx context.Context, root *RoundStatsQuery, v any) error { selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(rss.fns)) - for _, fn := range rss.fns { + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { aggregation = append(aggregation, fn(selector)) } - switch n := len(*rss.selector.flds); { + switch n := len(*_s.selector.flds); { case n == 0 && len(aggregation) > 0: selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: @@ -621,7 +623,7 @@ func (rss *RoundStatsSelect) sqlScan(ctx context.Context, root *RoundStatsQuery, } rows := &sql.Rows{} query, args := selector.Query() - if err := rss.driver.Query(ctx, query, args, rows); err != nil { + if err := _s.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -629,7 +631,7 @@ func (rss *RoundStatsSelect) sqlScan(ctx context.Context, root *RoundStatsQuery, } // Modify adds a query modifier for attaching custom logic to queries. -func (rss *RoundStatsSelect) Modify(modifiers ...func(s *sql.Selector)) *RoundStatsSelect { - rss.modifiers = append(rss.modifiers, modifiers...) - return rss +func (_s *RoundStatsSelect) Modify(modifiers ...func(s *sql.Selector)) *RoundStatsSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s } diff --git a/ent/roundstats_update.go b/ent/roundstats_update.go index 946abc5..dbd06ca 100644 --- a/ent/roundstats_update.go +++ b/ent/roundstats_update.go @@ -24,101 +24,133 @@ type RoundStatsUpdate struct { } // Where appends a list predicates to the RoundStatsUpdate builder. -func (rsu *RoundStatsUpdate) Where(ps ...predicate.RoundStats) *RoundStatsUpdate { - rsu.mutation.Where(ps...) - return rsu +func (_u *RoundStatsUpdate) Where(ps ...predicate.RoundStats) *RoundStatsUpdate { + _u.mutation.Where(ps...) + return _u } // SetRound sets the "round" field. -func (rsu *RoundStatsUpdate) SetRound(u uint) *RoundStatsUpdate { - rsu.mutation.ResetRound() - rsu.mutation.SetRound(u) - return rsu +func (_u *RoundStatsUpdate) SetRound(v uint) *RoundStatsUpdate { + _u.mutation.ResetRound() + _u.mutation.SetRound(v) + return _u } -// AddRound adds u to the "round" field. -func (rsu *RoundStatsUpdate) AddRound(u int) *RoundStatsUpdate { - rsu.mutation.AddRound(u) - return rsu +// SetNillableRound sets the "round" field if the given value is not nil. +func (_u *RoundStatsUpdate) SetNillableRound(v *uint) *RoundStatsUpdate { + if v != nil { + _u.SetRound(*v) + } + return _u +} + +// AddRound adds value to the "round" field. +func (_u *RoundStatsUpdate) AddRound(v int) *RoundStatsUpdate { + _u.mutation.AddRound(v) + return _u } // SetBank sets the "bank" field. -func (rsu *RoundStatsUpdate) SetBank(u uint) *RoundStatsUpdate { - rsu.mutation.ResetBank() - rsu.mutation.SetBank(u) - return rsu +func (_u *RoundStatsUpdate) SetBank(v uint) *RoundStatsUpdate { + _u.mutation.ResetBank() + _u.mutation.SetBank(v) + return _u } -// AddBank adds u to the "bank" field. -func (rsu *RoundStatsUpdate) AddBank(u int) *RoundStatsUpdate { - rsu.mutation.AddBank(u) - return rsu +// SetNillableBank sets the "bank" field if the given value is not nil. +func (_u *RoundStatsUpdate) SetNillableBank(v *uint) *RoundStatsUpdate { + if v != nil { + _u.SetBank(*v) + } + return _u +} + +// AddBank adds value to the "bank" field. +func (_u *RoundStatsUpdate) AddBank(v int) *RoundStatsUpdate { + _u.mutation.AddBank(v) + return _u } // SetEquipment sets the "equipment" field. -func (rsu *RoundStatsUpdate) SetEquipment(u uint) *RoundStatsUpdate { - rsu.mutation.ResetEquipment() - rsu.mutation.SetEquipment(u) - return rsu +func (_u *RoundStatsUpdate) SetEquipment(v uint) *RoundStatsUpdate { + _u.mutation.ResetEquipment() + _u.mutation.SetEquipment(v) + return _u } -// AddEquipment adds u to the "equipment" field. -func (rsu *RoundStatsUpdate) AddEquipment(u int) *RoundStatsUpdate { - rsu.mutation.AddEquipment(u) - return rsu +// SetNillableEquipment sets the "equipment" field if the given value is not nil. +func (_u *RoundStatsUpdate) SetNillableEquipment(v *uint) *RoundStatsUpdate { + if v != nil { + _u.SetEquipment(*v) + } + return _u +} + +// AddEquipment adds value to the "equipment" field. +func (_u *RoundStatsUpdate) AddEquipment(v int) *RoundStatsUpdate { + _u.mutation.AddEquipment(v) + return _u } // SetSpent sets the "spent" field. -func (rsu *RoundStatsUpdate) SetSpent(u uint) *RoundStatsUpdate { - rsu.mutation.ResetSpent() - rsu.mutation.SetSpent(u) - return rsu +func (_u *RoundStatsUpdate) SetSpent(v uint) *RoundStatsUpdate { + _u.mutation.ResetSpent() + _u.mutation.SetSpent(v) + return _u } -// AddSpent adds u to the "spent" field. -func (rsu *RoundStatsUpdate) AddSpent(u int) *RoundStatsUpdate { - rsu.mutation.AddSpent(u) - return rsu +// SetNillableSpent sets the "spent" field if the given value is not nil. +func (_u *RoundStatsUpdate) SetNillableSpent(v *uint) *RoundStatsUpdate { + if v != nil { + _u.SetSpent(*v) + } + return _u +} + +// AddSpent adds value to the "spent" field. +func (_u *RoundStatsUpdate) AddSpent(v int) *RoundStatsUpdate { + _u.mutation.AddSpent(v) + return _u } // SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID. -func (rsu *RoundStatsUpdate) SetMatchPlayerID(id int) *RoundStatsUpdate { - rsu.mutation.SetMatchPlayerID(id) - return rsu +func (_u *RoundStatsUpdate) SetMatchPlayerID(id int) *RoundStatsUpdate { + _u.mutation.SetMatchPlayerID(id) + return _u } // SetNillableMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID if the given value is not nil. -func (rsu *RoundStatsUpdate) SetNillableMatchPlayerID(id *int) *RoundStatsUpdate { +func (_u *RoundStatsUpdate) SetNillableMatchPlayerID(id *int) *RoundStatsUpdate { if id != nil { - rsu = rsu.SetMatchPlayerID(*id) + _u = _u.SetMatchPlayerID(*id) } - return rsu + return _u } // SetMatchPlayer sets the "match_player" edge to the MatchPlayer entity. -func (rsu *RoundStatsUpdate) SetMatchPlayer(m *MatchPlayer) *RoundStatsUpdate { - return rsu.SetMatchPlayerID(m.ID) +func (_u *RoundStatsUpdate) SetMatchPlayer(v *MatchPlayer) *RoundStatsUpdate { + return _u.SetMatchPlayerID(v.ID) } // Mutation returns the RoundStatsMutation object of the builder. -func (rsu *RoundStatsUpdate) Mutation() *RoundStatsMutation { - return rsu.mutation +func (_u *RoundStatsUpdate) Mutation() *RoundStatsMutation { + return _u.mutation } // ClearMatchPlayer clears the "match_player" edge to the MatchPlayer entity. -func (rsu *RoundStatsUpdate) ClearMatchPlayer() *RoundStatsUpdate { - rsu.mutation.ClearMatchPlayer() - return rsu +func (_u *RoundStatsUpdate) ClearMatchPlayer() *RoundStatsUpdate { + _u.mutation.ClearMatchPlayer() + return _u } // Save executes the query and returns the number of nodes affected by the update operation. -func (rsu *RoundStatsUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, rsu.sqlSave, rsu.mutation, rsu.hooks) +func (_u *RoundStatsUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (rsu *RoundStatsUpdate) SaveX(ctx context.Context) int { - affected, err := rsu.Save(ctx) +func (_u *RoundStatsUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) if err != nil { panic(err) } @@ -126,58 +158,58 @@ func (rsu *RoundStatsUpdate) SaveX(ctx context.Context) int { } // Exec executes the query. -func (rsu *RoundStatsUpdate) Exec(ctx context.Context) error { - _, err := rsu.Save(ctx) +func (_u *RoundStatsUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (rsu *RoundStatsUpdate) ExecX(ctx context.Context) { - if err := rsu.Exec(ctx); err != nil { +func (_u *RoundStatsUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // 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 (_u *RoundStatsUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RoundStatsUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (rsu *RoundStatsUpdate) sqlSave(ctx context.Context) (n int, err error) { +func (_u *RoundStatsUpdate) sqlSave(ctx context.Context) (_node int, err error) { _spec := sqlgraph.NewUpdateSpec(roundstats.Table, roundstats.Columns, sqlgraph.NewFieldSpec(roundstats.FieldID, field.TypeInt)) - if ps := rsu.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := rsu.mutation.Round(); ok { + if value, ok := _u.mutation.Round(); ok { _spec.SetField(roundstats.FieldRound, field.TypeUint, value) } - if value, ok := rsu.mutation.AddedRound(); ok { + if value, ok := _u.mutation.AddedRound(); ok { _spec.AddField(roundstats.FieldRound, field.TypeUint, value) } - if value, ok := rsu.mutation.Bank(); ok { + if value, ok := _u.mutation.Bank(); ok { _spec.SetField(roundstats.FieldBank, field.TypeUint, value) } - if value, ok := rsu.mutation.AddedBank(); ok { + if value, ok := _u.mutation.AddedBank(); ok { _spec.AddField(roundstats.FieldBank, field.TypeUint, value) } - if value, ok := rsu.mutation.Equipment(); ok { + if value, ok := _u.mutation.Equipment(); ok { _spec.SetField(roundstats.FieldEquipment, field.TypeUint, value) } - if value, ok := rsu.mutation.AddedEquipment(); ok { + if value, ok := _u.mutation.AddedEquipment(); ok { _spec.AddField(roundstats.FieldEquipment, field.TypeUint, value) } - if value, ok := rsu.mutation.Spent(); ok { + if value, ok := _u.mutation.Spent(); ok { _spec.SetField(roundstats.FieldSpent, field.TypeUint, value) } - if value, ok := rsu.mutation.AddedSpent(); ok { + if value, ok := _u.mutation.AddedSpent(); ok { _spec.AddField(roundstats.FieldSpent, field.TypeUint, value) } - if rsu.mutation.MatchPlayerCleared() { + if _u.mutation.MatchPlayerCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -190,7 +222,7 @@ func (rsu *RoundStatsUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := rsu.mutation.MatchPlayerIDs(); len(nodes) > 0 { + if nodes := _u.mutation.MatchPlayerIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -206,8 +238,8 @@ func (rsu *RoundStatsUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(rsu.modifiers...) - if n, err = sqlgraph.UpdateNodes(ctx, rsu.driver, _spec); err != nil { + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{roundstats.Label} } else if sqlgraph.IsConstraintError(err) { @@ -215,8 +247,8 @@ func (rsu *RoundStatsUpdate) sqlSave(ctx context.Context) (n int, err error) { } return 0, err } - rsu.mutation.done = true - return n, nil + _u.mutation.done = true + return _node, nil } // RoundStatsUpdateOne is the builder for updating a single RoundStats entity. @@ -229,108 +261,140 @@ type RoundStatsUpdateOne struct { } // SetRound sets the "round" field. -func (rsuo *RoundStatsUpdateOne) SetRound(u uint) *RoundStatsUpdateOne { - rsuo.mutation.ResetRound() - rsuo.mutation.SetRound(u) - return rsuo +func (_u *RoundStatsUpdateOne) SetRound(v uint) *RoundStatsUpdateOne { + _u.mutation.ResetRound() + _u.mutation.SetRound(v) + return _u } -// AddRound adds u to the "round" field. -func (rsuo *RoundStatsUpdateOne) AddRound(u int) *RoundStatsUpdateOne { - rsuo.mutation.AddRound(u) - return rsuo +// SetNillableRound sets the "round" field if the given value is not nil. +func (_u *RoundStatsUpdateOne) SetNillableRound(v *uint) *RoundStatsUpdateOne { + if v != nil { + _u.SetRound(*v) + } + return _u +} + +// AddRound adds value to the "round" field. +func (_u *RoundStatsUpdateOne) AddRound(v int) *RoundStatsUpdateOne { + _u.mutation.AddRound(v) + return _u } // SetBank sets the "bank" field. -func (rsuo *RoundStatsUpdateOne) SetBank(u uint) *RoundStatsUpdateOne { - rsuo.mutation.ResetBank() - rsuo.mutation.SetBank(u) - return rsuo +func (_u *RoundStatsUpdateOne) SetBank(v uint) *RoundStatsUpdateOne { + _u.mutation.ResetBank() + _u.mutation.SetBank(v) + return _u } -// AddBank adds u to the "bank" field. -func (rsuo *RoundStatsUpdateOne) AddBank(u int) *RoundStatsUpdateOne { - rsuo.mutation.AddBank(u) - return rsuo +// SetNillableBank sets the "bank" field if the given value is not nil. +func (_u *RoundStatsUpdateOne) SetNillableBank(v *uint) *RoundStatsUpdateOne { + if v != nil { + _u.SetBank(*v) + } + return _u +} + +// AddBank adds value to the "bank" field. +func (_u *RoundStatsUpdateOne) AddBank(v int) *RoundStatsUpdateOne { + _u.mutation.AddBank(v) + return _u } // SetEquipment sets the "equipment" field. -func (rsuo *RoundStatsUpdateOne) SetEquipment(u uint) *RoundStatsUpdateOne { - rsuo.mutation.ResetEquipment() - rsuo.mutation.SetEquipment(u) - return rsuo +func (_u *RoundStatsUpdateOne) SetEquipment(v uint) *RoundStatsUpdateOne { + _u.mutation.ResetEquipment() + _u.mutation.SetEquipment(v) + return _u } -// AddEquipment adds u to the "equipment" field. -func (rsuo *RoundStatsUpdateOne) AddEquipment(u int) *RoundStatsUpdateOne { - rsuo.mutation.AddEquipment(u) - return rsuo +// SetNillableEquipment sets the "equipment" field if the given value is not nil. +func (_u *RoundStatsUpdateOne) SetNillableEquipment(v *uint) *RoundStatsUpdateOne { + if v != nil { + _u.SetEquipment(*v) + } + return _u +} + +// AddEquipment adds value to the "equipment" field. +func (_u *RoundStatsUpdateOne) AddEquipment(v int) *RoundStatsUpdateOne { + _u.mutation.AddEquipment(v) + return _u } // SetSpent sets the "spent" field. -func (rsuo *RoundStatsUpdateOne) SetSpent(u uint) *RoundStatsUpdateOne { - rsuo.mutation.ResetSpent() - rsuo.mutation.SetSpent(u) - return rsuo +func (_u *RoundStatsUpdateOne) SetSpent(v uint) *RoundStatsUpdateOne { + _u.mutation.ResetSpent() + _u.mutation.SetSpent(v) + return _u } -// AddSpent adds u to the "spent" field. -func (rsuo *RoundStatsUpdateOne) AddSpent(u int) *RoundStatsUpdateOne { - rsuo.mutation.AddSpent(u) - return rsuo +// SetNillableSpent sets the "spent" field if the given value is not nil. +func (_u *RoundStatsUpdateOne) SetNillableSpent(v *uint) *RoundStatsUpdateOne { + if v != nil { + _u.SetSpent(*v) + } + return _u +} + +// AddSpent adds value to the "spent" field. +func (_u *RoundStatsUpdateOne) AddSpent(v int) *RoundStatsUpdateOne { + _u.mutation.AddSpent(v) + return _u } // SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID. -func (rsuo *RoundStatsUpdateOne) SetMatchPlayerID(id int) *RoundStatsUpdateOne { - rsuo.mutation.SetMatchPlayerID(id) - return rsuo +func (_u *RoundStatsUpdateOne) SetMatchPlayerID(id int) *RoundStatsUpdateOne { + _u.mutation.SetMatchPlayerID(id) + return _u } // SetNillableMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID if the given value is not nil. -func (rsuo *RoundStatsUpdateOne) SetNillableMatchPlayerID(id *int) *RoundStatsUpdateOne { +func (_u *RoundStatsUpdateOne) SetNillableMatchPlayerID(id *int) *RoundStatsUpdateOne { if id != nil { - rsuo = rsuo.SetMatchPlayerID(*id) + _u = _u.SetMatchPlayerID(*id) } - return rsuo + return _u } // SetMatchPlayer sets the "match_player" edge to the MatchPlayer entity. -func (rsuo *RoundStatsUpdateOne) SetMatchPlayer(m *MatchPlayer) *RoundStatsUpdateOne { - return rsuo.SetMatchPlayerID(m.ID) +func (_u *RoundStatsUpdateOne) SetMatchPlayer(v *MatchPlayer) *RoundStatsUpdateOne { + return _u.SetMatchPlayerID(v.ID) } // Mutation returns the RoundStatsMutation object of the builder. -func (rsuo *RoundStatsUpdateOne) Mutation() *RoundStatsMutation { - return rsuo.mutation +func (_u *RoundStatsUpdateOne) Mutation() *RoundStatsMutation { + return _u.mutation } // ClearMatchPlayer clears the "match_player" edge to the MatchPlayer entity. -func (rsuo *RoundStatsUpdateOne) ClearMatchPlayer() *RoundStatsUpdateOne { - rsuo.mutation.ClearMatchPlayer() - return rsuo +func (_u *RoundStatsUpdateOne) ClearMatchPlayer() *RoundStatsUpdateOne { + _u.mutation.ClearMatchPlayer() + return _u } // Where appends a list predicates to the RoundStatsUpdate builder. -func (rsuo *RoundStatsUpdateOne) Where(ps ...predicate.RoundStats) *RoundStatsUpdateOne { - rsuo.mutation.Where(ps...) - return rsuo +func (_u *RoundStatsUpdateOne) Where(ps ...predicate.RoundStats) *RoundStatsUpdateOne { + _u.mutation.Where(ps...) + return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. -func (rsuo *RoundStatsUpdateOne) Select(field string, fields ...string) *RoundStatsUpdateOne { - rsuo.fields = append([]string{field}, fields...) - return rsuo +func (_u *RoundStatsUpdateOne) Select(field string, fields ...string) *RoundStatsUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u } // Save executes the query and returns the updated RoundStats entity. -func (rsuo *RoundStatsUpdateOne) Save(ctx context.Context) (*RoundStats, error) { - return withHooks(ctx, rsuo.sqlSave, rsuo.mutation, rsuo.hooks) +func (_u *RoundStatsUpdateOne) Save(ctx context.Context) (*RoundStats, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (rsuo *RoundStatsUpdateOne) SaveX(ctx context.Context) *RoundStats { - node, err := rsuo.Save(ctx) +func (_u *RoundStatsUpdateOne) SaveX(ctx context.Context) *RoundStats { + node, err := _u.Save(ctx) if err != nil { panic(err) } @@ -338,32 +402,32 @@ func (rsuo *RoundStatsUpdateOne) SaveX(ctx context.Context) *RoundStats { } // Exec executes the query on the entity. -func (rsuo *RoundStatsUpdateOne) Exec(ctx context.Context) error { - _, err := rsuo.Save(ctx) +func (_u *RoundStatsUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (rsuo *RoundStatsUpdateOne) ExecX(ctx context.Context) { - if err := rsuo.Exec(ctx); err != nil { +func (_u *RoundStatsUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // 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 (_u *RoundStatsUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RoundStatsUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats, err error) { +func (_u *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats, err error) { _spec := sqlgraph.NewUpdateSpec(roundstats.Table, roundstats.Columns, sqlgraph.NewFieldSpec(roundstats.FieldID, field.TypeInt)) - id, ok := rsuo.mutation.ID() + id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "RoundStats.id" for update`)} } _spec.Node.ID.Value = id - if fields := rsuo.fields; len(fields) > 0 { + if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, roundstats.FieldID) for _, f := range fields { @@ -375,38 +439,38 @@ func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats } } } - if ps := rsuo.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := rsuo.mutation.Round(); ok { + if value, ok := _u.mutation.Round(); ok { _spec.SetField(roundstats.FieldRound, field.TypeUint, value) } - if value, ok := rsuo.mutation.AddedRound(); ok { + if value, ok := _u.mutation.AddedRound(); ok { _spec.AddField(roundstats.FieldRound, field.TypeUint, value) } - if value, ok := rsuo.mutation.Bank(); ok { + if value, ok := _u.mutation.Bank(); ok { _spec.SetField(roundstats.FieldBank, field.TypeUint, value) } - if value, ok := rsuo.mutation.AddedBank(); ok { + if value, ok := _u.mutation.AddedBank(); ok { _spec.AddField(roundstats.FieldBank, field.TypeUint, value) } - if value, ok := rsuo.mutation.Equipment(); ok { + if value, ok := _u.mutation.Equipment(); ok { _spec.SetField(roundstats.FieldEquipment, field.TypeUint, value) } - if value, ok := rsuo.mutation.AddedEquipment(); ok { + if value, ok := _u.mutation.AddedEquipment(); ok { _spec.AddField(roundstats.FieldEquipment, field.TypeUint, value) } - if value, ok := rsuo.mutation.Spent(); ok { + if value, ok := _u.mutation.Spent(); ok { _spec.SetField(roundstats.FieldSpent, field.TypeUint, value) } - if value, ok := rsuo.mutation.AddedSpent(); ok { + if value, ok := _u.mutation.AddedSpent(); ok { _spec.AddField(roundstats.FieldSpent, field.TypeUint, value) } - if rsuo.mutation.MatchPlayerCleared() { + if _u.mutation.MatchPlayerCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -419,7 +483,7 @@ func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := rsuo.mutation.MatchPlayerIDs(); len(nodes) > 0 { + if nodes := _u.mutation.MatchPlayerIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -435,11 +499,11 @@ func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(rsuo.modifiers...) - _node = &RoundStats{config: rsuo.config} + _spec.AddModifiers(_u.modifiers...) + _node = &RoundStats{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, rsuo.driver, _spec); err != nil { + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{roundstats.Label} } else if sqlgraph.IsConstraintError(err) { @@ -447,6 +511,6 @@ func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats } return nil, err } - rsuo.mutation.done = true + _u.mutation.done = true return _node, nil } diff --git a/ent/runtime/runtime.go b/ent/runtime/runtime.go index 1445c0a..487cedc 100644 --- a/ent/runtime/runtime.go +++ b/ent/runtime/runtime.go @@ -5,6 +5,6 @@ package runtime // The schema-stitching logic is generated in somegit.dev/csgowtf/csgowtfd/ent/runtime.go const ( - Version = "v0.12.3" // Version of ent codegen. - Sum = "h1:N5lO2EOrHpCH5HYfiMOCHYbo+oh5M8GjT0/cx5x6xkk=" // Sum of ent codegen. + Version = "v0.14.5" // Version of ent codegen. + Sum = "h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4=" // Sum of ent codegen. ) diff --git a/ent/spray.go b/ent/spray.go index a98d663..d9be62d 100644 --- a/ent/spray.go +++ b/ent/spray.go @@ -40,12 +40,10 @@ type SprayEdges struct { // MatchPlayersOrErr returns the MatchPlayers value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e SprayEdges) MatchPlayersOrErr() (*MatchPlayer, error) { - if e.loadedTypes[0] { - if e.MatchPlayers == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: matchplayer.Label} - } + if e.MatchPlayers != nil { return e.MatchPlayers, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: matchplayer.Label} } return nil, &NotLoadedError{edge: "match_players"} } @@ -70,7 +68,7 @@ func (*Spray) scanValues(columns []string) ([]any, error) { // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the Spray fields. -func (s *Spray) assignValues(columns []string, values []any) error { +func (_m *Spray) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } @@ -81,28 +79,28 @@ func (s *Spray) assignValues(columns []string, values []any) error { if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - s.ID = int(value.Int64) + _m.ID = int(value.Int64) case spray.FieldWeapon: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field weapon", values[i]) } else if value.Valid { - s.Weapon = int(value.Int64) + _m.Weapon = int(value.Int64) } case spray.FieldSpray: if value, ok := values[i].(*[]byte); !ok { return fmt.Errorf("unexpected type %T for field spray", values[i]) } else if value != nil { - s.Spray = *value + _m.Spray = *value } case spray.ForeignKeys[0]: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for edge-field match_player_spray", value) } else if value.Valid { - s.match_player_spray = new(int) - *s.match_player_spray = int(value.Int64) + _m.match_player_spray = new(int) + *_m.match_player_spray = int(value.Int64) } default: - s.selectValues.Set(columns[i], values[i]) + _m.selectValues.Set(columns[i], values[i]) } } return nil @@ -110,43 +108,43 @@ func (s *Spray) assignValues(columns []string, values []any) error { // Value returns the ent.Value that was dynamically selected and assigned to the Spray. // This includes values selected through modifiers, order, etc. -func (s *Spray) Value(name string) (ent.Value, error) { - return s.selectValues.Get(name) +func (_m *Spray) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) } // QueryMatchPlayers queries the "match_players" edge of the Spray entity. -func (s *Spray) QueryMatchPlayers() *MatchPlayerQuery { - return NewSprayClient(s.config).QueryMatchPlayers(s) +func (_m *Spray) QueryMatchPlayers() *MatchPlayerQuery { + return NewSprayClient(_m.config).QueryMatchPlayers(_m) } // Update returns a builder for updating this Spray. // Note that you need to call Spray.Unwrap() before calling this method if this Spray // was returned from a transaction, and the transaction was committed or rolled back. -func (s *Spray) Update() *SprayUpdateOne { - return NewSprayClient(s.config).UpdateOne(s) +func (_m *Spray) Update() *SprayUpdateOne { + return NewSprayClient(_m.config).UpdateOne(_m) } // 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) +func (_m *Spray) Unwrap() *Spray { + _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: Spray is not a transactional entity") } - s.config.driver = _tx.drv - return s + _m.config.driver = _tx.drv + return _m } // String implements the fmt.Stringer. -func (s *Spray) String() string { +func (_m *Spray) String() string { var builder strings.Builder builder.WriteString("Spray(") - builder.WriteString(fmt.Sprintf("id=%v, ", s.ID)) + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("weapon=") - builder.WriteString(fmt.Sprintf("%v", s.Weapon)) + builder.WriteString(fmt.Sprintf("%v", _m.Weapon)) builder.WriteString(", ") builder.WriteString("spray=") - builder.WriteString(fmt.Sprintf("%v", s.Spray)) + builder.WriteString(fmt.Sprintf("%v", _m.Spray)) builder.WriteByte(')') return builder.String() } diff --git a/ent/spray/where.go b/ent/spray/where.go index 039fb9e..92d0759 100644 --- a/ent/spray/where.go +++ b/ent/spray/where.go @@ -168,32 +168,15 @@ func HasMatchPlayersWith(preds ...predicate.MatchPlayer) predicate.Spray { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Spray) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Spray(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Spray) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Spray(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Spray) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Spray(sql.NotPredicates(p)) } diff --git a/ent/spray_create.go b/ent/spray_create.go index 102408c..728f5cd 100644 --- a/ent/spray_create.go +++ b/ent/spray_create.go @@ -21,49 +21,49 @@ type SprayCreate struct { } // SetWeapon sets the "weapon" field. -func (sc *SprayCreate) SetWeapon(i int) *SprayCreate { - sc.mutation.SetWeapon(i) - return sc +func (_c *SprayCreate) SetWeapon(v int) *SprayCreate { + _c.mutation.SetWeapon(v) + return _c } // SetSpray sets the "spray" field. -func (sc *SprayCreate) SetSpray(b []byte) *SprayCreate { - sc.mutation.SetSpray(b) - return sc +func (_c *SprayCreate) SetSpray(v []byte) *SprayCreate { + _c.mutation.SetSpray(v) + return _c } // SetMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID. -func (sc *SprayCreate) SetMatchPlayersID(id int) *SprayCreate { - sc.mutation.SetMatchPlayersID(id) - return sc +func (_c *SprayCreate) SetMatchPlayersID(id int) *SprayCreate { + _c.mutation.SetMatchPlayersID(id) + return _c } // SetNillableMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID if the given value is not nil. -func (sc *SprayCreate) SetNillableMatchPlayersID(id *int) *SprayCreate { +func (_c *SprayCreate) SetNillableMatchPlayersID(id *int) *SprayCreate { if id != nil { - sc = sc.SetMatchPlayersID(*id) + _c = _c.SetMatchPlayersID(*id) } - return sc + return _c } // SetMatchPlayers sets the "match_players" edge to the MatchPlayer entity. -func (sc *SprayCreate) SetMatchPlayers(m *MatchPlayer) *SprayCreate { - return sc.SetMatchPlayersID(m.ID) +func (_c *SprayCreate) SetMatchPlayers(v *MatchPlayer) *SprayCreate { + return _c.SetMatchPlayersID(v.ID) } // Mutation returns the SprayMutation object of the builder. -func (sc *SprayCreate) Mutation() *SprayMutation { - return sc.mutation +func (_c *SprayCreate) Mutation() *SprayMutation { + return _c.mutation } // Save creates the Spray in the database. -func (sc *SprayCreate) Save(ctx context.Context) (*Spray, error) { - return withHooks(ctx, sc.sqlSave, sc.mutation, sc.hooks) +func (_c *SprayCreate) Save(ctx context.Context) (*Spray, error) { + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. -func (sc *SprayCreate) SaveX(ctx context.Context) *Spray { - v, err := sc.Save(ctx) +func (_c *SprayCreate) SaveX(ctx context.Context) *Spray { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -71,35 +71,35 @@ func (sc *SprayCreate) SaveX(ctx context.Context) *Spray { } // Exec executes the query. -func (sc *SprayCreate) Exec(ctx context.Context) error { - _, err := sc.Save(ctx) +func (_c *SprayCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (sc *SprayCreate) ExecX(ctx context.Context) { - if err := sc.Exec(ctx); err != nil { +func (_c *SprayCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (sc *SprayCreate) check() error { - if _, ok := sc.mutation.Weapon(); !ok { +func (_c *SprayCreate) check() error { + if _, ok := _c.mutation.Weapon(); !ok { return &ValidationError{Name: "weapon", err: errors.New(`ent: missing required field "Spray.weapon"`)} } - if _, ok := sc.mutation.Spray(); !ok { + if _, ok := _c.mutation.Spray(); !ok { return &ValidationError{Name: "spray", err: errors.New(`ent: missing required field "Spray.spray"`)} } return nil } -func (sc *SprayCreate) sqlSave(ctx context.Context) (*Spray, error) { - if err := sc.check(); err != nil { +func (_c *SprayCreate) sqlSave(ctx context.Context) (*Spray, error) { + if err := _c.check(); err != nil { return nil, err } - _node, _spec := sc.createSpec() - if err := sqlgraph.CreateNode(ctx, sc.driver, _spec); err != nil { + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -107,25 +107,25 @@ func (sc *SprayCreate) sqlSave(ctx context.Context) (*Spray, error) { } id := _spec.ID.Value.(int64) _node.ID = int(id) - sc.mutation.id = &_node.ID - sc.mutation.done = true + _c.mutation.id = &_node.ID + _c.mutation.done = true return _node, nil } -func (sc *SprayCreate) createSpec() (*Spray, *sqlgraph.CreateSpec) { +func (_c *SprayCreate) createSpec() (*Spray, *sqlgraph.CreateSpec) { var ( - _node = &Spray{config: sc.config} + _node = &Spray{config: _c.config} _spec = sqlgraph.NewCreateSpec(spray.Table, sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt)) ) - if value, ok := sc.mutation.Weapon(); ok { + if value, ok := _c.mutation.Weapon(); ok { _spec.SetField(spray.FieldWeapon, field.TypeInt, value) _node.Weapon = value } - if value, ok := sc.mutation.Spray(); ok { + if value, ok := _c.mutation.Spray(); ok { _spec.SetField(spray.FieldSpray, field.TypeBytes, value) _node.Spray = value } - if nodes := sc.mutation.MatchPlayersIDs(); len(nodes) > 0 { + if nodes := _c.mutation.MatchPlayersIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -148,17 +148,21 @@ func (sc *SprayCreate) createSpec() (*Spray, *sqlgraph.CreateSpec) { // SprayCreateBulk is the builder for creating many Spray entities in bulk. type SprayCreateBulk struct { config + err error builders []*SprayCreate } // Save creates the Spray entities in the database. -func (scb *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) { - specs := make([]*sqlgraph.CreateSpec, len(scb.builders)) - nodes := make([]*Spray, len(scb.builders)) - mutators := make([]Mutator, len(scb.builders)) - for i := range scb.builders { +func (_c *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*Spray, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { func(i int, root context.Context) { - builder := scb.builders[i] + builder := _c.builders[i] var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*SprayMutation) if !ok { @@ -171,11 +175,11 @@ func (scb *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) { var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, scb.builders[i+1].mutation) + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, scb.driver, spec); err != nil { + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -199,7 +203,7 @@ func (scb *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) { }(i, ctx) } if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, scb.builders[0].mutation); err != nil { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { return nil, err } } @@ -207,8 +211,8 @@ func (scb *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) { } // SaveX is like Save, but panics if an error occurs. -func (scb *SprayCreateBulk) SaveX(ctx context.Context) []*Spray { - v, err := scb.Save(ctx) +func (_c *SprayCreateBulk) SaveX(ctx context.Context) []*Spray { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -216,14 +220,14 @@ func (scb *SprayCreateBulk) SaveX(ctx context.Context) []*Spray { } // Exec executes the query. -func (scb *SprayCreateBulk) Exec(ctx context.Context) error { - _, err := scb.Save(ctx) +func (_c *SprayCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (scb *SprayCreateBulk) ExecX(ctx context.Context) { - if err := scb.Exec(ctx); err != nil { +func (_c *SprayCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } diff --git a/ent/spray_delete.go b/ent/spray_delete.go index c48279b..bb719f2 100644 --- a/ent/spray_delete.go +++ b/ent/spray_delete.go @@ -20,56 +20,56 @@ type SprayDelete struct { } // Where appends a list predicates to the SprayDelete builder. -func (sd *SprayDelete) Where(ps ...predicate.Spray) *SprayDelete { - sd.mutation.Where(ps...) - return sd +func (_d *SprayDelete) Where(ps ...predicate.Spray) *SprayDelete { + _d.mutation.Where(ps...) + return _d } // Exec executes the deletion query and returns how many vertices were deleted. -func (sd *SprayDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, sd.sqlExec, sd.mutation, sd.hooks) +func (_d *SprayDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) } // ExecX is like Exec, but panics if an error occurs. -func (sd *SprayDelete) ExecX(ctx context.Context) int { - n, err := sd.Exec(ctx) +func (_d *SprayDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) if err != nil { panic(err) } return n } -func (sd *SprayDelete) sqlExec(ctx context.Context) (int, error) { +func (_d *SprayDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(spray.Table, sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt)) - if ps := sd.mutation.predicates; len(ps) > 0 { + if ps := _d.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - affected, err := sqlgraph.DeleteNodes(ctx, sd.driver, _spec) + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } - sd.mutation.done = true + _d.mutation.done = true return affected, err } // SprayDeleteOne is the builder for deleting a single Spray entity. type SprayDeleteOne struct { - sd *SprayDelete + _d *SprayDelete } // Where appends a list predicates to the SprayDelete builder. -func (sdo *SprayDeleteOne) Where(ps ...predicate.Spray) *SprayDeleteOne { - sdo.sd.mutation.Where(ps...) - return sdo +func (_d *SprayDeleteOne) Where(ps ...predicate.Spray) *SprayDeleteOne { + _d._d.mutation.Where(ps...) + return _d } // Exec executes the deletion query. -func (sdo *SprayDeleteOne) Exec(ctx context.Context) error { - n, err := sdo.sd.Exec(ctx) +func (_d *SprayDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) switch { case err != nil: return err @@ -81,8 +81,8 @@ func (sdo *SprayDeleteOne) Exec(ctx context.Context) error { } // ExecX is like Exec, but panics if an error occurs. -func (sdo *SprayDeleteOne) ExecX(ctx context.Context) { - if err := sdo.Exec(ctx); err != nil { +func (_d *SprayDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { panic(err) } } diff --git a/ent/spray_query.go b/ent/spray_query.go index 78ad9b4..be38126 100644 --- a/ent/spray_query.go +++ b/ent/spray_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -31,44 +32,44 @@ type SprayQuery struct { } // Where adds a new predicate for the SprayQuery builder. -func (sq *SprayQuery) Where(ps ...predicate.Spray) *SprayQuery { - sq.predicates = append(sq.predicates, ps...) - return sq +func (_q *SprayQuery) Where(ps ...predicate.Spray) *SprayQuery { + _q.predicates = append(_q.predicates, ps...) + return _q } // Limit the number of records to be returned by this query. -func (sq *SprayQuery) Limit(limit int) *SprayQuery { - sq.ctx.Limit = &limit - return sq +func (_q *SprayQuery) Limit(limit int) *SprayQuery { + _q.ctx.Limit = &limit + return _q } // Offset to start from. -func (sq *SprayQuery) Offset(offset int) *SprayQuery { - sq.ctx.Offset = &offset - return sq +func (_q *SprayQuery) Offset(offset int) *SprayQuery { + _q.ctx.Offset = &offset + return _q } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. -func (sq *SprayQuery) Unique(unique bool) *SprayQuery { - sq.ctx.Unique = &unique - return sq +func (_q *SprayQuery) Unique(unique bool) *SprayQuery { + _q.ctx.Unique = &unique + return _q } // Order specifies how the records should be ordered. -func (sq *SprayQuery) Order(o ...spray.OrderOption) *SprayQuery { - sq.order = append(sq.order, o...) - return sq +func (_q *SprayQuery) Order(o ...spray.OrderOption) *SprayQuery { + _q.order = append(_q.order, o...) + return _q } // QueryMatchPlayers chains the current query on the "match_players" edge. -func (sq *SprayQuery) QueryMatchPlayers() *MatchPlayerQuery { - query := (&MatchPlayerClient{config: sq.config}).Query() +func (_q *SprayQuery) QueryMatchPlayers() *MatchPlayerQuery { + query := (&MatchPlayerClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := sq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := sq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -77,7 +78,7 @@ func (sq *SprayQuery) QueryMatchPlayers() *MatchPlayerQuery { sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, spray.MatchPlayersTable, spray.MatchPlayersColumn), ) - fromU = sqlgraph.SetNeighbors(sq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query @@ -85,8 +86,8 @@ func (sq *SprayQuery) QueryMatchPlayers() *MatchPlayerQuery { // First returns the first Spray entity from the query. // Returns a *NotFoundError when no Spray was found. -func (sq *SprayQuery) First(ctx context.Context) (*Spray, error) { - nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, "First")) +func (_q *SprayQuery) First(ctx context.Context) (*Spray, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -97,8 +98,8 @@ func (sq *SprayQuery) First(ctx context.Context) (*Spray, error) { } // FirstX is like First, but panics if an error occurs. -func (sq *SprayQuery) FirstX(ctx context.Context) *Spray { - node, err := sq.First(ctx) +func (_q *SprayQuery) FirstX(ctx context.Context) *Spray { + node, err := _q.First(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -107,9 +108,9 @@ func (sq *SprayQuery) FirstX(ctx context.Context) *Spray { // FirstID returns the first Spray ID from the query. // Returns a *NotFoundError when no Spray ID was found. -func (sq *SprayQuery) FirstID(ctx context.Context) (id int, err error) { +func (_q *SprayQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, "FirstID")); err != nil { + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -120,8 +121,8 @@ func (sq *SprayQuery) FirstID(ctx context.Context) (id int, err error) { } // FirstIDX is like FirstID, but panics if an error occurs. -func (sq *SprayQuery) FirstIDX(ctx context.Context) int { - id, err := sq.FirstID(ctx) +func (_q *SprayQuery) FirstIDX(ctx context.Context) int { + id, err := _q.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -131,8 +132,8 @@ func (sq *SprayQuery) FirstIDX(ctx context.Context) int { // Only returns a single Spray entity found by the query, ensuring it only returns one. // Returns a *NotSingularError when more than one Spray entity is found. // Returns a *NotFoundError when no Spray entities are found. -func (sq *SprayQuery) Only(ctx context.Context) (*Spray, error) { - nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, "Only")) +func (_q *SprayQuery) Only(ctx context.Context) (*Spray, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -147,8 +148,8 @@ func (sq *SprayQuery) Only(ctx context.Context) (*Spray, error) { } // OnlyX is like Only, but panics if an error occurs. -func (sq *SprayQuery) OnlyX(ctx context.Context) *Spray { - node, err := sq.Only(ctx) +func (_q *SprayQuery) OnlyX(ctx context.Context) *Spray { + node, err := _q.Only(ctx) if err != nil { panic(err) } @@ -158,9 +159,9 @@ func (sq *SprayQuery) OnlyX(ctx context.Context) *Spray { // OnlyID is like Only, but returns the only Spray ID in the query. // Returns a *NotSingularError when more than one Spray ID is found. // Returns a *NotFoundError when no entities are found. -func (sq *SprayQuery) OnlyID(ctx context.Context) (id int, err error) { +func (_q *SprayQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = sq.Limit(2).IDs(setContextOp(ctx, sq.ctx, "OnlyID")); err != nil { + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -175,8 +176,8 @@ func (sq *SprayQuery) OnlyID(ctx context.Context) (id int, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (sq *SprayQuery) OnlyIDX(ctx context.Context) int { - id, err := sq.OnlyID(ctx) +func (_q *SprayQuery) OnlyIDX(ctx context.Context) int { + id, err := _q.OnlyID(ctx) if err != nil { panic(err) } @@ -184,18 +185,18 @@ func (sq *SprayQuery) OnlyIDX(ctx context.Context) int { } // All executes the query and returns a list of Sprays. -func (sq *SprayQuery) All(ctx context.Context) ([]*Spray, error) { - ctx = setContextOp(ctx, sq.ctx, "All") - if err := sq.prepareQuery(ctx); err != nil { +func (_q *SprayQuery) All(ctx context.Context) ([]*Spray, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { return nil, err } qr := querierAll[[]*Spray, *SprayQuery]() - return withInterceptors[[]*Spray](ctx, sq, qr, sq.inters) + return withInterceptors[[]*Spray](ctx, _q, qr, _q.inters) } // AllX is like All, but panics if an error occurs. -func (sq *SprayQuery) AllX(ctx context.Context) []*Spray { - nodes, err := sq.All(ctx) +func (_q *SprayQuery) AllX(ctx context.Context) []*Spray { + nodes, err := _q.All(ctx) if err != nil { panic(err) } @@ -203,20 +204,20 @@ func (sq *SprayQuery) AllX(ctx context.Context) []*Spray { } // IDs executes the query and returns a list of Spray IDs. -func (sq *SprayQuery) IDs(ctx context.Context) (ids []int, err error) { - if sq.ctx.Unique == nil && sq.path != nil { - sq.Unique(true) +func (_q *SprayQuery) IDs(ctx context.Context) (ids []int, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) } - ctx = setContextOp(ctx, sq.ctx, "IDs") - if err = sq.Select(spray.FieldID).Scan(ctx, &ids); err != nil { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(spray.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. -func (sq *SprayQuery) IDsX(ctx context.Context) []int { - ids, err := sq.IDs(ctx) +func (_q *SprayQuery) IDsX(ctx context.Context) []int { + ids, err := _q.IDs(ctx) if err != nil { panic(err) } @@ -224,17 +225,17 @@ func (sq *SprayQuery) IDsX(ctx context.Context) []int { } // Count returns the count of the given query. -func (sq *SprayQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, sq.ctx, "Count") - if err := sq.prepareQuery(ctx); err != nil { +func (_q *SprayQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { return 0, err } - return withInterceptors[int](ctx, sq, querierCount[*SprayQuery](), sq.inters) + return withInterceptors[int](ctx, _q, querierCount[*SprayQuery](), _q.inters) } // CountX is like Count, but panics if an error occurs. -func (sq *SprayQuery) CountX(ctx context.Context) int { - count, err := sq.Count(ctx) +func (_q *SprayQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) if err != nil { panic(err) } @@ -242,9 +243,9 @@ func (sq *SprayQuery) CountX(ctx context.Context) int { } // Exist returns true if the query has elements in the graph. -func (sq *SprayQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, sq.ctx, "Exist") - switch _, err := sq.FirstID(ctx); { +func (_q *SprayQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { case IsNotFound(err): return false, nil case err != nil: @@ -255,8 +256,8 @@ func (sq *SprayQuery) Exist(ctx context.Context) (bool, error) { } // ExistX is like Exist, but panics if an error occurs. -func (sq *SprayQuery) ExistX(ctx context.Context) bool { - exist, err := sq.Exist(ctx) +func (_q *SprayQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) if err != nil { panic(err) } @@ -265,32 +266,33 @@ func (sq *SprayQuery) ExistX(ctx context.Context) bool { // Clone returns a duplicate of the SprayQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. -func (sq *SprayQuery) Clone() *SprayQuery { - if sq == nil { +func (_q *SprayQuery) Clone() *SprayQuery { + if _q == nil { return nil } return &SprayQuery{ - config: sq.config, - ctx: sq.ctx.Clone(), - order: append([]spray.OrderOption{}, sq.order...), - inters: append([]Interceptor{}, sq.inters...), - predicates: append([]predicate.Spray{}, sq.predicates...), - withMatchPlayers: sq.withMatchPlayers.Clone(), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]spray.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.Spray{}, _q.predicates...), + withMatchPlayers: _q.withMatchPlayers.Clone(), // clone intermediate query. - sql: sq.sql.Clone(), - path: sq.path, + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), } } // WithMatchPlayers tells the query-builder to eager-load the nodes that are connected to // the "match_players" edge. The optional arguments are used to configure the query builder of the edge. -func (sq *SprayQuery) WithMatchPlayers(opts ...func(*MatchPlayerQuery)) *SprayQuery { - query := (&MatchPlayerClient{config: sq.config}).Query() +func (_q *SprayQuery) WithMatchPlayers(opts ...func(*MatchPlayerQuery)) *SprayQuery { + query := (&MatchPlayerClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - sq.withMatchPlayers = query - return sq + _q.withMatchPlayers = query + return _q } // GroupBy is used to group vertices by one or more fields/columns. @@ -307,10 +309,10 @@ 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 { - sq.ctx.Fields = append([]string{field}, fields...) - grbuild := &SprayGroupBy{build: sq} - grbuild.flds = &sq.ctx.Fields +func (_q *SprayQuery) GroupBy(field string, fields ...string) *SprayGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &SprayGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields grbuild.label = spray.Label grbuild.scan = grbuild.Scan return grbuild @@ -328,55 +330,55 @@ 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.ctx.Fields = append(sq.ctx.Fields, fields...) - sbuild := &SpraySelect{SprayQuery: sq} +func (_q *SprayQuery) Select(fields ...string) *SpraySelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &SpraySelect{SprayQuery: _q} sbuild.label = spray.Label - sbuild.flds, sbuild.scan = &sq.ctx.Fields, sbuild.Scan + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan return sbuild } // Aggregate returns a SpraySelect configured with the given aggregations. -func (sq *SprayQuery) Aggregate(fns ...AggregateFunc) *SpraySelect { - return sq.Select().Aggregate(fns...) +func (_q *SprayQuery) Aggregate(fns ...AggregateFunc) *SpraySelect { + return _q.Select().Aggregate(fns...) } -func (sq *SprayQuery) prepareQuery(ctx context.Context) error { - for _, inter := range sq.inters { +func (_q *SprayQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { if inter == nil { return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") } if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, sq); err != nil { + if err := trv.Traverse(ctx, _q); err != nil { return err } } } - for _, f := range sq.ctx.Fields { + for _, f := range _q.ctx.Fields { if !spray.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } - if sq.path != nil { - prev, err := sq.path(ctx) + if _q.path != nil { + prev, err := _q.path(ctx) if err != nil { return err } - sq.sql = prev + _q.sql = prev } return nil } -func (sq *SprayQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Spray, error) { +func (_q *SprayQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Spray, error) { var ( nodes = []*Spray{} - withFKs = sq.withFKs - _spec = sq.querySpec() + withFKs = _q.withFKs + _spec = _q.querySpec() loadedTypes = [1]bool{ - sq.withMatchPlayers != nil, + _q.withMatchPlayers != nil, } ) - if sq.withMatchPlayers != nil { + if _q.withMatchPlayers != nil { withFKs = true } if withFKs { @@ -386,25 +388,25 @@ func (sq *SprayQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Spray, return (*Spray).scanValues(nil, columns) } _spec.Assign = func(columns []string, values []any) error { - node := &Spray{config: sq.config} + node := &Spray{config: _q.config} nodes = append(nodes, node) node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) } - if len(sq.modifiers) > 0 { - _spec.Modifiers = sq.modifiers + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } for i := range hooks { hooks[i](ctx, _spec) } - if err := sqlgraph.QueryNodes(ctx, sq.driver, _spec); err != nil { + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { return nil, err } if len(nodes) == 0 { return nodes, nil } - if query := sq.withMatchPlayers; query != nil { - if err := sq.loadMatchPlayers(ctx, query, nodes, nil, + if query := _q.withMatchPlayers; query != nil { + if err := _q.loadMatchPlayers(ctx, query, nodes, nil, func(n *Spray, e *MatchPlayer) { n.Edges.MatchPlayers = e }); err != nil { return nil, err } @@ -412,7 +414,7 @@ func (sq *SprayQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Spray, return nodes, nil } -func (sq *SprayQuery) loadMatchPlayers(ctx context.Context, query *MatchPlayerQuery, nodes []*Spray, init func(*Spray), assign func(*Spray, *MatchPlayer)) error { +func (_q *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 { @@ -445,27 +447,27 @@ func (sq *SprayQuery) loadMatchPlayers(ctx context.Context, query *MatchPlayerQu return nil } -func (sq *SprayQuery) sqlCount(ctx context.Context) (int, error) { - _spec := sq.querySpec() - if len(sq.modifiers) > 0 { - _spec.Modifiers = sq.modifiers +func (_q *SprayQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } - _spec.Node.Columns = sq.ctx.Fields - if len(sq.ctx.Fields) > 0 { - _spec.Unique = sq.ctx.Unique != nil && *sq.ctx.Unique + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique } - return sqlgraph.CountNodes(ctx, sq.driver, _spec) + return sqlgraph.CountNodes(ctx, _q.driver, _spec) } -func (sq *SprayQuery) querySpec() *sqlgraph.QuerySpec { +func (_q *SprayQuery) querySpec() *sqlgraph.QuerySpec { _spec := sqlgraph.NewQuerySpec(spray.Table, spray.Columns, sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt)) - _spec.From = sq.sql - if unique := sq.ctx.Unique; unique != nil { + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { _spec.Unique = *unique - } else if sq.path != nil { + } else if _q.path != nil { _spec.Unique = true } - if fields := sq.ctx.Fields; len(fields) > 0 { + if fields := _q.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, spray.FieldID) for i := range fields { @@ -474,20 +476,20 @@ func (sq *SprayQuery) querySpec() *sqlgraph.QuerySpec { } } } - if ps := sq.predicates; len(ps) > 0 { + if ps := _q.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if limit := sq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := sq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { _spec.Offset = *offset } - if ps := sq.order; len(ps) > 0 { + if ps := _q.order; len(ps) > 0 { _spec.Order = func(selector *sql.Selector) { for i := range ps { ps[i](selector) @@ -497,45 +499,45 @@ func (sq *SprayQuery) querySpec() *sqlgraph.QuerySpec { return _spec } -func (sq *SprayQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(sq.driver.Dialect()) +func (_q *SprayQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) t1 := builder.Table(spray.Table) - columns := sq.ctx.Fields + columns := _q.ctx.Fields if len(columns) == 0 { columns = spray.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) - if sq.sql != nil { - selector = sq.sql + if _q.sql != nil { + selector = _q.sql selector.Select(selector.Columns(columns...)...) } - if sq.ctx.Unique != nil && *sq.ctx.Unique { + if _q.ctx.Unique != nil && *_q.ctx.Unique { selector.Distinct() } - for _, m := range sq.modifiers { + for _, m := range _q.modifiers { m(selector) } - for _, p := range sq.predicates { + for _, p := range _q.predicates { p(selector) } - for _, p := range sq.order { + for _, p := range _q.order { p(selector) } - if offset := sq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { // limit is mandatory for offset clause. We start // with default value, and override it below if needed. selector.Offset(*offset).Limit(math.MaxInt32) } - if limit := sq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector } // Modify adds a query modifier for attaching custom logic to queries. -func (sq *SprayQuery) Modify(modifiers ...func(s *sql.Selector)) *SpraySelect { - sq.modifiers = append(sq.modifiers, modifiers...) - return sq.Select() +func (_q *SprayQuery) Modify(modifiers ...func(s *sql.Selector)) *SpraySelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() } // SprayGroupBy is the group-by builder for Spray entities. @@ -545,41 +547,41 @@ type SprayGroupBy struct { } // Aggregate adds the given aggregation functions to the group-by query. -func (sgb *SprayGroupBy) Aggregate(fns ...AggregateFunc) *SprayGroupBy { - sgb.fns = append(sgb.fns, fns...) - return sgb +func (_g *SprayGroupBy) Aggregate(fns ...AggregateFunc) *SprayGroupBy { + _g.fns = append(_g.fns, fns...) + return _g } // Scan applies the selector query and scans the result into the given value. -func (sgb *SprayGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, sgb.build.ctx, "GroupBy") - if err := sgb.build.prepareQuery(ctx); err != nil { +func (_g *SprayGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*SprayQuery, *SprayGroupBy](ctx, sgb.build, sgb, sgb.build.inters, v) + return scanWithInterceptors[*SprayQuery, *SprayGroupBy](ctx, _g.build, _g, _g.build.inters, v) } -func (sgb *SprayGroupBy) sqlScan(ctx context.Context, root *SprayQuery, v any) error { +func (_g *SprayGroupBy) sqlScan(ctx context.Context, root *SprayQuery, v any) error { selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(sgb.fns)) - for _, fn := range sgb.fns { + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { aggregation = append(aggregation, fn(selector)) } if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*sgb.flds)+len(sgb.fns)) - for _, f := range *sgb.flds { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { columns = append(columns, selector.C(f)) } columns = append(columns, aggregation...) selector.Select(columns...) } - selector.GroupBy(selector.Columns(*sgb.flds...)...) + selector.GroupBy(selector.Columns(*_g.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := sgb.build.driver.Query(ctx, query, args, rows); err != nil { + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -593,27 +595,27 @@ type SpraySelect struct { } // Aggregate adds the given aggregation functions to the selector query. -func (ss *SpraySelect) Aggregate(fns ...AggregateFunc) *SpraySelect { - ss.fns = append(ss.fns, fns...) - return ss +func (_s *SpraySelect) Aggregate(fns ...AggregateFunc) *SpraySelect { + _s.fns = append(_s.fns, fns...) + return _s } // Scan applies the selector query and scans the result into the given value. -func (ss *SpraySelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ss.ctx, "Select") - if err := ss.prepareQuery(ctx); err != nil { +func (_s *SpraySelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*SprayQuery, *SpraySelect](ctx, ss.SprayQuery, ss, ss.inters, v) + return scanWithInterceptors[*SprayQuery, *SpraySelect](ctx, _s.SprayQuery, _s, _s.inters, v) } -func (ss *SpraySelect) sqlScan(ctx context.Context, root *SprayQuery, v any) error { +func (_s *SpraySelect) sqlScan(ctx context.Context, root *SprayQuery, v any) error { selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(ss.fns)) - for _, fn := range ss.fns { + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { aggregation = append(aggregation, fn(selector)) } - switch n := len(*ss.selector.flds); { + switch n := len(*_s.selector.flds); { case n == 0 && len(aggregation) > 0: selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: @@ -621,7 +623,7 @@ func (ss *SpraySelect) sqlScan(ctx context.Context, root *SprayQuery, v any) err } rows := &sql.Rows{} query, args := selector.Query() - if err := ss.driver.Query(ctx, query, args, rows); err != nil { + if err := _s.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -629,7 +631,7 @@ func (ss *SpraySelect) sqlScan(ctx context.Context, root *SprayQuery, v any) err } // Modify adds a query modifier for attaching custom logic to queries. -func (ss *SpraySelect) Modify(modifiers ...func(s *sql.Selector)) *SpraySelect { - ss.modifiers = append(ss.modifiers, modifiers...) - return ss +func (_s *SpraySelect) Modify(modifiers ...func(s *sql.Selector)) *SpraySelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s } diff --git a/ent/spray_update.go b/ent/spray_update.go index cc75c68..a3dbd14 100644 --- a/ent/spray_update.go +++ b/ent/spray_update.go @@ -24,68 +24,76 @@ type SprayUpdate struct { } // Where appends a list predicates to the SprayUpdate builder. -func (su *SprayUpdate) Where(ps ...predicate.Spray) *SprayUpdate { - su.mutation.Where(ps...) - return su +func (_u *SprayUpdate) Where(ps ...predicate.Spray) *SprayUpdate { + _u.mutation.Where(ps...) + return _u } // SetWeapon sets the "weapon" field. -func (su *SprayUpdate) SetWeapon(i int) *SprayUpdate { - su.mutation.ResetWeapon() - su.mutation.SetWeapon(i) - return su +func (_u *SprayUpdate) SetWeapon(v int) *SprayUpdate { + _u.mutation.ResetWeapon() + _u.mutation.SetWeapon(v) + return _u } -// AddWeapon adds i to the "weapon" field. -func (su *SprayUpdate) AddWeapon(i int) *SprayUpdate { - su.mutation.AddWeapon(i) - return su +// SetNillableWeapon sets the "weapon" field if the given value is not nil. +func (_u *SprayUpdate) SetNillableWeapon(v *int) *SprayUpdate { + if v != nil { + _u.SetWeapon(*v) + } + return _u +} + +// AddWeapon adds value to the "weapon" field. +func (_u *SprayUpdate) AddWeapon(v int) *SprayUpdate { + _u.mutation.AddWeapon(v) + return _u } // SetSpray sets the "spray" field. -func (su *SprayUpdate) SetSpray(b []byte) *SprayUpdate { - su.mutation.SetSpray(b) - return su +func (_u *SprayUpdate) SetSpray(v []byte) *SprayUpdate { + _u.mutation.SetSpray(v) + return _u } // SetMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID. -func (su *SprayUpdate) SetMatchPlayersID(id int) *SprayUpdate { - su.mutation.SetMatchPlayersID(id) - return su +func (_u *SprayUpdate) SetMatchPlayersID(id int) *SprayUpdate { + _u.mutation.SetMatchPlayersID(id) + return _u } // SetNillableMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID if the given value is not nil. -func (su *SprayUpdate) SetNillableMatchPlayersID(id *int) *SprayUpdate { +func (_u *SprayUpdate) SetNillableMatchPlayersID(id *int) *SprayUpdate { if id != nil { - su = su.SetMatchPlayersID(*id) + _u = _u.SetMatchPlayersID(*id) } - return su + return _u } // SetMatchPlayers sets the "match_players" edge to the MatchPlayer entity. -func (su *SprayUpdate) SetMatchPlayers(m *MatchPlayer) *SprayUpdate { - return su.SetMatchPlayersID(m.ID) +func (_u *SprayUpdate) SetMatchPlayers(v *MatchPlayer) *SprayUpdate { + return _u.SetMatchPlayersID(v.ID) } // Mutation returns the SprayMutation object of the builder. -func (su *SprayUpdate) Mutation() *SprayMutation { - return su.mutation +func (_u *SprayUpdate) Mutation() *SprayMutation { + return _u.mutation } // ClearMatchPlayers clears the "match_players" edge to the MatchPlayer entity. -func (su *SprayUpdate) ClearMatchPlayers() *SprayUpdate { - su.mutation.ClearMatchPlayers() - return su +func (_u *SprayUpdate) ClearMatchPlayers() *SprayUpdate { + _u.mutation.ClearMatchPlayers() + return _u } // Save executes the query and returns the number of nodes affected by the update operation. -func (su *SprayUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, su.sqlSave, su.mutation, su.hooks) +func (_u *SprayUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (su *SprayUpdate) SaveX(ctx context.Context) int { - affected, err := su.Save(ctx) +func (_u *SprayUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) if err != nil { panic(err) } @@ -93,43 +101,43 @@ func (su *SprayUpdate) SaveX(ctx context.Context) int { } // Exec executes the query. -func (su *SprayUpdate) Exec(ctx context.Context) error { - _, err := su.Save(ctx) +func (_u *SprayUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (su *SprayUpdate) ExecX(ctx context.Context) { - if err := su.Exec(ctx); err != nil { +func (_u *SprayUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // 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 (_u *SprayUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SprayUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) { +func (_u *SprayUpdate) sqlSave(ctx context.Context) (_node int, err error) { _spec := sqlgraph.NewUpdateSpec(spray.Table, spray.Columns, sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt)) - if ps := su.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := su.mutation.Weapon(); ok { + if value, ok := _u.mutation.Weapon(); ok { _spec.SetField(spray.FieldWeapon, field.TypeInt, value) } - if value, ok := su.mutation.AddedWeapon(); ok { + if value, ok := _u.mutation.AddedWeapon(); ok { _spec.AddField(spray.FieldWeapon, field.TypeInt, value) } - if value, ok := su.mutation.Spray(); ok { + if value, ok := _u.mutation.Spray(); ok { _spec.SetField(spray.FieldSpray, field.TypeBytes, value) } - if su.mutation.MatchPlayersCleared() { + if _u.mutation.MatchPlayersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -142,7 +150,7 @@ func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := su.mutation.MatchPlayersIDs(); len(nodes) > 0 { + if nodes := _u.mutation.MatchPlayersIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -158,8 +166,8 @@ func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(su.modifiers...) - if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil { + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{spray.Label} } else if sqlgraph.IsConstraintError(err) { @@ -167,8 +175,8 @@ func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) { } return 0, err } - su.mutation.done = true - return n, nil + _u.mutation.done = true + return _node, nil } // SprayUpdateOne is the builder for updating a single Spray entity. @@ -181,75 +189,83 @@ type SprayUpdateOne struct { } // SetWeapon sets the "weapon" field. -func (suo *SprayUpdateOne) SetWeapon(i int) *SprayUpdateOne { - suo.mutation.ResetWeapon() - suo.mutation.SetWeapon(i) - return suo +func (_u *SprayUpdateOne) SetWeapon(v int) *SprayUpdateOne { + _u.mutation.ResetWeapon() + _u.mutation.SetWeapon(v) + return _u } -// AddWeapon adds i to the "weapon" field. -func (suo *SprayUpdateOne) AddWeapon(i int) *SprayUpdateOne { - suo.mutation.AddWeapon(i) - return suo +// SetNillableWeapon sets the "weapon" field if the given value is not nil. +func (_u *SprayUpdateOne) SetNillableWeapon(v *int) *SprayUpdateOne { + if v != nil { + _u.SetWeapon(*v) + } + return _u +} + +// AddWeapon adds value to the "weapon" field. +func (_u *SprayUpdateOne) AddWeapon(v int) *SprayUpdateOne { + _u.mutation.AddWeapon(v) + return _u } // SetSpray sets the "spray" field. -func (suo *SprayUpdateOne) SetSpray(b []byte) *SprayUpdateOne { - suo.mutation.SetSpray(b) - return suo +func (_u *SprayUpdateOne) SetSpray(v []byte) *SprayUpdateOne { + _u.mutation.SetSpray(v) + return _u } // SetMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID. -func (suo *SprayUpdateOne) SetMatchPlayersID(id int) *SprayUpdateOne { - suo.mutation.SetMatchPlayersID(id) - return suo +func (_u *SprayUpdateOne) SetMatchPlayersID(id int) *SprayUpdateOne { + _u.mutation.SetMatchPlayersID(id) + return _u } // SetNillableMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID if the given value is not nil. -func (suo *SprayUpdateOne) SetNillableMatchPlayersID(id *int) *SprayUpdateOne { +func (_u *SprayUpdateOne) SetNillableMatchPlayersID(id *int) *SprayUpdateOne { if id != nil { - suo = suo.SetMatchPlayersID(*id) + _u = _u.SetMatchPlayersID(*id) } - return suo + return _u } // SetMatchPlayers sets the "match_players" edge to the MatchPlayer entity. -func (suo *SprayUpdateOne) SetMatchPlayers(m *MatchPlayer) *SprayUpdateOne { - return suo.SetMatchPlayersID(m.ID) +func (_u *SprayUpdateOne) SetMatchPlayers(v *MatchPlayer) *SprayUpdateOne { + return _u.SetMatchPlayersID(v.ID) } // Mutation returns the SprayMutation object of the builder. -func (suo *SprayUpdateOne) Mutation() *SprayMutation { - return suo.mutation +func (_u *SprayUpdateOne) Mutation() *SprayMutation { + return _u.mutation } // ClearMatchPlayers clears the "match_players" edge to the MatchPlayer entity. -func (suo *SprayUpdateOne) ClearMatchPlayers() *SprayUpdateOne { - suo.mutation.ClearMatchPlayers() - return suo +func (_u *SprayUpdateOne) ClearMatchPlayers() *SprayUpdateOne { + _u.mutation.ClearMatchPlayers() + return _u } // Where appends a list predicates to the SprayUpdate builder. -func (suo *SprayUpdateOne) Where(ps ...predicate.Spray) *SprayUpdateOne { - suo.mutation.Where(ps...) - return suo +func (_u *SprayUpdateOne) Where(ps ...predicate.Spray) *SprayUpdateOne { + _u.mutation.Where(ps...) + return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. -func (suo *SprayUpdateOne) Select(field string, fields ...string) *SprayUpdateOne { - suo.fields = append([]string{field}, fields...) - return suo +func (_u *SprayUpdateOne) Select(field string, fields ...string) *SprayUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u } // Save executes the query and returns the updated Spray entity. -func (suo *SprayUpdateOne) Save(ctx context.Context) (*Spray, error) { - return withHooks(ctx, suo.sqlSave, suo.mutation, suo.hooks) +func (_u *SprayUpdateOne) Save(ctx context.Context) (*Spray, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (suo *SprayUpdateOne) SaveX(ctx context.Context) *Spray { - node, err := suo.Save(ctx) +func (_u *SprayUpdateOne) SaveX(ctx context.Context) *Spray { + node, err := _u.Save(ctx) if err != nil { panic(err) } @@ -257,32 +273,32 @@ func (suo *SprayUpdateOne) SaveX(ctx context.Context) *Spray { } // Exec executes the query on the entity. -func (suo *SprayUpdateOne) Exec(ctx context.Context) error { - _, err := suo.Save(ctx) +func (_u *SprayUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (suo *SprayUpdateOne) ExecX(ctx context.Context) { - if err := suo.Exec(ctx); err != nil { +func (_u *SprayUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // 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 (_u *SprayUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SprayUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error) { +func (_u *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error) { _spec := sqlgraph.NewUpdateSpec(spray.Table, spray.Columns, sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt)) - id, ok := suo.mutation.ID() + id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Spray.id" for update`)} } _spec.Node.ID.Value = id - if fields := suo.fields; len(fields) > 0 { + if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, spray.FieldID) for _, f := range fields { @@ -294,23 +310,23 @@ func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error } } } - if ps := suo.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := suo.mutation.Weapon(); ok { + if value, ok := _u.mutation.Weapon(); ok { _spec.SetField(spray.FieldWeapon, field.TypeInt, value) } - if value, ok := suo.mutation.AddedWeapon(); ok { + if value, ok := _u.mutation.AddedWeapon(); ok { _spec.AddField(spray.FieldWeapon, field.TypeInt, value) } - if value, ok := suo.mutation.Spray(); ok { + if value, ok := _u.mutation.Spray(); ok { _spec.SetField(spray.FieldSpray, field.TypeBytes, value) } - if suo.mutation.MatchPlayersCleared() { + if _u.mutation.MatchPlayersCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -323,7 +339,7 @@ func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := suo.mutation.MatchPlayersIDs(); len(nodes) > 0 { + if nodes := _u.mutation.MatchPlayersIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -339,11 +355,11 @@ func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(suo.modifiers...) - _node = &Spray{config: suo.config} + _spec.AddModifiers(_u.modifiers...) + _node = &Spray{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, suo.driver, _spec); err != nil { + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{spray.Label} } else if sqlgraph.IsConstraintError(err) { @@ -351,6 +367,6 @@ func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error } return nil, err } - suo.mutation.done = true + _u.mutation.done = true return _node, nil } diff --git a/ent/weapon.go b/ent/weapon.go index ea4a6f2..2770908 100644 --- a/ent/weapon.go +++ b/ent/weapon.go @@ -44,12 +44,10 @@ type WeaponEdges struct { // StatOrErr returns the Stat value or an error if the edge // was not loaded in eager-loading, or loaded but was not found. func (e WeaponEdges) StatOrErr() (*MatchPlayer, error) { - if e.loadedTypes[0] { - if e.Stat == nil { - // Edge was loaded but was not found. - return nil, &NotFoundError{label: matchplayer.Label} - } + if e.Stat != nil { return e.Stat, nil + } else if e.loadedTypes[0] { + return nil, &NotFoundError{label: matchplayer.Label} } return nil, &NotLoadedError{edge: "stat"} } @@ -72,7 +70,7 @@ func (*Weapon) scanValues(columns []string) ([]any, error) { // assignValues assigns the values that were returned from sql.Rows (after scanning) // to the Weapon fields. -func (w *Weapon) assignValues(columns []string, values []any) error { +func (_m *Weapon) assignValues(columns []string, values []any) error { if m, n := len(values), len(columns); m < n { return fmt.Errorf("mismatch number of scan values: %d != %d", m, n) } @@ -83,40 +81,40 @@ func (w *Weapon) assignValues(columns []string, values []any) error { if !ok { return fmt.Errorf("unexpected type %T for field id", value) } - w.ID = int(value.Int64) + _m.ID = int(value.Int64) case weapon.FieldVictim: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field victim", values[i]) } else if value.Valid { - w.Victim = uint64(value.Int64) + _m.Victim = uint64(value.Int64) } case weapon.FieldDmg: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field dmg", values[i]) } else if value.Valid { - w.Dmg = uint(value.Int64) + _m.Dmg = uint(value.Int64) } case weapon.FieldEqType: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field eq_type", values[i]) } else if value.Valid { - w.EqType = int(value.Int64) + _m.EqType = int(value.Int64) } case weapon.FieldHitGroup: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field hit_group", values[i]) } else if value.Valid { - w.HitGroup = int(value.Int64) + _m.HitGroup = int(value.Int64) } case weapon.ForeignKeys[0]: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for edge-field match_player_weapon_stats", value) } else if value.Valid { - w.match_player_weapon_stats = new(int) - *w.match_player_weapon_stats = int(value.Int64) + _m.match_player_weapon_stats = new(int) + *_m.match_player_weapon_stats = int(value.Int64) } default: - w.selectValues.Set(columns[i], values[i]) + _m.selectValues.Set(columns[i], values[i]) } } return nil @@ -124,49 +122,49 @@ func (w *Weapon) assignValues(columns []string, values []any) error { // Value returns the ent.Value that was dynamically selected and assigned to the Weapon. // This includes values selected through modifiers, order, etc. -func (w *Weapon) Value(name string) (ent.Value, error) { - return w.selectValues.Get(name) +func (_m *Weapon) Value(name string) (ent.Value, error) { + return _m.selectValues.Get(name) } // QueryStat queries the "stat" edge of the Weapon entity. -func (w *Weapon) QueryStat() *MatchPlayerQuery { - return NewWeaponClient(w.config).QueryStat(w) +func (_m *Weapon) QueryStat() *MatchPlayerQuery { + return NewWeaponClient(_m.config).QueryStat(_m) } // Update returns a builder for updating this Weapon. // Note that you need to call Weapon.Unwrap() before calling this method if this Weapon // was returned from a transaction, and the transaction was committed or rolled back. -func (w *Weapon) Update() *WeaponUpdateOne { - return NewWeaponClient(w.config).UpdateOne(w) +func (_m *Weapon) Update() *WeaponUpdateOne { + return NewWeaponClient(_m.config).UpdateOne(_m) } // 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) +func (_m *Weapon) Unwrap() *Weapon { + _tx, ok := _m.config.driver.(*txDriver) if !ok { panic("ent: Weapon is not a transactional entity") } - w.config.driver = _tx.drv - return w + _m.config.driver = _tx.drv + return _m } // String implements the fmt.Stringer. -func (w *Weapon) String() string { +func (_m *Weapon) String() string { var builder strings.Builder builder.WriteString("Weapon(") - builder.WriteString(fmt.Sprintf("id=%v, ", w.ID)) + builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID)) builder.WriteString("victim=") - builder.WriteString(fmt.Sprintf("%v", w.Victim)) + builder.WriteString(fmt.Sprintf("%v", _m.Victim)) builder.WriteString(", ") builder.WriteString("dmg=") - builder.WriteString(fmt.Sprintf("%v", w.Dmg)) + builder.WriteString(fmt.Sprintf("%v", _m.Dmg)) builder.WriteString(", ") builder.WriteString("eq_type=") - builder.WriteString(fmt.Sprintf("%v", w.EqType)) + builder.WriteString(fmt.Sprintf("%v", _m.EqType)) builder.WriteString(", ") builder.WriteString("hit_group=") - builder.WriteString(fmt.Sprintf("%v", w.HitGroup)) + builder.WriteString(fmt.Sprintf("%v", _m.HitGroup)) builder.WriteByte(')') return builder.String() } diff --git a/ent/weapon/where.go b/ent/weapon/where.go index 714f336..11b6a69 100644 --- a/ent/weapon/where.go +++ b/ent/weapon/where.go @@ -258,32 +258,15 @@ func HasStatWith(preds ...predicate.MatchPlayer) predicate.Weapon { // And groups predicates with the AND operator between them. func And(predicates ...predicate.Weapon) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for _, p := range predicates { - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Weapon(sql.AndPredicates(predicates...)) } // Or groups predicates with the OR operator between them. func Or(predicates ...predicate.Weapon) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s1 := s.Clone().SetP(nil) - for i, p := range predicates { - if i > 0 { - s1.Or() - } - p(s1) - } - s.Where(s1.P()) - }) + return predicate.Weapon(sql.OrPredicates(predicates...)) } // Not applies the not operator on the given predicate. func Not(p predicate.Weapon) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - p(s.Not()) - }) + return predicate.Weapon(sql.NotPredicates(p)) } diff --git a/ent/weapon_create.go b/ent/weapon_create.go index 60aeba0..1cee62e 100644 --- a/ent/weapon_create.go +++ b/ent/weapon_create.go @@ -21,61 +21,61 @@ type WeaponCreate struct { } // SetVictim sets the "victim" field. -func (wc *WeaponCreate) SetVictim(u uint64) *WeaponCreate { - wc.mutation.SetVictim(u) - return wc +func (_c *WeaponCreate) SetVictim(v uint64) *WeaponCreate { + _c.mutation.SetVictim(v) + return _c } // SetDmg sets the "dmg" field. -func (wc *WeaponCreate) SetDmg(u uint) *WeaponCreate { - wc.mutation.SetDmg(u) - return wc +func (_c *WeaponCreate) SetDmg(v uint) *WeaponCreate { + _c.mutation.SetDmg(v) + return _c } // SetEqType sets the "eq_type" field. -func (wc *WeaponCreate) SetEqType(i int) *WeaponCreate { - wc.mutation.SetEqType(i) - return wc +func (_c *WeaponCreate) SetEqType(v int) *WeaponCreate { + _c.mutation.SetEqType(v) + return _c } // SetHitGroup sets the "hit_group" field. -func (wc *WeaponCreate) SetHitGroup(i int) *WeaponCreate { - wc.mutation.SetHitGroup(i) - return wc +func (_c *WeaponCreate) SetHitGroup(v int) *WeaponCreate { + _c.mutation.SetHitGroup(v) + return _c } // SetStatID sets the "stat" edge to the MatchPlayer entity by ID. -func (wc *WeaponCreate) SetStatID(id int) *WeaponCreate { - wc.mutation.SetStatID(id) - return wc +func (_c *WeaponCreate) SetStatID(id int) *WeaponCreate { + _c.mutation.SetStatID(id) + return _c } // SetNillableStatID sets the "stat" edge to the MatchPlayer entity by ID if the given value is not nil. -func (wc *WeaponCreate) SetNillableStatID(id *int) *WeaponCreate { +func (_c *WeaponCreate) SetNillableStatID(id *int) *WeaponCreate { if id != nil { - wc = wc.SetStatID(*id) + _c = _c.SetStatID(*id) } - return wc + return _c } // SetStat sets the "stat" edge to the MatchPlayer entity. -func (wc *WeaponCreate) SetStat(m *MatchPlayer) *WeaponCreate { - return wc.SetStatID(m.ID) +func (_c *WeaponCreate) SetStat(v *MatchPlayer) *WeaponCreate { + return _c.SetStatID(v.ID) } // Mutation returns the WeaponMutation object of the builder. -func (wc *WeaponCreate) Mutation() *WeaponMutation { - return wc.mutation +func (_c *WeaponCreate) Mutation() *WeaponMutation { + return _c.mutation } // Save creates the Weapon in the database. -func (wc *WeaponCreate) Save(ctx context.Context) (*Weapon, error) { - return withHooks(ctx, wc.sqlSave, wc.mutation, wc.hooks) +func (_c *WeaponCreate) Save(ctx context.Context) (*Weapon, error) { + return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks) } // SaveX calls Save and panics if Save returns an error. -func (wc *WeaponCreate) SaveX(ctx context.Context) *Weapon { - v, err := wc.Save(ctx) +func (_c *WeaponCreate) SaveX(ctx context.Context) *Weapon { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -83,41 +83,41 @@ func (wc *WeaponCreate) SaveX(ctx context.Context) *Weapon { } // Exec executes the query. -func (wc *WeaponCreate) Exec(ctx context.Context) error { - _, err := wc.Save(ctx) +func (_c *WeaponCreate) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (wc *WeaponCreate) ExecX(ctx context.Context) { - if err := wc.Exec(ctx); err != nil { +func (_c *WeaponCreate) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } // check runs all checks and user-defined validators on the builder. -func (wc *WeaponCreate) check() error { - if _, ok := wc.mutation.Victim(); !ok { +func (_c *WeaponCreate) check() error { + if _, ok := _c.mutation.Victim(); !ok { return &ValidationError{Name: "victim", err: errors.New(`ent: missing required field "Weapon.victim"`)} } - if _, ok := wc.mutation.Dmg(); !ok { + if _, ok := _c.mutation.Dmg(); !ok { return &ValidationError{Name: "dmg", err: errors.New(`ent: missing required field "Weapon.dmg"`)} } - if _, ok := wc.mutation.EqType(); !ok { + if _, ok := _c.mutation.EqType(); !ok { return &ValidationError{Name: "eq_type", err: errors.New(`ent: missing required field "Weapon.eq_type"`)} } - if _, ok := wc.mutation.HitGroup(); !ok { + if _, ok := _c.mutation.HitGroup(); !ok { return &ValidationError{Name: "hit_group", err: errors.New(`ent: missing required field "Weapon.hit_group"`)} } return nil } -func (wc *WeaponCreate) sqlSave(ctx context.Context) (*Weapon, error) { - if err := wc.check(); err != nil { +func (_c *WeaponCreate) sqlSave(ctx context.Context) (*Weapon, error) { + if err := _c.check(); err != nil { return nil, err } - _node, _spec := wc.createSpec() - if err := sqlgraph.CreateNode(ctx, wc.driver, _spec); err != nil { + _node, _spec := _c.createSpec() + if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -125,33 +125,33 @@ func (wc *WeaponCreate) sqlSave(ctx context.Context) (*Weapon, error) { } id := _spec.ID.Value.(int64) _node.ID = int(id) - wc.mutation.id = &_node.ID - wc.mutation.done = true + _c.mutation.id = &_node.ID + _c.mutation.done = true return _node, nil } -func (wc *WeaponCreate) createSpec() (*Weapon, *sqlgraph.CreateSpec) { +func (_c *WeaponCreate) createSpec() (*Weapon, *sqlgraph.CreateSpec) { var ( - _node = &Weapon{config: wc.config} + _node = &Weapon{config: _c.config} _spec = sqlgraph.NewCreateSpec(weapon.Table, sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt)) ) - if value, ok := wc.mutation.Victim(); ok { + if value, ok := _c.mutation.Victim(); ok { _spec.SetField(weapon.FieldVictim, field.TypeUint64, value) _node.Victim = value } - if value, ok := wc.mutation.Dmg(); ok { + if value, ok := _c.mutation.Dmg(); ok { _spec.SetField(weapon.FieldDmg, field.TypeUint, value) _node.Dmg = value } - if value, ok := wc.mutation.EqType(); ok { + if value, ok := _c.mutation.EqType(); ok { _spec.SetField(weapon.FieldEqType, field.TypeInt, value) _node.EqType = value } - if value, ok := wc.mutation.HitGroup(); ok { + if value, ok := _c.mutation.HitGroup(); ok { _spec.SetField(weapon.FieldHitGroup, field.TypeInt, value) _node.HitGroup = value } - if nodes := wc.mutation.StatIDs(); len(nodes) > 0 { + if nodes := _c.mutation.StatIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -174,17 +174,21 @@ func (wc *WeaponCreate) createSpec() (*Weapon, *sqlgraph.CreateSpec) { // WeaponCreateBulk is the builder for creating many Weapon entities in bulk. type WeaponCreateBulk struct { config + err error builders []*WeaponCreate } // Save creates the Weapon entities in the database. -func (wcb *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) { - specs := make([]*sqlgraph.CreateSpec, len(wcb.builders)) - nodes := make([]*Weapon, len(wcb.builders)) - mutators := make([]Mutator, len(wcb.builders)) - for i := range wcb.builders { +func (_c *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) { + if _c.err != nil { + return nil, _c.err + } + specs := make([]*sqlgraph.CreateSpec, len(_c.builders)) + nodes := make([]*Weapon, len(_c.builders)) + mutators := make([]Mutator, len(_c.builders)) + for i := range _c.builders { func(i int, root context.Context) { - builder := wcb.builders[i] + builder := _c.builders[i] var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { mutation, ok := m.(*WeaponMutation) if !ok { @@ -197,11 +201,11 @@ func (wcb *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) { var err error nodes[i], specs[i] = builder.createSpec() if i < len(mutators)-1 { - _, err = mutators[i+1].Mutate(root, wcb.builders[i+1].mutation) + _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation) } else { spec := &sqlgraph.BatchCreateSpec{Nodes: specs} // Invoke the actual operation on the latest mutation in the chain. - if err = sqlgraph.BatchCreate(ctx, wcb.driver, spec); err != nil { + if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil { if sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } @@ -225,7 +229,7 @@ func (wcb *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) { }(i, ctx) } if len(mutators) > 0 { - if _, err := mutators[0].Mutate(ctx, wcb.builders[0].mutation); err != nil { + if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil { return nil, err } } @@ -233,8 +237,8 @@ func (wcb *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) { } // SaveX is like Save, but panics if an error occurs. -func (wcb *WeaponCreateBulk) SaveX(ctx context.Context) []*Weapon { - v, err := wcb.Save(ctx) +func (_c *WeaponCreateBulk) SaveX(ctx context.Context) []*Weapon { + v, err := _c.Save(ctx) if err != nil { panic(err) } @@ -242,14 +246,14 @@ func (wcb *WeaponCreateBulk) SaveX(ctx context.Context) []*Weapon { } // Exec executes the query. -func (wcb *WeaponCreateBulk) Exec(ctx context.Context) error { - _, err := wcb.Save(ctx) +func (_c *WeaponCreateBulk) Exec(ctx context.Context) error { + _, err := _c.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (wcb *WeaponCreateBulk) ExecX(ctx context.Context) { - if err := wcb.Exec(ctx); err != nil { +func (_c *WeaponCreateBulk) ExecX(ctx context.Context) { + if err := _c.Exec(ctx); err != nil { panic(err) } } diff --git a/ent/weapon_delete.go b/ent/weapon_delete.go index a5ae295..9f056d3 100644 --- a/ent/weapon_delete.go +++ b/ent/weapon_delete.go @@ -20,56 +20,56 @@ type WeaponDelete struct { } // Where appends a list predicates to the WeaponDelete builder. -func (wd *WeaponDelete) Where(ps ...predicate.Weapon) *WeaponDelete { - wd.mutation.Where(ps...) - return wd +func (_d *WeaponDelete) Where(ps ...predicate.Weapon) *WeaponDelete { + _d.mutation.Where(ps...) + return _d } // Exec executes the deletion query and returns how many vertices were deleted. -func (wd *WeaponDelete) Exec(ctx context.Context) (int, error) { - return withHooks(ctx, wd.sqlExec, wd.mutation, wd.hooks) +func (_d *WeaponDelete) Exec(ctx context.Context) (int, error) { + return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks) } // ExecX is like Exec, but panics if an error occurs. -func (wd *WeaponDelete) ExecX(ctx context.Context) int { - n, err := wd.Exec(ctx) +func (_d *WeaponDelete) ExecX(ctx context.Context) int { + n, err := _d.Exec(ctx) if err != nil { panic(err) } return n } -func (wd *WeaponDelete) sqlExec(ctx context.Context) (int, error) { +func (_d *WeaponDelete) sqlExec(ctx context.Context) (int, error) { _spec := sqlgraph.NewDeleteSpec(weapon.Table, sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt)) - if ps := wd.mutation.predicates; len(ps) > 0 { + if ps := _d.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - affected, err := sqlgraph.DeleteNodes(ctx, wd.driver, _spec) + affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec) if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } - wd.mutation.done = true + _d.mutation.done = true return affected, err } // WeaponDeleteOne is the builder for deleting a single Weapon entity. type WeaponDeleteOne struct { - wd *WeaponDelete + _d *WeaponDelete } // Where appends a list predicates to the WeaponDelete builder. -func (wdo *WeaponDeleteOne) Where(ps ...predicate.Weapon) *WeaponDeleteOne { - wdo.wd.mutation.Where(ps...) - return wdo +func (_d *WeaponDeleteOne) Where(ps ...predicate.Weapon) *WeaponDeleteOne { + _d._d.mutation.Where(ps...) + return _d } // Exec executes the deletion query. -func (wdo *WeaponDeleteOne) Exec(ctx context.Context) error { - n, err := wdo.wd.Exec(ctx) +func (_d *WeaponDeleteOne) Exec(ctx context.Context) error { + n, err := _d._d.Exec(ctx) switch { case err != nil: return err @@ -81,8 +81,8 @@ func (wdo *WeaponDeleteOne) Exec(ctx context.Context) error { } // ExecX is like Exec, but panics if an error occurs. -func (wdo *WeaponDeleteOne) ExecX(ctx context.Context) { - if err := wdo.Exec(ctx); err != nil { +func (_d *WeaponDeleteOne) ExecX(ctx context.Context) { + if err := _d.Exec(ctx); err != nil { panic(err) } } diff --git a/ent/weapon_query.go b/ent/weapon_query.go index 761b478..af32e66 100644 --- a/ent/weapon_query.go +++ b/ent/weapon_query.go @@ -7,6 +7,7 @@ import ( "fmt" "math" + "entgo.io/ent" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/schema/field" @@ -31,44 +32,44 @@ type WeaponQuery struct { } // Where adds a new predicate for the WeaponQuery builder. -func (wq *WeaponQuery) Where(ps ...predicate.Weapon) *WeaponQuery { - wq.predicates = append(wq.predicates, ps...) - return wq +func (_q *WeaponQuery) Where(ps ...predicate.Weapon) *WeaponQuery { + _q.predicates = append(_q.predicates, ps...) + return _q } // Limit the number of records to be returned by this query. -func (wq *WeaponQuery) Limit(limit int) *WeaponQuery { - wq.ctx.Limit = &limit - return wq +func (_q *WeaponQuery) Limit(limit int) *WeaponQuery { + _q.ctx.Limit = &limit + return _q } // Offset to start from. -func (wq *WeaponQuery) Offset(offset int) *WeaponQuery { - wq.ctx.Offset = &offset - return wq +func (_q *WeaponQuery) Offset(offset int) *WeaponQuery { + _q.ctx.Offset = &offset + return _q } // Unique configures the query builder to filter duplicate records on query. // By default, unique is set to true, and can be disabled using this method. -func (wq *WeaponQuery) Unique(unique bool) *WeaponQuery { - wq.ctx.Unique = &unique - return wq +func (_q *WeaponQuery) Unique(unique bool) *WeaponQuery { + _q.ctx.Unique = &unique + return _q } // Order specifies how the records should be ordered. -func (wq *WeaponQuery) Order(o ...weapon.OrderOption) *WeaponQuery { - wq.order = append(wq.order, o...) - return wq +func (_q *WeaponQuery) Order(o ...weapon.OrderOption) *WeaponQuery { + _q.order = append(_q.order, o...) + return _q } // QueryStat chains the current query on the "stat" edge. -func (wq *WeaponQuery) QueryStat() *MatchPlayerQuery { - query := (&MatchPlayerClient{config: wq.config}).Query() +func (_q *WeaponQuery) QueryStat() *MatchPlayerQuery { + query := (&MatchPlayerClient{config: _q.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { - if err := wq.prepareQuery(ctx); err != nil { + if err := _q.prepareQuery(ctx); err != nil { return nil, err } - selector := wq.sqlQuery(ctx) + selector := _q.sqlQuery(ctx) if err := selector.Err(); err != nil { return nil, err } @@ -77,7 +78,7 @@ func (wq *WeaponQuery) QueryStat() *MatchPlayerQuery { sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.Edge(sqlgraph.M2O, true, weapon.StatTable, weapon.StatColumn), ) - fromU = sqlgraph.SetNeighbors(wq.driver.Dialect(), step) + fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step) return fromU, nil } return query @@ -85,8 +86,8 @@ func (wq *WeaponQuery) QueryStat() *MatchPlayerQuery { // First returns the first Weapon entity from the query. // Returns a *NotFoundError when no Weapon was found. -func (wq *WeaponQuery) First(ctx context.Context) (*Weapon, error) { - nodes, err := wq.Limit(1).All(setContextOp(ctx, wq.ctx, "First")) +func (_q *WeaponQuery) First(ctx context.Context) (*Weapon, error) { + nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst)) if err != nil { return nil, err } @@ -97,8 +98,8 @@ func (wq *WeaponQuery) First(ctx context.Context) (*Weapon, error) { } // FirstX is like First, but panics if an error occurs. -func (wq *WeaponQuery) FirstX(ctx context.Context) *Weapon { - node, err := wq.First(ctx) +func (_q *WeaponQuery) FirstX(ctx context.Context) *Weapon { + node, err := _q.First(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -107,9 +108,9 @@ func (wq *WeaponQuery) FirstX(ctx context.Context) *Weapon { // FirstID returns the first Weapon ID from the query. // Returns a *NotFoundError when no Weapon ID was found. -func (wq *WeaponQuery) FirstID(ctx context.Context) (id int, err error) { +func (_q *WeaponQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = wq.Limit(1).IDs(setContextOp(ctx, wq.ctx, "FirstID")); err != nil { + if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil { return } if len(ids) == 0 { @@ -120,8 +121,8 @@ func (wq *WeaponQuery) FirstID(ctx context.Context) (id int, err error) { } // FirstIDX is like FirstID, but panics if an error occurs. -func (wq *WeaponQuery) FirstIDX(ctx context.Context) int { - id, err := wq.FirstID(ctx) +func (_q *WeaponQuery) FirstIDX(ctx context.Context) int { + id, err := _q.FirstID(ctx) if err != nil && !IsNotFound(err) { panic(err) } @@ -131,8 +132,8 @@ func (wq *WeaponQuery) FirstIDX(ctx context.Context) int { // Only returns a single Weapon entity found by the query, ensuring it only returns one. // Returns a *NotSingularError when more than one Weapon entity is found. // Returns a *NotFoundError when no Weapon entities are found. -func (wq *WeaponQuery) Only(ctx context.Context) (*Weapon, error) { - nodes, err := wq.Limit(2).All(setContextOp(ctx, wq.ctx, "Only")) +func (_q *WeaponQuery) Only(ctx context.Context) (*Weapon, error) { + nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly)) if err != nil { return nil, err } @@ -147,8 +148,8 @@ func (wq *WeaponQuery) Only(ctx context.Context) (*Weapon, error) { } // OnlyX is like Only, but panics if an error occurs. -func (wq *WeaponQuery) OnlyX(ctx context.Context) *Weapon { - node, err := wq.Only(ctx) +func (_q *WeaponQuery) OnlyX(ctx context.Context) *Weapon { + node, err := _q.Only(ctx) if err != nil { panic(err) } @@ -158,9 +159,9 @@ func (wq *WeaponQuery) OnlyX(ctx context.Context) *Weapon { // OnlyID is like Only, but returns the only Weapon ID in the query. // Returns a *NotSingularError when more than one Weapon ID is found. // Returns a *NotFoundError when no entities are found. -func (wq *WeaponQuery) OnlyID(ctx context.Context) (id int, err error) { +func (_q *WeaponQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = wq.Limit(2).IDs(setContextOp(ctx, wq.ctx, "OnlyID")); err != nil { + if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil { return } switch len(ids) { @@ -175,8 +176,8 @@ func (wq *WeaponQuery) OnlyID(ctx context.Context) (id int, err error) { } // OnlyIDX is like OnlyID, but panics if an error occurs. -func (wq *WeaponQuery) OnlyIDX(ctx context.Context) int { - id, err := wq.OnlyID(ctx) +func (_q *WeaponQuery) OnlyIDX(ctx context.Context) int { + id, err := _q.OnlyID(ctx) if err != nil { panic(err) } @@ -184,18 +185,18 @@ func (wq *WeaponQuery) OnlyIDX(ctx context.Context) int { } // All executes the query and returns a list of Weapons. -func (wq *WeaponQuery) All(ctx context.Context) ([]*Weapon, error) { - ctx = setContextOp(ctx, wq.ctx, "All") - if err := wq.prepareQuery(ctx); err != nil { +func (_q *WeaponQuery) All(ctx context.Context) ([]*Weapon, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll) + if err := _q.prepareQuery(ctx); err != nil { return nil, err } qr := querierAll[[]*Weapon, *WeaponQuery]() - return withInterceptors[[]*Weapon](ctx, wq, qr, wq.inters) + return withInterceptors[[]*Weapon](ctx, _q, qr, _q.inters) } // AllX is like All, but panics if an error occurs. -func (wq *WeaponQuery) AllX(ctx context.Context) []*Weapon { - nodes, err := wq.All(ctx) +func (_q *WeaponQuery) AllX(ctx context.Context) []*Weapon { + nodes, err := _q.All(ctx) if err != nil { panic(err) } @@ -203,20 +204,20 @@ func (wq *WeaponQuery) AllX(ctx context.Context) []*Weapon { } // IDs executes the query and returns a list of Weapon IDs. -func (wq *WeaponQuery) IDs(ctx context.Context) (ids []int, err error) { - if wq.ctx.Unique == nil && wq.path != nil { - wq.Unique(true) +func (_q *WeaponQuery) IDs(ctx context.Context) (ids []int, err error) { + if _q.ctx.Unique == nil && _q.path != nil { + _q.Unique(true) } - ctx = setContextOp(ctx, wq.ctx, "IDs") - if err = wq.Select(weapon.FieldID).Scan(ctx, &ids); err != nil { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs) + if err = _q.Select(weapon.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil } // IDsX is like IDs, but panics if an error occurs. -func (wq *WeaponQuery) IDsX(ctx context.Context) []int { - ids, err := wq.IDs(ctx) +func (_q *WeaponQuery) IDsX(ctx context.Context) []int { + ids, err := _q.IDs(ctx) if err != nil { panic(err) } @@ -224,17 +225,17 @@ func (wq *WeaponQuery) IDsX(ctx context.Context) []int { } // Count returns the count of the given query. -func (wq *WeaponQuery) Count(ctx context.Context) (int, error) { - ctx = setContextOp(ctx, wq.ctx, "Count") - if err := wq.prepareQuery(ctx); err != nil { +func (_q *WeaponQuery) Count(ctx context.Context) (int, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount) + if err := _q.prepareQuery(ctx); err != nil { return 0, err } - return withInterceptors[int](ctx, wq, querierCount[*WeaponQuery](), wq.inters) + return withInterceptors[int](ctx, _q, querierCount[*WeaponQuery](), _q.inters) } // CountX is like Count, but panics if an error occurs. -func (wq *WeaponQuery) CountX(ctx context.Context) int { - count, err := wq.Count(ctx) +func (_q *WeaponQuery) CountX(ctx context.Context) int { + count, err := _q.Count(ctx) if err != nil { panic(err) } @@ -242,9 +243,9 @@ func (wq *WeaponQuery) CountX(ctx context.Context) int { } // Exist returns true if the query has elements in the graph. -func (wq *WeaponQuery) Exist(ctx context.Context) (bool, error) { - ctx = setContextOp(ctx, wq.ctx, "Exist") - switch _, err := wq.FirstID(ctx); { +func (_q *WeaponQuery) Exist(ctx context.Context) (bool, error) { + ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist) + switch _, err := _q.FirstID(ctx); { case IsNotFound(err): return false, nil case err != nil: @@ -255,8 +256,8 @@ func (wq *WeaponQuery) Exist(ctx context.Context) (bool, error) { } // ExistX is like Exist, but panics if an error occurs. -func (wq *WeaponQuery) ExistX(ctx context.Context) bool { - exist, err := wq.Exist(ctx) +func (_q *WeaponQuery) ExistX(ctx context.Context) bool { + exist, err := _q.Exist(ctx) if err != nil { panic(err) } @@ -265,32 +266,33 @@ func (wq *WeaponQuery) ExistX(ctx context.Context) bool { // Clone returns a duplicate of the WeaponQuery builder, including all associated steps. It can be // used to prepare common query builders and use them differently after the clone is made. -func (wq *WeaponQuery) Clone() *WeaponQuery { - if wq == nil { +func (_q *WeaponQuery) Clone() *WeaponQuery { + if _q == nil { return nil } return &WeaponQuery{ - config: wq.config, - ctx: wq.ctx.Clone(), - order: append([]weapon.OrderOption{}, wq.order...), - inters: append([]Interceptor{}, wq.inters...), - predicates: append([]predicate.Weapon{}, wq.predicates...), - withStat: wq.withStat.Clone(), + config: _q.config, + ctx: _q.ctx.Clone(), + order: append([]weapon.OrderOption{}, _q.order...), + inters: append([]Interceptor{}, _q.inters...), + predicates: append([]predicate.Weapon{}, _q.predicates...), + withStat: _q.withStat.Clone(), // clone intermediate query. - sql: wq.sql.Clone(), - path: wq.path, + sql: _q.sql.Clone(), + path: _q.path, + modifiers: append([]func(*sql.Selector){}, _q.modifiers...), } } // WithStat tells the query-builder to eager-load the nodes that are connected to // the "stat" edge. The optional arguments are used to configure the query builder of the edge. -func (wq *WeaponQuery) WithStat(opts ...func(*MatchPlayerQuery)) *WeaponQuery { - query := (&MatchPlayerClient{config: wq.config}).Query() +func (_q *WeaponQuery) WithStat(opts ...func(*MatchPlayerQuery)) *WeaponQuery { + query := (&MatchPlayerClient{config: _q.config}).Query() for _, opt := range opts { opt(query) } - wq.withStat = query - return wq + _q.withStat = query + return _q } // GroupBy is used to group vertices by one or more fields/columns. @@ -307,10 +309,10 @@ 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 { - wq.ctx.Fields = append([]string{field}, fields...) - grbuild := &WeaponGroupBy{build: wq} - grbuild.flds = &wq.ctx.Fields +func (_q *WeaponQuery) GroupBy(field string, fields ...string) *WeaponGroupBy { + _q.ctx.Fields = append([]string{field}, fields...) + grbuild := &WeaponGroupBy{build: _q} + grbuild.flds = &_q.ctx.Fields grbuild.label = weapon.Label grbuild.scan = grbuild.Scan return grbuild @@ -328,55 +330,55 @@ 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.ctx.Fields = append(wq.ctx.Fields, fields...) - sbuild := &WeaponSelect{WeaponQuery: wq} +func (_q *WeaponQuery) Select(fields ...string) *WeaponSelect { + _q.ctx.Fields = append(_q.ctx.Fields, fields...) + sbuild := &WeaponSelect{WeaponQuery: _q} sbuild.label = weapon.Label - sbuild.flds, sbuild.scan = &wq.ctx.Fields, sbuild.Scan + sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan return sbuild } // Aggregate returns a WeaponSelect configured with the given aggregations. -func (wq *WeaponQuery) Aggregate(fns ...AggregateFunc) *WeaponSelect { - return wq.Select().Aggregate(fns...) +func (_q *WeaponQuery) Aggregate(fns ...AggregateFunc) *WeaponSelect { + return _q.Select().Aggregate(fns...) } -func (wq *WeaponQuery) prepareQuery(ctx context.Context) error { - for _, inter := range wq.inters { +func (_q *WeaponQuery) prepareQuery(ctx context.Context) error { + for _, inter := range _q.inters { if inter == nil { return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") } if trv, ok := inter.(Traverser); ok { - if err := trv.Traverse(ctx, wq); err != nil { + if err := trv.Traverse(ctx, _q); err != nil { return err } } } - for _, f := range wq.ctx.Fields { + for _, f := range _q.ctx.Fields { if !weapon.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } } - if wq.path != nil { - prev, err := wq.path(ctx) + if _q.path != nil { + prev, err := _q.path(ctx) if err != nil { return err } - wq.sql = prev + _q.sql = prev } return nil } -func (wq *WeaponQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Weapon, error) { +func (_q *WeaponQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Weapon, error) { var ( nodes = []*Weapon{} - withFKs = wq.withFKs - _spec = wq.querySpec() + withFKs = _q.withFKs + _spec = _q.querySpec() loadedTypes = [1]bool{ - wq.withStat != nil, + _q.withStat != nil, } ) - if wq.withStat != nil { + if _q.withStat != nil { withFKs = true } if withFKs { @@ -386,25 +388,25 @@ func (wq *WeaponQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Weapo return (*Weapon).scanValues(nil, columns) } _spec.Assign = func(columns []string, values []any) error { - node := &Weapon{config: wq.config} + node := &Weapon{config: _q.config} nodes = append(nodes, node) node.Edges.loadedTypes = loadedTypes return node.assignValues(columns, values) } - if len(wq.modifiers) > 0 { - _spec.Modifiers = wq.modifiers + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } for i := range hooks { hooks[i](ctx, _spec) } - if err := sqlgraph.QueryNodes(ctx, wq.driver, _spec); err != nil { + if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { return nil, err } if len(nodes) == 0 { return nodes, nil } - if query := wq.withStat; query != nil { - if err := wq.loadStat(ctx, query, nodes, nil, + if query := _q.withStat; query != nil { + if err := _q.loadStat(ctx, query, nodes, nil, func(n *Weapon, e *MatchPlayer) { n.Edges.Stat = e }); err != nil { return nil, err } @@ -412,7 +414,7 @@ func (wq *WeaponQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Weapo return nodes, nil } -func (wq *WeaponQuery) loadStat(ctx context.Context, query *MatchPlayerQuery, nodes []*Weapon, init func(*Weapon), assign func(*Weapon, *MatchPlayer)) error { +func (_q *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 { @@ -445,27 +447,27 @@ func (wq *WeaponQuery) loadStat(ctx context.Context, query *MatchPlayerQuery, no return nil } -func (wq *WeaponQuery) sqlCount(ctx context.Context) (int, error) { - _spec := wq.querySpec() - if len(wq.modifiers) > 0 { - _spec.Modifiers = wq.modifiers +func (_q *WeaponQuery) sqlCount(ctx context.Context) (int, error) { + _spec := _q.querySpec() + if len(_q.modifiers) > 0 { + _spec.Modifiers = _q.modifiers } - _spec.Node.Columns = wq.ctx.Fields - if len(wq.ctx.Fields) > 0 { - _spec.Unique = wq.ctx.Unique != nil && *wq.ctx.Unique + _spec.Node.Columns = _q.ctx.Fields + if len(_q.ctx.Fields) > 0 { + _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique } - return sqlgraph.CountNodes(ctx, wq.driver, _spec) + return sqlgraph.CountNodes(ctx, _q.driver, _spec) } -func (wq *WeaponQuery) querySpec() *sqlgraph.QuerySpec { +func (_q *WeaponQuery) querySpec() *sqlgraph.QuerySpec { _spec := sqlgraph.NewQuerySpec(weapon.Table, weapon.Columns, sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt)) - _spec.From = wq.sql - if unique := wq.ctx.Unique; unique != nil { + _spec.From = _q.sql + if unique := _q.ctx.Unique; unique != nil { _spec.Unique = *unique - } else if wq.path != nil { + } else if _q.path != nil { _spec.Unique = true } - if fields := wq.ctx.Fields; len(fields) > 0 { + if fields := _q.ctx.Fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, weapon.FieldID) for i := range fields { @@ -474,20 +476,20 @@ func (wq *WeaponQuery) querySpec() *sqlgraph.QuerySpec { } } } - if ps := wq.predicates; len(ps) > 0 { + if ps := _q.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if limit := wq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := wq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { _spec.Offset = *offset } - if ps := wq.order; len(ps) > 0 { + if ps := _q.order; len(ps) > 0 { _spec.Order = func(selector *sql.Selector) { for i := range ps { ps[i](selector) @@ -497,45 +499,45 @@ func (wq *WeaponQuery) querySpec() *sqlgraph.QuerySpec { return _spec } -func (wq *WeaponQuery) sqlQuery(ctx context.Context) *sql.Selector { - builder := sql.Dialect(wq.driver.Dialect()) +func (_q *WeaponQuery) sqlQuery(ctx context.Context) *sql.Selector { + builder := sql.Dialect(_q.driver.Dialect()) t1 := builder.Table(weapon.Table) - columns := wq.ctx.Fields + columns := _q.ctx.Fields if len(columns) == 0 { columns = weapon.Columns } selector := builder.Select(t1.Columns(columns...)...).From(t1) - if wq.sql != nil { - selector = wq.sql + if _q.sql != nil { + selector = _q.sql selector.Select(selector.Columns(columns...)...) } - if wq.ctx.Unique != nil && *wq.ctx.Unique { + if _q.ctx.Unique != nil && *_q.ctx.Unique { selector.Distinct() } - for _, m := range wq.modifiers { + for _, m := range _q.modifiers { m(selector) } - for _, p := range wq.predicates { + for _, p := range _q.predicates { p(selector) } - for _, p := range wq.order { + for _, p := range _q.order { p(selector) } - if offset := wq.ctx.Offset; offset != nil { + if offset := _q.ctx.Offset; offset != nil { // limit is mandatory for offset clause. We start // with default value, and override it below if needed. selector.Offset(*offset).Limit(math.MaxInt32) } - if limit := wq.ctx.Limit; limit != nil { + if limit := _q.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector } // Modify adds a query modifier for attaching custom logic to queries. -func (wq *WeaponQuery) Modify(modifiers ...func(s *sql.Selector)) *WeaponSelect { - wq.modifiers = append(wq.modifiers, modifiers...) - return wq.Select() +func (_q *WeaponQuery) Modify(modifiers ...func(s *sql.Selector)) *WeaponSelect { + _q.modifiers = append(_q.modifiers, modifiers...) + return _q.Select() } // WeaponGroupBy is the group-by builder for Weapon entities. @@ -545,41 +547,41 @@ type WeaponGroupBy struct { } // Aggregate adds the given aggregation functions to the group-by query. -func (wgb *WeaponGroupBy) Aggregate(fns ...AggregateFunc) *WeaponGroupBy { - wgb.fns = append(wgb.fns, fns...) - return wgb +func (_g *WeaponGroupBy) Aggregate(fns ...AggregateFunc) *WeaponGroupBy { + _g.fns = append(_g.fns, fns...) + return _g } // Scan applies the selector query and scans the result into the given value. -func (wgb *WeaponGroupBy) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, wgb.build.ctx, "GroupBy") - if err := wgb.build.prepareQuery(ctx); err != nil { +func (_g *WeaponGroupBy) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy) + if err := _g.build.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*WeaponQuery, *WeaponGroupBy](ctx, wgb.build, wgb, wgb.build.inters, v) + return scanWithInterceptors[*WeaponQuery, *WeaponGroupBy](ctx, _g.build, _g, _g.build.inters, v) } -func (wgb *WeaponGroupBy) sqlScan(ctx context.Context, root *WeaponQuery, v any) error { +func (_g *WeaponGroupBy) sqlScan(ctx context.Context, root *WeaponQuery, v any) error { selector := root.sqlQuery(ctx).Select() - aggregation := make([]string, 0, len(wgb.fns)) - for _, fn := range wgb.fns { + aggregation := make([]string, 0, len(_g.fns)) + for _, fn := range _g.fns { aggregation = append(aggregation, fn(selector)) } if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(*wgb.flds)+len(wgb.fns)) - for _, f := range *wgb.flds { + columns := make([]string, 0, len(*_g.flds)+len(_g.fns)) + for _, f := range *_g.flds { columns = append(columns, selector.C(f)) } columns = append(columns, aggregation...) selector.Select(columns...) } - selector.GroupBy(selector.Columns(*wgb.flds...)...) + selector.GroupBy(selector.Columns(*_g.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := wgb.build.driver.Query(ctx, query, args, rows); err != nil { + if err := _g.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -593,27 +595,27 @@ type WeaponSelect struct { } // Aggregate adds the given aggregation functions to the selector query. -func (ws *WeaponSelect) Aggregate(fns ...AggregateFunc) *WeaponSelect { - ws.fns = append(ws.fns, fns...) - return ws +func (_s *WeaponSelect) Aggregate(fns ...AggregateFunc) *WeaponSelect { + _s.fns = append(_s.fns, fns...) + return _s } // Scan applies the selector query and scans the result into the given value. -func (ws *WeaponSelect) Scan(ctx context.Context, v any) error { - ctx = setContextOp(ctx, ws.ctx, "Select") - if err := ws.prepareQuery(ctx); err != nil { +func (_s *WeaponSelect) Scan(ctx context.Context, v any) error { + ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect) + if err := _s.prepareQuery(ctx); err != nil { return err } - return scanWithInterceptors[*WeaponQuery, *WeaponSelect](ctx, ws.WeaponQuery, ws, ws.inters, v) + return scanWithInterceptors[*WeaponQuery, *WeaponSelect](ctx, _s.WeaponQuery, _s, _s.inters, v) } -func (ws *WeaponSelect) sqlScan(ctx context.Context, root *WeaponQuery, v any) error { +func (_s *WeaponSelect) sqlScan(ctx context.Context, root *WeaponQuery, v any) error { selector := root.sqlQuery(ctx) - aggregation := make([]string, 0, len(ws.fns)) - for _, fn := range ws.fns { + aggregation := make([]string, 0, len(_s.fns)) + for _, fn := range _s.fns { aggregation = append(aggregation, fn(selector)) } - switch n := len(*ws.selector.flds); { + switch n := len(*_s.selector.flds); { case n == 0 && len(aggregation) > 0: selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: @@ -621,7 +623,7 @@ func (ws *WeaponSelect) sqlScan(ctx context.Context, root *WeaponQuery, v any) e } rows := &sql.Rows{} query, args := selector.Query() - if err := ws.driver.Query(ctx, query, args, rows); err != nil { + if err := _s.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() @@ -629,7 +631,7 @@ func (ws *WeaponSelect) sqlScan(ctx context.Context, root *WeaponQuery, v any) e } // Modify adds a query modifier for attaching custom logic to queries. -func (ws *WeaponSelect) Modify(modifiers ...func(s *sql.Selector)) *WeaponSelect { - ws.modifiers = append(ws.modifiers, modifiers...) - return ws +func (_s *WeaponSelect) Modify(modifiers ...func(s *sql.Selector)) *WeaponSelect { + _s.modifiers = append(_s.modifiers, modifiers...) + return _s } diff --git a/ent/weapon_update.go b/ent/weapon_update.go index 3ae2772..fd4e55f 100644 --- a/ent/weapon_update.go +++ b/ent/weapon_update.go @@ -24,101 +24,133 @@ type WeaponUpdate struct { } // Where appends a list predicates to the WeaponUpdate builder. -func (wu *WeaponUpdate) Where(ps ...predicate.Weapon) *WeaponUpdate { - wu.mutation.Where(ps...) - return wu +func (_u *WeaponUpdate) Where(ps ...predicate.Weapon) *WeaponUpdate { + _u.mutation.Where(ps...) + return _u } // SetVictim sets the "victim" field. -func (wu *WeaponUpdate) SetVictim(u uint64) *WeaponUpdate { - wu.mutation.ResetVictim() - wu.mutation.SetVictim(u) - return wu +func (_u *WeaponUpdate) SetVictim(v uint64) *WeaponUpdate { + _u.mutation.ResetVictim() + _u.mutation.SetVictim(v) + return _u } -// AddVictim adds u to the "victim" field. -func (wu *WeaponUpdate) AddVictim(u int64) *WeaponUpdate { - wu.mutation.AddVictim(u) - return wu +// SetNillableVictim sets the "victim" field if the given value is not nil. +func (_u *WeaponUpdate) SetNillableVictim(v *uint64) *WeaponUpdate { + if v != nil { + _u.SetVictim(*v) + } + return _u +} + +// AddVictim adds value to the "victim" field. +func (_u *WeaponUpdate) AddVictim(v int64) *WeaponUpdate { + _u.mutation.AddVictim(v) + return _u } // SetDmg sets the "dmg" field. -func (wu *WeaponUpdate) SetDmg(u uint) *WeaponUpdate { - wu.mutation.ResetDmg() - wu.mutation.SetDmg(u) - return wu +func (_u *WeaponUpdate) SetDmg(v uint) *WeaponUpdate { + _u.mutation.ResetDmg() + _u.mutation.SetDmg(v) + return _u } -// AddDmg adds u to the "dmg" field. -func (wu *WeaponUpdate) AddDmg(u int) *WeaponUpdate { - wu.mutation.AddDmg(u) - return wu +// SetNillableDmg sets the "dmg" field if the given value is not nil. +func (_u *WeaponUpdate) SetNillableDmg(v *uint) *WeaponUpdate { + if v != nil { + _u.SetDmg(*v) + } + return _u +} + +// AddDmg adds value to the "dmg" field. +func (_u *WeaponUpdate) AddDmg(v int) *WeaponUpdate { + _u.mutation.AddDmg(v) + return _u } // SetEqType sets the "eq_type" field. -func (wu *WeaponUpdate) SetEqType(i int) *WeaponUpdate { - wu.mutation.ResetEqType() - wu.mutation.SetEqType(i) - return wu +func (_u *WeaponUpdate) SetEqType(v int) *WeaponUpdate { + _u.mutation.ResetEqType() + _u.mutation.SetEqType(v) + return _u } -// AddEqType adds i to the "eq_type" field. -func (wu *WeaponUpdate) AddEqType(i int) *WeaponUpdate { - wu.mutation.AddEqType(i) - return wu +// SetNillableEqType sets the "eq_type" field if the given value is not nil. +func (_u *WeaponUpdate) SetNillableEqType(v *int) *WeaponUpdate { + if v != nil { + _u.SetEqType(*v) + } + return _u +} + +// AddEqType adds value to the "eq_type" field. +func (_u *WeaponUpdate) AddEqType(v int) *WeaponUpdate { + _u.mutation.AddEqType(v) + return _u } // SetHitGroup sets the "hit_group" field. -func (wu *WeaponUpdate) SetHitGroup(i int) *WeaponUpdate { - wu.mutation.ResetHitGroup() - wu.mutation.SetHitGroup(i) - return wu +func (_u *WeaponUpdate) SetHitGroup(v int) *WeaponUpdate { + _u.mutation.ResetHitGroup() + _u.mutation.SetHitGroup(v) + return _u } -// AddHitGroup adds i to the "hit_group" field. -func (wu *WeaponUpdate) AddHitGroup(i int) *WeaponUpdate { - wu.mutation.AddHitGroup(i) - return wu +// SetNillableHitGroup sets the "hit_group" field if the given value is not nil. +func (_u *WeaponUpdate) SetNillableHitGroup(v *int) *WeaponUpdate { + if v != nil { + _u.SetHitGroup(*v) + } + return _u +} + +// AddHitGroup adds value to the "hit_group" field. +func (_u *WeaponUpdate) AddHitGroup(v int) *WeaponUpdate { + _u.mutation.AddHitGroup(v) + return _u } // SetStatID sets the "stat" edge to the MatchPlayer entity by ID. -func (wu *WeaponUpdate) SetStatID(id int) *WeaponUpdate { - wu.mutation.SetStatID(id) - return wu +func (_u *WeaponUpdate) SetStatID(id int) *WeaponUpdate { + _u.mutation.SetStatID(id) + return _u } // SetNillableStatID sets the "stat" edge to the MatchPlayer entity by ID if the given value is not nil. -func (wu *WeaponUpdate) SetNillableStatID(id *int) *WeaponUpdate { +func (_u *WeaponUpdate) SetNillableStatID(id *int) *WeaponUpdate { if id != nil { - wu = wu.SetStatID(*id) + _u = _u.SetStatID(*id) } - return wu + return _u } // SetStat sets the "stat" edge to the MatchPlayer entity. -func (wu *WeaponUpdate) SetStat(m *MatchPlayer) *WeaponUpdate { - return wu.SetStatID(m.ID) +func (_u *WeaponUpdate) SetStat(v *MatchPlayer) *WeaponUpdate { + return _u.SetStatID(v.ID) } // Mutation returns the WeaponMutation object of the builder. -func (wu *WeaponUpdate) Mutation() *WeaponMutation { - return wu.mutation +func (_u *WeaponUpdate) Mutation() *WeaponMutation { + return _u.mutation } // ClearStat clears the "stat" edge to the MatchPlayer entity. -func (wu *WeaponUpdate) ClearStat() *WeaponUpdate { - wu.mutation.ClearStat() - return wu +func (_u *WeaponUpdate) ClearStat() *WeaponUpdate { + _u.mutation.ClearStat() + return _u } // Save executes the query and returns the number of nodes affected by the update operation. -func (wu *WeaponUpdate) Save(ctx context.Context) (int, error) { - return withHooks(ctx, wu.sqlSave, wu.mutation, wu.hooks) +func (_u *WeaponUpdate) Save(ctx context.Context) (int, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (wu *WeaponUpdate) SaveX(ctx context.Context) int { - affected, err := wu.Save(ctx) +func (_u *WeaponUpdate) SaveX(ctx context.Context) int { + affected, err := _u.Save(ctx) if err != nil { panic(err) } @@ -126,58 +158,58 @@ func (wu *WeaponUpdate) SaveX(ctx context.Context) int { } // Exec executes the query. -func (wu *WeaponUpdate) Exec(ctx context.Context) error { - _, err := wu.Save(ctx) +func (_u *WeaponUpdate) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (wu *WeaponUpdate) ExecX(ctx context.Context) { - if err := wu.Exec(ctx); err != nil { +func (_u *WeaponUpdate) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // 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 (_u *WeaponUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WeaponUpdate { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (wu *WeaponUpdate) sqlSave(ctx context.Context) (n int, err error) { +func (_u *WeaponUpdate) sqlSave(ctx context.Context) (_node int, err error) { _spec := sqlgraph.NewUpdateSpec(weapon.Table, weapon.Columns, sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt)) - if ps := wu.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := wu.mutation.Victim(); ok { + if value, ok := _u.mutation.Victim(); ok { _spec.SetField(weapon.FieldVictim, field.TypeUint64, value) } - if value, ok := wu.mutation.AddedVictim(); ok { + if value, ok := _u.mutation.AddedVictim(); ok { _spec.AddField(weapon.FieldVictim, field.TypeUint64, value) } - if value, ok := wu.mutation.Dmg(); ok { + if value, ok := _u.mutation.Dmg(); ok { _spec.SetField(weapon.FieldDmg, field.TypeUint, value) } - if value, ok := wu.mutation.AddedDmg(); ok { + if value, ok := _u.mutation.AddedDmg(); ok { _spec.AddField(weapon.FieldDmg, field.TypeUint, value) } - if value, ok := wu.mutation.EqType(); ok { + if value, ok := _u.mutation.EqType(); ok { _spec.SetField(weapon.FieldEqType, field.TypeInt, value) } - if value, ok := wu.mutation.AddedEqType(); ok { + if value, ok := _u.mutation.AddedEqType(); ok { _spec.AddField(weapon.FieldEqType, field.TypeInt, value) } - if value, ok := wu.mutation.HitGroup(); ok { + if value, ok := _u.mutation.HitGroup(); ok { _spec.SetField(weapon.FieldHitGroup, field.TypeInt, value) } - if value, ok := wu.mutation.AddedHitGroup(); ok { + if value, ok := _u.mutation.AddedHitGroup(); ok { _spec.AddField(weapon.FieldHitGroup, field.TypeInt, value) } - if wu.mutation.StatCleared() { + if _u.mutation.StatCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -190,7 +222,7 @@ func (wu *WeaponUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := wu.mutation.StatIDs(); len(nodes) > 0 { + if nodes := _u.mutation.StatIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -206,8 +238,8 @@ func (wu *WeaponUpdate) sqlSave(ctx context.Context) (n int, err error) { } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(wu.modifiers...) - if n, err = sqlgraph.UpdateNodes(ctx, wu.driver, _spec); err != nil { + _spec.AddModifiers(_u.modifiers...) + if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{weapon.Label} } else if sqlgraph.IsConstraintError(err) { @@ -215,8 +247,8 @@ func (wu *WeaponUpdate) sqlSave(ctx context.Context) (n int, err error) { } return 0, err } - wu.mutation.done = true - return n, nil + _u.mutation.done = true + return _node, nil } // WeaponUpdateOne is the builder for updating a single Weapon entity. @@ -229,108 +261,140 @@ type WeaponUpdateOne struct { } // SetVictim sets the "victim" field. -func (wuo *WeaponUpdateOne) SetVictim(u uint64) *WeaponUpdateOne { - wuo.mutation.ResetVictim() - wuo.mutation.SetVictim(u) - return wuo +func (_u *WeaponUpdateOne) SetVictim(v uint64) *WeaponUpdateOne { + _u.mutation.ResetVictim() + _u.mutation.SetVictim(v) + return _u } -// AddVictim adds u to the "victim" field. -func (wuo *WeaponUpdateOne) AddVictim(u int64) *WeaponUpdateOne { - wuo.mutation.AddVictim(u) - return wuo +// SetNillableVictim sets the "victim" field if the given value is not nil. +func (_u *WeaponUpdateOne) SetNillableVictim(v *uint64) *WeaponUpdateOne { + if v != nil { + _u.SetVictim(*v) + } + return _u +} + +// AddVictim adds value to the "victim" field. +func (_u *WeaponUpdateOne) AddVictim(v int64) *WeaponUpdateOne { + _u.mutation.AddVictim(v) + return _u } // SetDmg sets the "dmg" field. -func (wuo *WeaponUpdateOne) SetDmg(u uint) *WeaponUpdateOne { - wuo.mutation.ResetDmg() - wuo.mutation.SetDmg(u) - return wuo +func (_u *WeaponUpdateOne) SetDmg(v uint) *WeaponUpdateOne { + _u.mutation.ResetDmg() + _u.mutation.SetDmg(v) + return _u } -// AddDmg adds u to the "dmg" field. -func (wuo *WeaponUpdateOne) AddDmg(u int) *WeaponUpdateOne { - wuo.mutation.AddDmg(u) - return wuo +// SetNillableDmg sets the "dmg" field if the given value is not nil. +func (_u *WeaponUpdateOne) SetNillableDmg(v *uint) *WeaponUpdateOne { + if v != nil { + _u.SetDmg(*v) + } + return _u +} + +// AddDmg adds value to the "dmg" field. +func (_u *WeaponUpdateOne) AddDmg(v int) *WeaponUpdateOne { + _u.mutation.AddDmg(v) + return _u } // SetEqType sets the "eq_type" field. -func (wuo *WeaponUpdateOne) SetEqType(i int) *WeaponUpdateOne { - wuo.mutation.ResetEqType() - wuo.mutation.SetEqType(i) - return wuo +func (_u *WeaponUpdateOne) SetEqType(v int) *WeaponUpdateOne { + _u.mutation.ResetEqType() + _u.mutation.SetEqType(v) + return _u } -// AddEqType adds i to the "eq_type" field. -func (wuo *WeaponUpdateOne) AddEqType(i int) *WeaponUpdateOne { - wuo.mutation.AddEqType(i) - return wuo +// SetNillableEqType sets the "eq_type" field if the given value is not nil. +func (_u *WeaponUpdateOne) SetNillableEqType(v *int) *WeaponUpdateOne { + if v != nil { + _u.SetEqType(*v) + } + return _u +} + +// AddEqType adds value to the "eq_type" field. +func (_u *WeaponUpdateOne) AddEqType(v int) *WeaponUpdateOne { + _u.mutation.AddEqType(v) + return _u } // SetHitGroup sets the "hit_group" field. -func (wuo *WeaponUpdateOne) SetHitGroup(i int) *WeaponUpdateOne { - wuo.mutation.ResetHitGroup() - wuo.mutation.SetHitGroup(i) - return wuo +func (_u *WeaponUpdateOne) SetHitGroup(v int) *WeaponUpdateOne { + _u.mutation.ResetHitGroup() + _u.mutation.SetHitGroup(v) + return _u } -// AddHitGroup adds i to the "hit_group" field. -func (wuo *WeaponUpdateOne) AddHitGroup(i int) *WeaponUpdateOne { - wuo.mutation.AddHitGroup(i) - return wuo +// SetNillableHitGroup sets the "hit_group" field if the given value is not nil. +func (_u *WeaponUpdateOne) SetNillableHitGroup(v *int) *WeaponUpdateOne { + if v != nil { + _u.SetHitGroup(*v) + } + return _u +} + +// AddHitGroup adds value to the "hit_group" field. +func (_u *WeaponUpdateOne) AddHitGroup(v int) *WeaponUpdateOne { + _u.mutation.AddHitGroup(v) + return _u } // SetStatID sets the "stat" edge to the MatchPlayer entity by ID. -func (wuo *WeaponUpdateOne) SetStatID(id int) *WeaponUpdateOne { - wuo.mutation.SetStatID(id) - return wuo +func (_u *WeaponUpdateOne) SetStatID(id int) *WeaponUpdateOne { + _u.mutation.SetStatID(id) + return _u } // SetNillableStatID sets the "stat" edge to the MatchPlayer entity by ID if the given value is not nil. -func (wuo *WeaponUpdateOne) SetNillableStatID(id *int) *WeaponUpdateOne { +func (_u *WeaponUpdateOne) SetNillableStatID(id *int) *WeaponUpdateOne { if id != nil { - wuo = wuo.SetStatID(*id) + _u = _u.SetStatID(*id) } - return wuo + return _u } // SetStat sets the "stat" edge to the MatchPlayer entity. -func (wuo *WeaponUpdateOne) SetStat(m *MatchPlayer) *WeaponUpdateOne { - return wuo.SetStatID(m.ID) +func (_u *WeaponUpdateOne) SetStat(v *MatchPlayer) *WeaponUpdateOne { + return _u.SetStatID(v.ID) } // Mutation returns the WeaponMutation object of the builder. -func (wuo *WeaponUpdateOne) Mutation() *WeaponMutation { - return wuo.mutation +func (_u *WeaponUpdateOne) Mutation() *WeaponMutation { + return _u.mutation } // ClearStat clears the "stat" edge to the MatchPlayer entity. -func (wuo *WeaponUpdateOne) ClearStat() *WeaponUpdateOne { - wuo.mutation.ClearStat() - return wuo +func (_u *WeaponUpdateOne) ClearStat() *WeaponUpdateOne { + _u.mutation.ClearStat() + return _u } // Where appends a list predicates to the WeaponUpdate builder. -func (wuo *WeaponUpdateOne) Where(ps ...predicate.Weapon) *WeaponUpdateOne { - wuo.mutation.Where(ps...) - return wuo +func (_u *WeaponUpdateOne) Where(ps ...predicate.Weapon) *WeaponUpdateOne { + _u.mutation.Where(ps...) + return _u } // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. -func (wuo *WeaponUpdateOne) Select(field string, fields ...string) *WeaponUpdateOne { - wuo.fields = append([]string{field}, fields...) - return wuo +func (_u *WeaponUpdateOne) Select(field string, fields ...string) *WeaponUpdateOne { + _u.fields = append([]string{field}, fields...) + return _u } // Save executes the query and returns the updated Weapon entity. -func (wuo *WeaponUpdateOne) Save(ctx context.Context) (*Weapon, error) { - return withHooks(ctx, wuo.sqlSave, wuo.mutation, wuo.hooks) +func (_u *WeaponUpdateOne) Save(ctx context.Context) (*Weapon, error) { + return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks) } // SaveX is like Save, but panics if an error occurs. -func (wuo *WeaponUpdateOne) SaveX(ctx context.Context) *Weapon { - node, err := wuo.Save(ctx) +func (_u *WeaponUpdateOne) SaveX(ctx context.Context) *Weapon { + node, err := _u.Save(ctx) if err != nil { panic(err) } @@ -338,32 +402,32 @@ func (wuo *WeaponUpdateOne) SaveX(ctx context.Context) *Weapon { } // Exec executes the query on the entity. -func (wuo *WeaponUpdateOne) Exec(ctx context.Context) error { - _, err := wuo.Save(ctx) +func (_u *WeaponUpdateOne) Exec(ctx context.Context) error { + _, err := _u.Save(ctx) return err } // ExecX is like Exec, but panics if an error occurs. -func (wuo *WeaponUpdateOne) ExecX(ctx context.Context) { - if err := wuo.Exec(ctx); err != nil { +func (_u *WeaponUpdateOne) ExecX(ctx context.Context) { + if err := _u.Exec(ctx); err != nil { panic(err) } } // 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 (_u *WeaponUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WeaponUpdateOne { + _u.modifiers = append(_u.modifiers, modifiers...) + return _u } -func (wuo *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err error) { +func (_u *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err error) { _spec := sqlgraph.NewUpdateSpec(weapon.Table, weapon.Columns, sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt)) - id, ok := wuo.mutation.ID() + id, ok := _u.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Weapon.id" for update`)} } _spec.Node.ID.Value = id - if fields := wuo.fields; len(fields) > 0 { + if fields := _u.fields; len(fields) > 0 { _spec.Node.Columns = make([]string, 0, len(fields)) _spec.Node.Columns = append(_spec.Node.Columns, weapon.FieldID) for _, f := range fields { @@ -375,38 +439,38 @@ func (wuo *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err err } } } - if ps := wuo.mutation.predicates; len(ps) > 0 { + if ps := _u.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { ps[i](selector) } } } - if value, ok := wuo.mutation.Victim(); ok { + if value, ok := _u.mutation.Victim(); ok { _spec.SetField(weapon.FieldVictim, field.TypeUint64, value) } - if value, ok := wuo.mutation.AddedVictim(); ok { + if value, ok := _u.mutation.AddedVictim(); ok { _spec.AddField(weapon.FieldVictim, field.TypeUint64, value) } - if value, ok := wuo.mutation.Dmg(); ok { + if value, ok := _u.mutation.Dmg(); ok { _spec.SetField(weapon.FieldDmg, field.TypeUint, value) } - if value, ok := wuo.mutation.AddedDmg(); ok { + if value, ok := _u.mutation.AddedDmg(); ok { _spec.AddField(weapon.FieldDmg, field.TypeUint, value) } - if value, ok := wuo.mutation.EqType(); ok { + if value, ok := _u.mutation.EqType(); ok { _spec.SetField(weapon.FieldEqType, field.TypeInt, value) } - if value, ok := wuo.mutation.AddedEqType(); ok { + if value, ok := _u.mutation.AddedEqType(); ok { _spec.AddField(weapon.FieldEqType, field.TypeInt, value) } - if value, ok := wuo.mutation.HitGroup(); ok { + if value, ok := _u.mutation.HitGroup(); ok { _spec.SetField(weapon.FieldHitGroup, field.TypeInt, value) } - if value, ok := wuo.mutation.AddedHitGroup(); ok { + if value, ok := _u.mutation.AddedHitGroup(); ok { _spec.AddField(weapon.FieldHitGroup, field.TypeInt, value) } - if wuo.mutation.StatCleared() { + if _u.mutation.StatCleared() { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -419,7 +483,7 @@ func (wuo *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err err } _spec.Edges.Clear = append(_spec.Edges.Clear, edge) } - if nodes := wuo.mutation.StatIDs(); len(nodes) > 0 { + if nodes := _u.mutation.StatIDs(); len(nodes) > 0 { edge := &sqlgraph.EdgeSpec{ Rel: sqlgraph.M2O, Inverse: true, @@ -435,11 +499,11 @@ func (wuo *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err err } _spec.Edges.Add = append(_spec.Edges.Add, edge) } - _spec.AddModifiers(wuo.modifiers...) - _node = &Weapon{config: wuo.config} + _spec.AddModifiers(_u.modifiers...) + _node = &Weapon{config: _u.config} _spec.Assign = _node.assignValues _spec.ScanValues = _node.scanValues - if err = sqlgraph.UpdateNode(ctx, wuo.driver, _spec); err != nil { + if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil { if _, ok := err.(*sqlgraph.NotFoundError); ok { err = &NotFoundError{weapon.Label} } else if sqlgraph.IsConstraintError(err) { @@ -447,6 +511,6 @@ func (wuo *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err err } return nil, err } - wuo.mutation.done = true + _u.mutation.done = true return _node, nil }