regenerate ent

This commit is contained in:
2025-10-26 05:09:47 +01:00
parent 5358d9dd0f
commit ab8b0b983c
46 changed files with 6050 additions and 5607 deletions

View File

@@ -7,6 +7,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"log" "log"
"reflect"
"somegit.dev/csgowtf/csgowtfd/ent/migrate" "somegit.dev/csgowtf/csgowtfd/ent/migrate"
@@ -46,9 +47,7 @@ type Client struct {
// NewClient creates a new client configured with the given options. // NewClient creates a new client configured with the given options.
func NewClient(opts ...Option) *Client { func NewClient(opts ...Option) *Client {
cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} client := &Client{config: newConfig(opts...)}
cfg.options(opts...)
client := &Client{config: cfg}
client.init() client.init()
return client return client
} }
@@ -82,6 +81,13 @@ type (
Option func(*config) 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. // options applies the options on the config object.
func (c *config) options(opts ...Option) { func (c *config) options(opts ...Option) {
for _, opt := range opts { 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 // Tx returns a new transactional client. The provided context
// is used until the transaction is committed or rolled back. // is used until the transaction is committed or rolled back.
func (c *Client) Tx(ctx context.Context) (*Tx, error) { func (c *Client) Tx(ctx context.Context) (*Tx, error) {
if _, ok := c.driver.(*txDriver); ok { 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) tx, err := newTx(ctx, c.driver)
if err != nil { if err != nil {
@@ -277,6 +286,21 @@ func (c *MatchClient) CreateBulk(builders ...*MatchCreate) *MatchCreateBulk {
return &MatchCreateBulk{config: c.config, builders: builders} 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. // Update returns an update builder for Match.
func (c *MatchClient) Update() *MatchUpdate { func (c *MatchClient) Update() *MatchUpdate {
mutation := newMatchMutation(c.config, OpUpdate) mutation := newMatchMutation(c.config, OpUpdate)
@@ -284,8 +308,8 @@ func (c *MatchClient) Update() *MatchUpdate {
} }
// UpdateOne returns an update builder for the given entity. // UpdateOne returns an update builder for the given entity.
func (c *MatchClient) UpdateOne(m *Match) *MatchUpdateOne { func (c *MatchClient) UpdateOne(_m *Match) *MatchUpdateOne {
mutation := newMatchMutation(c.config, OpUpdateOne, withMatch(m)) mutation := newMatchMutation(c.config, OpUpdateOne, withMatch(_m))
return &MatchUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} 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. // DeleteOne returns a builder for deleting the given entity.
func (c *MatchClient) DeleteOne(m *Match) *MatchDeleteOne { func (c *MatchClient) DeleteOne(_m *Match) *MatchDeleteOne {
return c.DeleteOneID(m.ID) return c.DeleteOneID(_m.ID)
} }
// DeleteOneID returns a builder for deleting the given entity by its 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. // 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 := (&MatchPlayerClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := m.ID id := _m.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(match.Table, match.FieldID, id), sqlgraph.From(match.Table, match.FieldID, id),
sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, match.StatsTable, match.StatsColumn), 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 fromV, nil
} }
return query return query
} }
// QueryPlayers queries the players edge of a Match. // 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 := (&PlayerClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := m.ID id := _m.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(match.Table, match.FieldID, id), sqlgraph.From(match.Table, match.FieldID, id),
sqlgraph.To(player.Table, player.FieldID), sqlgraph.To(player.Table, player.FieldID),
sqlgraph.Edge(sqlgraph.M2M, true, match.PlayersTable, match.PlayersPrimaryKey...), 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 fromV, nil
} }
return query return query
@@ -427,6 +451,21 @@ func (c *MatchPlayerClient) CreateBulk(builders ...*MatchPlayerCreate) *MatchPla
return &MatchPlayerCreateBulk{config: c.config, builders: builders} 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. // Update returns an update builder for MatchPlayer.
func (c *MatchPlayerClient) Update() *MatchPlayerUpdate { func (c *MatchPlayerClient) Update() *MatchPlayerUpdate {
mutation := newMatchPlayerMutation(c.config, OpUpdate) mutation := newMatchPlayerMutation(c.config, OpUpdate)
@@ -434,8 +473,8 @@ func (c *MatchPlayerClient) Update() *MatchPlayerUpdate {
} }
// UpdateOne returns an update builder for the given entity. // UpdateOne returns an update builder for the given entity.
func (c *MatchPlayerClient) UpdateOne(mp *MatchPlayer) *MatchPlayerUpdateOne { func (c *MatchPlayerClient) UpdateOne(_m *MatchPlayer) *MatchPlayerUpdateOne {
mutation := newMatchPlayerMutation(c.config, OpUpdateOne, withMatchPlayer(mp)) mutation := newMatchPlayerMutation(c.config, OpUpdateOne, withMatchPlayer(_m))
return &MatchPlayerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} 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. // DeleteOne returns a builder for deleting the given entity.
func (c *MatchPlayerClient) DeleteOne(mp *MatchPlayer) *MatchPlayerDeleteOne { func (c *MatchPlayerClient) DeleteOne(_m *MatchPlayer) *MatchPlayerDeleteOne {
return c.DeleteOneID(mp.ID) return c.DeleteOneID(_m.ID)
} }
// DeleteOneID returns a builder for deleting the given entity by its 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. // 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 := (&MatchClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := mp.ID id := _m.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id), sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id),
sqlgraph.To(match.Table, match.FieldID), sqlgraph.To(match.Table, match.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, matchplayer.MatchesTable, matchplayer.MatchesColumn), 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 fromV, nil
} }
return query return query
} }
// QueryPlayers queries the players edge of a MatchPlayer. // 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 := (&PlayerClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := mp.ID id := _m.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id), sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id),
sqlgraph.To(player.Table, player.FieldID), sqlgraph.To(player.Table, player.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, matchplayer.PlayersTable, matchplayer.PlayersColumn), 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 fromV, nil
} }
return query return query
} }
// QueryWeaponStats queries the weapon_stats edge of a MatchPlayer. // 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 := (&WeaponClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := mp.ID id := _m.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id), sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id),
sqlgraph.To(weapon.Table, weapon.FieldID), sqlgraph.To(weapon.Table, weapon.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.WeaponStatsTable, matchplayer.WeaponStatsColumn), 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 fromV, nil
} }
return query return query
} }
// QueryRoundStats queries the round_stats edge of a MatchPlayer. // 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 := (&RoundStatsClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := mp.ID id := _m.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id), sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id),
sqlgraph.To(roundstats.Table, roundstats.FieldID), sqlgraph.To(roundstats.Table, roundstats.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.RoundStatsTable, matchplayer.RoundStatsColumn), 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 fromV, nil
} }
return query return query
} }
// QuerySpray queries the spray edge of a MatchPlayer. // 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 := (&SprayClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := mp.ID id := _m.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id), sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id),
sqlgraph.To(spray.Table, spray.FieldID), sqlgraph.To(spray.Table, spray.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.SprayTable, matchplayer.SprayColumn), 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 fromV, nil
} }
return query return query
} }
// QueryMessages queries the messages edge of a MatchPlayer. // 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 := (&MessagesClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := mp.ID id := _m.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id), sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id),
sqlgraph.To(messages.Table, messages.FieldID), sqlgraph.To(messages.Table, messages.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.MessagesTable, matchplayer.MessagesColumn), 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 fromV, nil
} }
return query return query
@@ -641,6 +680,21 @@ func (c *MessagesClient) CreateBulk(builders ...*MessagesCreate) *MessagesCreate
return &MessagesCreateBulk{config: c.config, builders: builders} 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. // Update returns an update builder for Messages.
func (c *MessagesClient) Update() *MessagesUpdate { func (c *MessagesClient) Update() *MessagesUpdate {
mutation := newMessagesMutation(c.config, OpUpdate) mutation := newMessagesMutation(c.config, OpUpdate)
@@ -648,8 +702,8 @@ func (c *MessagesClient) Update() *MessagesUpdate {
} }
// UpdateOne returns an update builder for the given entity. // UpdateOne returns an update builder for the given entity.
func (c *MessagesClient) UpdateOne(m *Messages) *MessagesUpdateOne { func (c *MessagesClient) UpdateOne(_m *Messages) *MessagesUpdateOne {
mutation := newMessagesMutation(c.config, OpUpdateOne, withMessages(m)) mutation := newMessagesMutation(c.config, OpUpdateOne, withMessages(_m))
return &MessagesUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} 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. // DeleteOne returns a builder for deleting the given entity.
func (c *MessagesClient) DeleteOne(m *Messages) *MessagesDeleteOne { func (c *MessagesClient) DeleteOne(_m *Messages) *MessagesDeleteOne {
return c.DeleteOneID(m.ID) return c.DeleteOneID(_m.ID)
} }
// DeleteOneID returns a builder for deleting the given entity by its 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. // 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 := (&MatchPlayerClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := m.ID id := _m.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(messages.Table, messages.FieldID, id), sqlgraph.From(messages.Table, messages.FieldID, id),
sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, messages.MatchPlayerTable, messages.MatchPlayerColumn), 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 fromV, nil
} }
return query return query
@@ -775,6 +829,21 @@ func (c *PlayerClient) CreateBulk(builders ...*PlayerCreate) *PlayerCreateBulk {
return &PlayerCreateBulk{config: c.config, builders: builders} 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. // Update returns an update builder for Player.
func (c *PlayerClient) Update() *PlayerUpdate { func (c *PlayerClient) Update() *PlayerUpdate {
mutation := newPlayerMutation(c.config, OpUpdate) mutation := newPlayerMutation(c.config, OpUpdate)
@@ -782,8 +851,8 @@ func (c *PlayerClient) Update() *PlayerUpdate {
} }
// UpdateOne returns an update builder for the given entity. // UpdateOne returns an update builder for the given entity.
func (c *PlayerClient) UpdateOne(pl *Player) *PlayerUpdateOne { func (c *PlayerClient) UpdateOne(_m *Player) *PlayerUpdateOne {
mutation := newPlayerMutation(c.config, OpUpdateOne, withPlayer(pl)) mutation := newPlayerMutation(c.config, OpUpdateOne, withPlayer(_m))
return &PlayerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} 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. // DeleteOne returns a builder for deleting the given entity.
func (c *PlayerClient) DeleteOne(pl *Player) *PlayerDeleteOne { func (c *PlayerClient) DeleteOne(_m *Player) *PlayerDeleteOne {
return c.DeleteOneID(pl.ID) return c.DeleteOneID(_m.ID)
} }
// DeleteOneID returns a builder for deleting the given entity by its 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. // 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 := (&MatchPlayerClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := pl.ID id := _m.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(player.Table, player.FieldID, id), sqlgraph.From(player.Table, player.FieldID, id),
sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, player.StatsTable, player.StatsColumn), 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 fromV, nil
} }
return query return query
} }
// QueryMatches queries the matches edge of a Player. // 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 := (&MatchClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := pl.ID id := _m.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(player.Table, player.FieldID, id), sqlgraph.From(player.Table, player.FieldID, id),
sqlgraph.To(match.Table, match.FieldID), sqlgraph.To(match.Table, match.FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, player.MatchesTable, player.MatchesPrimaryKey...), 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 fromV, nil
} }
return query return query
@@ -925,6 +994,21 @@ func (c *RoundStatsClient) CreateBulk(builders ...*RoundStatsCreate) *RoundStats
return &RoundStatsCreateBulk{config: c.config, builders: builders} 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. // Update returns an update builder for RoundStats.
func (c *RoundStatsClient) Update() *RoundStatsUpdate { func (c *RoundStatsClient) Update() *RoundStatsUpdate {
mutation := newRoundStatsMutation(c.config, OpUpdate) mutation := newRoundStatsMutation(c.config, OpUpdate)
@@ -932,8 +1016,8 @@ func (c *RoundStatsClient) Update() *RoundStatsUpdate {
} }
// UpdateOne returns an update builder for the given entity. // UpdateOne returns an update builder for the given entity.
func (c *RoundStatsClient) UpdateOne(rs *RoundStats) *RoundStatsUpdateOne { func (c *RoundStatsClient) UpdateOne(_m *RoundStats) *RoundStatsUpdateOne {
mutation := newRoundStatsMutation(c.config, OpUpdateOne, withRoundStats(rs)) mutation := newRoundStatsMutation(c.config, OpUpdateOne, withRoundStats(_m))
return &RoundStatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} 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. // DeleteOne returns a builder for deleting the given entity.
func (c *RoundStatsClient) DeleteOne(rs *RoundStats) *RoundStatsDeleteOne { func (c *RoundStatsClient) DeleteOne(_m *RoundStats) *RoundStatsDeleteOne {
return c.DeleteOneID(rs.ID) return c.DeleteOneID(_m.ID)
} }
// DeleteOneID returns a builder for deleting the given entity by its 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. // 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 := (&MatchPlayerClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := rs.ID id := _m.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(roundstats.Table, roundstats.FieldID, id), sqlgraph.From(roundstats.Table, roundstats.FieldID, id),
sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, roundstats.MatchPlayerTable, roundstats.MatchPlayerColumn), 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 fromV, nil
} }
return query return query
@@ -1059,6 +1143,21 @@ func (c *SprayClient) CreateBulk(builders ...*SprayCreate) *SprayCreateBulk {
return &SprayCreateBulk{config: c.config, builders: builders} 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. // Update returns an update builder for Spray.
func (c *SprayClient) Update() *SprayUpdate { func (c *SprayClient) Update() *SprayUpdate {
mutation := newSprayMutation(c.config, OpUpdate) mutation := newSprayMutation(c.config, OpUpdate)
@@ -1066,8 +1165,8 @@ func (c *SprayClient) Update() *SprayUpdate {
} }
// UpdateOne returns an update builder for the given entity. // UpdateOne returns an update builder for the given entity.
func (c *SprayClient) UpdateOne(s *Spray) *SprayUpdateOne { func (c *SprayClient) UpdateOne(_m *Spray) *SprayUpdateOne {
mutation := newSprayMutation(c.config, OpUpdateOne, withSpray(s)) mutation := newSprayMutation(c.config, OpUpdateOne, withSpray(_m))
return &SprayUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} 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. // DeleteOne returns a builder for deleting the given entity.
func (c *SprayClient) DeleteOne(s *Spray) *SprayDeleteOne { func (c *SprayClient) DeleteOne(_m *Spray) *SprayDeleteOne {
return c.DeleteOneID(s.ID) return c.DeleteOneID(_m.ID)
} }
// DeleteOneID returns a builder for deleting the given entity by its 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. // 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 := (&MatchPlayerClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := s.ID id := _m.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(spray.Table, spray.FieldID, id), sqlgraph.From(spray.Table, spray.FieldID, id),
sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, spray.MatchPlayersTable, spray.MatchPlayersColumn), 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 fromV, nil
} }
return query return query
@@ -1193,6 +1292,21 @@ func (c *WeaponClient) CreateBulk(builders ...*WeaponCreate) *WeaponCreateBulk {
return &WeaponCreateBulk{config: c.config, builders: builders} 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. // Update returns an update builder for Weapon.
func (c *WeaponClient) Update() *WeaponUpdate { func (c *WeaponClient) Update() *WeaponUpdate {
mutation := newWeaponMutation(c.config, OpUpdate) mutation := newWeaponMutation(c.config, OpUpdate)
@@ -1200,8 +1314,8 @@ func (c *WeaponClient) Update() *WeaponUpdate {
} }
// UpdateOne returns an update builder for the given entity. // UpdateOne returns an update builder for the given entity.
func (c *WeaponClient) UpdateOne(w *Weapon) *WeaponUpdateOne { func (c *WeaponClient) UpdateOne(_m *Weapon) *WeaponUpdateOne {
mutation := newWeaponMutation(c.config, OpUpdateOne, withWeapon(w)) mutation := newWeaponMutation(c.config, OpUpdateOne, withWeapon(_m))
return &WeaponUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation} 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. // DeleteOne returns a builder for deleting the given entity.
func (c *WeaponClient) DeleteOne(w *Weapon) *WeaponDeleteOne { func (c *WeaponClient) DeleteOne(_m *Weapon) *WeaponDeleteOne {
return c.DeleteOneID(w.ID) return c.DeleteOneID(_m.ID)
} }
// DeleteOneID returns a builder for deleting the given entity by its 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. // 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 := (&MatchPlayerClient{config: c.config}).Query()
query.path = func(context.Context) (fromV *sql.Selector, _ error) { query.path = func(context.Context) (fromV *sql.Selector, _ error) {
id := w.ID id := _m.ID
step := sqlgraph.NewStep( step := sqlgraph.NewStep(
sqlgraph.From(weapon.Table, weapon.FieldID, id), sqlgraph.From(weapon.Table, weapon.FieldID, id),
sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, weapon.StatTable, weapon.StatColumn), 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 fromV, nil
} }
return query return query

View File

@@ -75,8 +75,8 @@ var (
columnCheck sql.ColumnCheck columnCheck sql.ColumnCheck
) )
// columnChecker checks if the column exists in the given table. // checkColumn checks if the column exists in the given table.
func checkColumn(table, column string) error { func checkColumn(t, c string) error {
initCheck.Do(func() { initCheck.Do(func() {
columnCheck = sql.NewColumnCheck(map[string]func(string) bool{ columnCheck = sql.NewColumnCheck(map[string]func(string) bool{
match.Table: match.ValidColumn, match.Table: match.ValidColumn,
@@ -88,7 +88,7 @@ func checkColumn(table, column string) error {
weapon.Table: weapon.ValidColumn, weapon.Table: weapon.ValidColumn,
}) })
}) })
return columnCheck(table, column) return columnCheck(t, c)
} }
// Asc applies the given fields in ASC order. // Asc applies the given fields in ASC order.

View File

@@ -106,7 +106,7 @@ func (*Match) scanValues(columns []string) ([]any, error) {
// assignValues assigns the values that were returned from sql.Rows (after scanning) // assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Match fields. // 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 { if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", 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 { if !ok {
return fmt.Errorf("unexpected type %T for field id", value) return fmt.Errorf("unexpected type %T for field id", value)
} }
m.ID = uint64(value.Int64) _m.ID = uint64(value.Int64)
case match.FieldShareCode: case match.FieldShareCode:
if value, ok := values[i].(*sql.NullString); !ok { if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field share_code", values[i]) return fmt.Errorf("unexpected type %T for field share_code", values[i])
} else if value.Valid { } else if value.Valid {
m.ShareCode = value.String _m.ShareCode = value.String
} }
case match.FieldMap: case match.FieldMap:
if value, ok := values[i].(*sql.NullString); !ok { if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field map", values[i]) return fmt.Errorf("unexpected type %T for field map", values[i])
} else if value.Valid { } else if value.Valid {
m.Map = value.String _m.Map = value.String
} }
case match.FieldDate: case match.FieldDate:
if value, ok := values[i].(*sql.NullTime); !ok { if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field date", values[i]) return fmt.Errorf("unexpected type %T for field date", values[i])
} else if value.Valid { } else if value.Valid {
m.Date = value.Time _m.Date = value.Time
} }
case match.FieldScoreTeamA: case match.FieldScoreTeamA:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field score_team_a", values[i]) return fmt.Errorf("unexpected type %T for field score_team_a", values[i])
} else if value.Valid { } else if value.Valid {
m.ScoreTeamA = int(value.Int64) _m.ScoreTeamA = int(value.Int64)
} }
case match.FieldScoreTeamB: case match.FieldScoreTeamB:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field score_team_b", values[i]) return fmt.Errorf("unexpected type %T for field score_team_b", values[i])
} else if value.Valid { } else if value.Valid {
m.ScoreTeamB = int(value.Int64) _m.ScoreTeamB = int(value.Int64)
} }
case match.FieldReplayURL: case match.FieldReplayURL:
if value, ok := values[i].(*sql.NullString); !ok { if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field replay_url", values[i]) return fmt.Errorf("unexpected type %T for field replay_url", values[i])
} else if value.Valid { } else if value.Valid {
m.ReplayURL = value.String _m.ReplayURL = value.String
} }
case match.FieldDuration: case match.FieldDuration:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field duration", values[i]) return fmt.Errorf("unexpected type %T for field duration", values[i])
} else if value.Valid { } else if value.Valid {
m.Duration = int(value.Int64) _m.Duration = int(value.Int64)
} }
case match.FieldMatchResult: case match.FieldMatchResult:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field match_result", values[i]) return fmt.Errorf("unexpected type %T for field match_result", values[i])
} else if value.Valid { } else if value.Valid {
m.MatchResult = int(value.Int64) _m.MatchResult = int(value.Int64)
} }
case match.FieldMaxRounds: case match.FieldMaxRounds:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field max_rounds", values[i]) return fmt.Errorf("unexpected type %T for field max_rounds", values[i])
} else if value.Valid { } else if value.Valid {
m.MaxRounds = int(value.Int64) _m.MaxRounds = int(value.Int64)
} }
case match.FieldDemoParsed: case match.FieldDemoParsed:
if value, ok := values[i].(*sql.NullBool); !ok { if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field demo_parsed", values[i]) return fmt.Errorf("unexpected type %T for field demo_parsed", values[i])
} else if value.Valid { } else if value.Valid {
m.DemoParsed = value.Bool _m.DemoParsed = value.Bool
} }
case match.FieldVacPresent: case match.FieldVacPresent:
if value, ok := values[i].(*sql.NullBool); !ok { if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field vac_present", values[i]) return fmt.Errorf("unexpected type %T for field vac_present", values[i])
} else if value.Valid { } else if value.Valid {
m.VacPresent = value.Bool _m.VacPresent = value.Bool
} }
case match.FieldGamebanPresent: case match.FieldGamebanPresent:
if value, ok := values[i].(*sql.NullBool); !ok { if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field gameban_present", values[i]) return fmt.Errorf("unexpected type %T for field gameban_present", values[i])
} else if value.Valid { } else if value.Valid {
m.GamebanPresent = value.Bool _m.GamebanPresent = value.Bool
} }
case match.FieldDecryptionKey: case match.FieldDecryptionKey:
if value, ok := values[i].(*[]byte); !ok { if value, ok := values[i].(*[]byte); !ok {
return fmt.Errorf("unexpected type %T for field decryption_key", values[i]) return fmt.Errorf("unexpected type %T for field decryption_key", values[i])
} else if value != nil { } else if value != nil {
m.DecryptionKey = *value _m.DecryptionKey = *value
} }
case match.FieldTickRate: case match.FieldTickRate:
if value, ok := values[i].(*sql.NullFloat64); !ok { if value, ok := values[i].(*sql.NullFloat64); !ok {
return fmt.Errorf("unexpected type %T for field tick_rate", values[i]) return fmt.Errorf("unexpected type %T for field tick_rate", values[i])
} else if value.Valid { } else if value.Valid {
m.TickRate = value.Float64 _m.TickRate = value.Float64
} }
default: default:
m.selectValues.Set(columns[i], values[i]) _m.selectValues.Set(columns[i], values[i])
} }
} }
return nil 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. // Value returns the ent.Value that was dynamically selected and assigned to the Match.
// This includes values selected through modifiers, order, etc. // This includes values selected through modifiers, order, etc.
func (m *Match) Value(name string) (ent.Value, error) { func (_m *Match) Value(name string) (ent.Value, error) {
return m.selectValues.Get(name) return _m.selectValues.Get(name)
} }
// QueryStats queries the "stats" edge of the Match entity. // QueryStats queries the "stats" edge of the Match entity.
func (m *Match) QueryStats() *MatchPlayerQuery { func (_m *Match) QueryStats() *MatchPlayerQuery {
return NewMatchClient(m.config).QueryStats(m) return NewMatchClient(_m.config).QueryStats(_m)
} }
// QueryPlayers queries the "players" edge of the Match entity. // QueryPlayers queries the "players" edge of the Match entity.
func (m *Match) QueryPlayers() *PlayerQuery { func (_m *Match) QueryPlayers() *PlayerQuery {
return NewMatchClient(m.config).QueryPlayers(m) return NewMatchClient(_m.config).QueryPlayers(_m)
} }
// Update returns a builder for updating this Match. // Update returns a builder for updating this Match.
// Note that you need to call Match.Unwrap() before calling this method if 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. // was returned from a transaction, and the transaction was committed or rolled back.
func (m *Match) Update() *MatchUpdateOne { func (_m *Match) Update() *MatchUpdateOne {
return NewMatchClient(m.config).UpdateOne(m) return NewMatchClient(_m.config).UpdateOne(_m)
} }
// Unwrap unwraps the Match entity that was returned from a transaction after it was closed, // 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. // so that all future queries will be executed through the driver which created the transaction.
func (m *Match) Unwrap() *Match { func (_m *Match) Unwrap() *Match {
_tx, ok := m.config.driver.(*txDriver) _tx, ok := _m.config.driver.(*txDriver)
if !ok { if !ok {
panic("ent: Match is not a transactional entity") panic("ent: Match is not a transactional entity")
} }
m.config.driver = _tx.drv _m.config.driver = _tx.drv
return m return _m
} }
// String implements the fmt.Stringer. // String implements the fmt.Stringer.
func (m *Match) String() string { func (_m *Match) String() string {
var builder strings.Builder var builder strings.Builder
builder.WriteString("Match(") 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("share_code=")
builder.WriteString(m.ShareCode) builder.WriteString(_m.ShareCode)
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("map=") builder.WriteString("map=")
builder.WriteString(m.Map) builder.WriteString(_m.Map)
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("date=") builder.WriteString("date=")
builder.WriteString(m.Date.Format(time.ANSIC)) builder.WriteString(_m.Date.Format(time.ANSIC))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("score_team_a=") builder.WriteString("score_team_a=")
builder.WriteString(fmt.Sprintf("%v", m.ScoreTeamA)) builder.WriteString(fmt.Sprintf("%v", _m.ScoreTeamA))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("score_team_b=") builder.WriteString("score_team_b=")
builder.WriteString(fmt.Sprintf("%v", m.ScoreTeamB)) builder.WriteString(fmt.Sprintf("%v", _m.ScoreTeamB))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("replay_url=") builder.WriteString("replay_url=")
builder.WriteString(m.ReplayURL) builder.WriteString(_m.ReplayURL)
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("duration=") builder.WriteString("duration=")
builder.WriteString(fmt.Sprintf("%v", m.Duration)) builder.WriteString(fmt.Sprintf("%v", _m.Duration))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("match_result=") builder.WriteString("match_result=")
builder.WriteString(fmt.Sprintf("%v", m.MatchResult)) builder.WriteString(fmt.Sprintf("%v", _m.MatchResult))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("max_rounds=") builder.WriteString("max_rounds=")
builder.WriteString(fmt.Sprintf("%v", m.MaxRounds)) builder.WriteString(fmt.Sprintf("%v", _m.MaxRounds))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("demo_parsed=") builder.WriteString("demo_parsed=")
builder.WriteString(fmt.Sprintf("%v", m.DemoParsed)) builder.WriteString(fmt.Sprintf("%v", _m.DemoParsed))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("vac_present=") builder.WriteString("vac_present=")
builder.WriteString(fmt.Sprintf("%v", m.VacPresent)) builder.WriteString(fmt.Sprintf("%v", _m.VacPresent))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("gameban_present=") builder.WriteString("gameban_present=")
builder.WriteString(fmt.Sprintf("%v", m.GamebanPresent)) builder.WriteString(fmt.Sprintf("%v", _m.GamebanPresent))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("decryption_key=") builder.WriteString("decryption_key=")
builder.WriteString(fmt.Sprintf("%v", m.DecryptionKey)) builder.WriteString(fmt.Sprintf("%v", _m.DecryptionKey))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("tick_rate=") builder.WriteString("tick_rate=")
builder.WriteString(fmt.Sprintf("%v", m.TickRate)) builder.WriteString(fmt.Sprintf("%v", _m.TickRate))
builder.WriteByte(')') builder.WriteByte(')')
return builder.String() return builder.String()
} }

View File

@@ -758,32 +758,15 @@ func HasPlayersWith(preds ...predicate.Player) predicate.Match {
// And groups predicates with the AND operator between them. // And groups predicates with the AND operator between them.
func And(predicates ...predicate.Match) predicate.Match { func And(predicates ...predicate.Match) predicate.Match {
return predicate.Match(func(s *sql.Selector) { return predicate.Match(sql.AndPredicates(predicates...))
s1 := s.Clone().SetP(nil)
for _, p := range predicates {
p(s1)
}
s.Where(s1.P())
})
} }
// Or groups predicates with the OR operator between them. // Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.Match) predicate.Match { func Or(predicates ...predicate.Match) predicate.Match {
return predicate.Match(func(s *sql.Selector) { return predicate.Match(sql.OrPredicates(predicates...))
s1 := s.Clone().SetP(nil)
for i, p := range predicates {
if i > 0 {
s1.Or()
}
p(s1)
}
s.Where(s1.P())
})
} }
// Not applies the not operator on the given predicate. // Not applies the not operator on the given predicate.
func Not(p predicate.Match) predicate.Match { func Not(p predicate.Match) predicate.Match {
return predicate.Match(func(s *sql.Selector) { return predicate.Match(sql.NotPredicates(p))
p(s.Not())
})
} }

View File

@@ -23,187 +23,187 @@ type MatchCreate struct {
} }
// SetShareCode sets the "share_code" field. // SetShareCode sets the "share_code" field.
func (mc *MatchCreate) SetShareCode(s string) *MatchCreate { func (_c *MatchCreate) SetShareCode(v string) *MatchCreate {
mc.mutation.SetShareCode(s) _c.mutation.SetShareCode(v)
return mc return _c
} }
// SetMap sets the "map" field. // SetMap sets the "map" field.
func (mc *MatchCreate) SetMap(s string) *MatchCreate { func (_c *MatchCreate) SetMap(v string) *MatchCreate {
mc.mutation.SetMap(s) _c.mutation.SetMap(v)
return mc return _c
} }
// SetNillableMap sets the "map" field if the given value is not nil. // SetNillableMap sets the "map" field if the given value is not nil.
func (mc *MatchCreate) SetNillableMap(s *string) *MatchCreate { func (_c *MatchCreate) SetNillableMap(v *string) *MatchCreate {
if s != nil { if v != nil {
mc.SetMap(*s) _c.SetMap(*v)
} }
return mc return _c
} }
// SetDate sets the "date" field. // SetDate sets the "date" field.
func (mc *MatchCreate) SetDate(t time.Time) *MatchCreate { func (_c *MatchCreate) SetDate(v time.Time) *MatchCreate {
mc.mutation.SetDate(t) _c.mutation.SetDate(v)
return mc return _c
} }
// SetScoreTeamA sets the "score_team_a" field. // SetScoreTeamA sets the "score_team_a" field.
func (mc *MatchCreate) SetScoreTeamA(i int) *MatchCreate { func (_c *MatchCreate) SetScoreTeamA(v int) *MatchCreate {
mc.mutation.SetScoreTeamA(i) _c.mutation.SetScoreTeamA(v)
return mc return _c
} }
// SetScoreTeamB sets the "score_team_b" field. // SetScoreTeamB sets the "score_team_b" field.
func (mc *MatchCreate) SetScoreTeamB(i int) *MatchCreate { func (_c *MatchCreate) SetScoreTeamB(v int) *MatchCreate {
mc.mutation.SetScoreTeamB(i) _c.mutation.SetScoreTeamB(v)
return mc return _c
} }
// SetReplayURL sets the "replay_url" field. // SetReplayURL sets the "replay_url" field.
func (mc *MatchCreate) SetReplayURL(s string) *MatchCreate { func (_c *MatchCreate) SetReplayURL(v string) *MatchCreate {
mc.mutation.SetReplayURL(s) _c.mutation.SetReplayURL(v)
return mc return _c
} }
// SetNillableReplayURL sets the "replay_url" field if the given value is not nil. // SetNillableReplayURL sets the "replay_url" field if the given value is not nil.
func (mc *MatchCreate) SetNillableReplayURL(s *string) *MatchCreate { func (_c *MatchCreate) SetNillableReplayURL(v *string) *MatchCreate {
if s != nil { if v != nil {
mc.SetReplayURL(*s) _c.SetReplayURL(*v)
} }
return mc return _c
} }
// SetDuration sets the "duration" field. // SetDuration sets the "duration" field.
func (mc *MatchCreate) SetDuration(i int) *MatchCreate { func (_c *MatchCreate) SetDuration(v int) *MatchCreate {
mc.mutation.SetDuration(i) _c.mutation.SetDuration(v)
return mc return _c
} }
// SetMatchResult sets the "match_result" field. // SetMatchResult sets the "match_result" field.
func (mc *MatchCreate) SetMatchResult(i int) *MatchCreate { func (_c *MatchCreate) SetMatchResult(v int) *MatchCreate {
mc.mutation.SetMatchResult(i) _c.mutation.SetMatchResult(v)
return mc return _c
} }
// SetMaxRounds sets the "max_rounds" field. // SetMaxRounds sets the "max_rounds" field.
func (mc *MatchCreate) SetMaxRounds(i int) *MatchCreate { func (_c *MatchCreate) SetMaxRounds(v int) *MatchCreate {
mc.mutation.SetMaxRounds(i) _c.mutation.SetMaxRounds(v)
return mc return _c
} }
// SetDemoParsed sets the "demo_parsed" field. // SetDemoParsed sets the "demo_parsed" field.
func (mc *MatchCreate) SetDemoParsed(b bool) *MatchCreate { func (_c *MatchCreate) SetDemoParsed(v bool) *MatchCreate {
mc.mutation.SetDemoParsed(b) _c.mutation.SetDemoParsed(v)
return mc return _c
} }
// SetNillableDemoParsed sets the "demo_parsed" field if the given value is not nil. // SetNillableDemoParsed sets the "demo_parsed" field if the given value is not nil.
func (mc *MatchCreate) SetNillableDemoParsed(b *bool) *MatchCreate { func (_c *MatchCreate) SetNillableDemoParsed(v *bool) *MatchCreate {
if b != nil { if v != nil {
mc.SetDemoParsed(*b) _c.SetDemoParsed(*v)
} }
return mc return _c
} }
// SetVacPresent sets the "vac_present" field. // SetVacPresent sets the "vac_present" field.
func (mc *MatchCreate) SetVacPresent(b bool) *MatchCreate { func (_c *MatchCreate) SetVacPresent(v bool) *MatchCreate {
mc.mutation.SetVacPresent(b) _c.mutation.SetVacPresent(v)
return mc return _c
} }
// SetNillableVacPresent sets the "vac_present" field if the given value is not nil. // SetNillableVacPresent sets the "vac_present" field if the given value is not nil.
func (mc *MatchCreate) SetNillableVacPresent(b *bool) *MatchCreate { func (_c *MatchCreate) SetNillableVacPresent(v *bool) *MatchCreate {
if b != nil { if v != nil {
mc.SetVacPresent(*b) _c.SetVacPresent(*v)
} }
return mc return _c
} }
// SetGamebanPresent sets the "gameban_present" field. // SetGamebanPresent sets the "gameban_present" field.
func (mc *MatchCreate) SetGamebanPresent(b bool) *MatchCreate { func (_c *MatchCreate) SetGamebanPresent(v bool) *MatchCreate {
mc.mutation.SetGamebanPresent(b) _c.mutation.SetGamebanPresent(v)
return mc return _c
} }
// SetNillableGamebanPresent sets the "gameban_present" field if the given value is not nil. // SetNillableGamebanPresent sets the "gameban_present" field if the given value is not nil.
func (mc *MatchCreate) SetNillableGamebanPresent(b *bool) *MatchCreate { func (_c *MatchCreate) SetNillableGamebanPresent(v *bool) *MatchCreate {
if b != nil { if v != nil {
mc.SetGamebanPresent(*b) _c.SetGamebanPresent(*v)
} }
return mc return _c
} }
// SetDecryptionKey sets the "decryption_key" field. // SetDecryptionKey sets the "decryption_key" field.
func (mc *MatchCreate) SetDecryptionKey(b []byte) *MatchCreate { func (_c *MatchCreate) SetDecryptionKey(v []byte) *MatchCreate {
mc.mutation.SetDecryptionKey(b) _c.mutation.SetDecryptionKey(v)
return mc return _c
} }
// SetTickRate sets the "tick_rate" field. // SetTickRate sets the "tick_rate" field.
func (mc *MatchCreate) SetTickRate(f float64) *MatchCreate { func (_c *MatchCreate) SetTickRate(v float64) *MatchCreate {
mc.mutation.SetTickRate(f) _c.mutation.SetTickRate(v)
return mc return _c
} }
// SetNillableTickRate sets the "tick_rate" field if the given value is not nil. // SetNillableTickRate sets the "tick_rate" field if the given value is not nil.
func (mc *MatchCreate) SetNillableTickRate(f *float64) *MatchCreate { func (_c *MatchCreate) SetNillableTickRate(v *float64) *MatchCreate {
if f != nil { if v != nil {
mc.SetTickRate(*f) _c.SetTickRate(*v)
} }
return mc return _c
} }
// SetID sets the "id" field. // SetID sets the "id" field.
func (mc *MatchCreate) SetID(u uint64) *MatchCreate { func (_c *MatchCreate) SetID(v uint64) *MatchCreate {
mc.mutation.SetID(u) _c.mutation.SetID(v)
return mc return _c
} }
// AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs. // AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs.
func (mc *MatchCreate) AddStatIDs(ids ...int) *MatchCreate { func (_c *MatchCreate) AddStatIDs(ids ...int) *MatchCreate {
mc.mutation.AddStatIDs(ids...) _c.mutation.AddStatIDs(ids...)
return mc return _c
} }
// AddStats adds the "stats" edges to the MatchPlayer entity. // AddStats adds the "stats" edges to the MatchPlayer entity.
func (mc *MatchCreate) AddStats(m ...*MatchPlayer) *MatchCreate { func (_c *MatchCreate) AddStats(v ...*MatchPlayer) *MatchCreate {
ids := make([]int, len(m)) ids := make([]int, len(v))
for i := range m { for i := range v {
ids[i] = m[i].ID ids[i] = v[i].ID
} }
return mc.AddStatIDs(ids...) return _c.AddStatIDs(ids...)
} }
// AddPlayerIDs adds the "players" edge to the Player entity by IDs. // AddPlayerIDs adds the "players" edge to the Player entity by IDs.
func (mc *MatchCreate) AddPlayerIDs(ids ...uint64) *MatchCreate { func (_c *MatchCreate) AddPlayerIDs(ids ...uint64) *MatchCreate {
mc.mutation.AddPlayerIDs(ids...) _c.mutation.AddPlayerIDs(ids...)
return mc return _c
} }
// AddPlayers adds the "players" edges to the Player entity. // AddPlayers adds the "players" edges to the Player entity.
func (mc *MatchCreate) AddPlayers(p ...*Player) *MatchCreate { func (_c *MatchCreate) AddPlayers(v ...*Player) *MatchCreate {
ids := make([]uint64, len(p)) ids := make([]uint64, len(v))
for i := range p { for i := range v {
ids[i] = p[i].ID ids[i] = v[i].ID
} }
return mc.AddPlayerIDs(ids...) return _c.AddPlayerIDs(ids...)
} }
// Mutation returns the MatchMutation object of the builder. // Mutation returns the MatchMutation object of the builder.
func (mc *MatchCreate) Mutation() *MatchMutation { func (_c *MatchCreate) Mutation() *MatchMutation {
return mc.mutation return _c.mutation
} }
// Save creates the Match in the database. // Save creates the Match in the database.
func (mc *MatchCreate) Save(ctx context.Context) (*Match, error) { func (_c *MatchCreate) Save(ctx context.Context) (*Match, error) {
mc.defaults() _c.defaults()
return withHooks(ctx, mc.sqlSave, mc.mutation, mc.hooks) return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
} }
// SaveX calls Save and panics if Save returns an error. // SaveX calls Save and panics if Save returns an error.
func (mc *MatchCreate) SaveX(ctx context.Context) *Match { func (_c *MatchCreate) SaveX(ctx context.Context) *Match {
v, err := mc.Save(ctx) v, err := _c.Save(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -211,75 +211,75 @@ func (mc *MatchCreate) SaveX(ctx context.Context) *Match {
} }
// Exec executes the query. // Exec executes the query.
func (mc *MatchCreate) Exec(ctx context.Context) error { func (_c *MatchCreate) Exec(ctx context.Context) error {
_, err := mc.Save(ctx) _, err := _c.Save(ctx)
return err return err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (mc *MatchCreate) ExecX(ctx context.Context) { func (_c *MatchCreate) ExecX(ctx context.Context) {
if err := mc.Exec(ctx); err != nil { if err := _c.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }
// defaults sets the default values of the builder before save. // defaults sets the default values of the builder before save.
func (mc *MatchCreate) defaults() { func (_c *MatchCreate) defaults() {
if _, ok := mc.mutation.DemoParsed(); !ok { if _, ok := _c.mutation.DemoParsed(); !ok {
v := match.DefaultDemoParsed 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 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 v := match.DefaultGamebanPresent
mc.mutation.SetGamebanPresent(v) _c.mutation.SetGamebanPresent(v)
} }
} }
// check runs all checks and user-defined validators on the builder. // check runs all checks and user-defined validators on the builder.
func (mc *MatchCreate) check() error { func (_c *MatchCreate) check() error {
if _, ok := mc.mutation.ShareCode(); !ok { if _, ok := _c.mutation.ShareCode(); !ok {
return &ValidationError{Name: "share_code", err: errors.New(`ent: missing required field "Match.share_code"`)} 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"`)} 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"`)} 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"`)} 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"`)} 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"`)} 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"`)} 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"`)} 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"`)} 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 &ValidationError{Name: "gameban_present", err: errors.New(`ent: missing required field "Match.gameban_present"`)}
} }
return nil return nil
} }
func (mc *MatchCreate) sqlSave(ctx context.Context) (*Match, error) { func (_c *MatchCreate) sqlSave(ctx context.Context) (*Match, error) {
if err := mc.check(); err != nil { if err := _c.check(); err != nil {
return nil, err return nil, err
} }
_node, _spec := mc.createSpec() _node, _spec := _c.createSpec()
if err := sqlgraph.CreateNode(ctx, mc.driver, _spec); err != nil { if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) { if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: 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) id := _spec.ID.Value.(int64)
_node.ID = uint64(id) _node.ID = uint64(id)
} }
mc.mutation.id = &_node.ID _c.mutation.id = &_node.ID
mc.mutation.done = true _c.mutation.done = true
return _node, nil return _node, nil
} }
func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) { func (_c *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) {
var ( var (
_node = &Match{config: mc.config} _node = &Match{config: _c.config}
_spec = sqlgraph.NewCreateSpec(match.Table, sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64)) _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 _node.ID = id
_spec.ID.Value = 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) _spec.SetField(match.FieldShareCode, field.TypeString, value)
_node.ShareCode = 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) _spec.SetField(match.FieldMap, field.TypeString, value)
_node.Map = 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) _spec.SetField(match.FieldDate, field.TypeTime, value)
_node.Date = 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) _spec.SetField(match.FieldScoreTeamA, field.TypeInt, value)
_node.ScoreTeamA = 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) _spec.SetField(match.FieldScoreTeamB, field.TypeInt, value)
_node.ScoreTeamB = 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) _spec.SetField(match.FieldReplayURL, field.TypeString, value)
_node.ReplayURL = 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) _spec.SetField(match.FieldDuration, field.TypeInt, value)
_node.Duration = 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) _spec.SetField(match.FieldMatchResult, field.TypeInt, value)
_node.MatchResult = 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) _spec.SetField(match.FieldMaxRounds, field.TypeInt, value)
_node.MaxRounds = 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) _spec.SetField(match.FieldDemoParsed, field.TypeBool, value)
_node.DemoParsed = 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) _spec.SetField(match.FieldVacPresent, field.TypeBool, value)
_node.VacPresent = 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) _spec.SetField(match.FieldGamebanPresent, field.TypeBool, value)
_node.GamebanPresent = 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) _spec.SetField(match.FieldDecryptionKey, field.TypeBytes, value)
_node.DecryptionKey = 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) _spec.SetField(match.FieldTickRate, field.TypeFloat64, value)
_node.TickRate = value _node.TickRate = value
} }
if nodes := mc.mutation.StatsIDs(); len(nodes) > 0 { if nodes := _c.mutation.StatsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{ edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M, Rel: sqlgraph.O2M,
Inverse: false, Inverse: false,
@@ -375,7 +375,7 @@ func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) {
} }
_spec.Edges = append(_spec.Edges, edge) _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{ edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M, Rel: sqlgraph.M2M,
Inverse: true, Inverse: true,
@@ -397,17 +397,21 @@ func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) {
// MatchCreateBulk is the builder for creating many Match entities in bulk. // MatchCreateBulk is the builder for creating many Match entities in bulk.
type MatchCreateBulk struct { type MatchCreateBulk struct {
config config
err error
builders []*MatchCreate builders []*MatchCreate
} }
// Save creates the Match entities in the database. // Save creates the Match entities in the database.
func (mcb *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) { func (_c *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) {
specs := make([]*sqlgraph.CreateSpec, len(mcb.builders)) if _c.err != nil {
nodes := make([]*Match, len(mcb.builders)) return nil, _c.err
mutators := make([]Mutator, len(mcb.builders)) }
for i := range mcb.builders { 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) { func(i int, root context.Context) {
builder := mcb.builders[i] builder := _c.builders[i]
builder.defaults() builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*MatchMutation) mutation, ok := m.(*MatchMutation)
@@ -421,11 +425,11 @@ func (mcb *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) {
var err error var err error
nodes[i], specs[i] = builder.createSpec() nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 { 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 { } else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs} spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain. // 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) { if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
@@ -449,7 +453,7 @@ func (mcb *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) {
}(i, ctx) }(i, ctx)
} }
if len(mutators) > 0 { 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 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. // SaveX is like Save, but panics if an error occurs.
func (mcb *MatchCreateBulk) SaveX(ctx context.Context) []*Match { func (_c *MatchCreateBulk) SaveX(ctx context.Context) []*Match {
v, err := mcb.Save(ctx) v, err := _c.Save(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -466,14 +470,14 @@ func (mcb *MatchCreateBulk) SaveX(ctx context.Context) []*Match {
} }
// Exec executes the query. // Exec executes the query.
func (mcb *MatchCreateBulk) Exec(ctx context.Context) error { func (_c *MatchCreateBulk) Exec(ctx context.Context) error {
_, err := mcb.Save(ctx) _, err := _c.Save(ctx)
return err return err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (mcb *MatchCreateBulk) ExecX(ctx context.Context) { func (_c *MatchCreateBulk) ExecX(ctx context.Context) {
if err := mcb.Exec(ctx); err != nil { if err := _c.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }

View File

@@ -20,56 +20,56 @@ type MatchDelete struct {
} }
// Where appends a list predicates to the MatchDelete builder. // Where appends a list predicates to the MatchDelete builder.
func (md *MatchDelete) Where(ps ...predicate.Match) *MatchDelete { func (_d *MatchDelete) Where(ps ...predicate.Match) *MatchDelete {
md.mutation.Where(ps...) _d.mutation.Where(ps...)
return md return _d
} }
// Exec executes the deletion query and returns how many vertices were deleted. // Exec executes the deletion query and returns how many vertices were deleted.
func (md *MatchDelete) Exec(ctx context.Context) (int, error) { func (_d *MatchDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, md.sqlExec, md.mutation, md.hooks) return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (md *MatchDelete) ExecX(ctx context.Context) int { func (_d *MatchDelete) ExecX(ctx context.Context) int {
n, err := md.Exec(ctx) n, err := _d.Exec(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
return n 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)) _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) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) 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) { if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
md.mutation.done = true _d.mutation.done = true
return affected, err return affected, err
} }
// MatchDeleteOne is the builder for deleting a single Match entity. // MatchDeleteOne is the builder for deleting a single Match entity.
type MatchDeleteOne struct { type MatchDeleteOne struct {
md *MatchDelete _d *MatchDelete
} }
// Where appends a list predicates to the MatchDelete builder. // Where appends a list predicates to the MatchDelete builder.
func (mdo *MatchDeleteOne) Where(ps ...predicate.Match) *MatchDeleteOne { func (_d *MatchDeleteOne) Where(ps ...predicate.Match) *MatchDeleteOne {
mdo.md.mutation.Where(ps...) _d._d.mutation.Where(ps...)
return mdo return _d
} }
// Exec executes the deletion query. // Exec executes the deletion query.
func (mdo *MatchDeleteOne) Exec(ctx context.Context) error { func (_d *MatchDeleteOne) Exec(ctx context.Context) error {
n, err := mdo.md.Exec(ctx) n, err := _d._d.Exec(ctx)
switch { switch {
case err != nil: case err != nil:
return err return err
@@ -81,8 +81,8 @@ func (mdo *MatchDeleteOne) Exec(ctx context.Context) error {
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (mdo *MatchDeleteOne) ExecX(ctx context.Context) { func (_d *MatchDeleteOne) ExecX(ctx context.Context) {
if err := mdo.Exec(ctx); err != nil { if err := _d.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }

View File

@@ -8,6 +8,7 @@ import (
"fmt" "fmt"
"math" "math"
"entgo.io/ent"
"entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field" "entgo.io/ent/schema/field"
@@ -33,44 +34,44 @@ type MatchQuery struct {
} }
// Where adds a new predicate for the MatchQuery builder. // Where adds a new predicate for the MatchQuery builder.
func (mq *MatchQuery) Where(ps ...predicate.Match) *MatchQuery { func (_q *MatchQuery) Where(ps ...predicate.Match) *MatchQuery {
mq.predicates = append(mq.predicates, ps...) _q.predicates = append(_q.predicates, ps...)
return mq return _q
} }
// Limit the number of records to be returned by this query. // Limit the number of records to be returned by this query.
func (mq *MatchQuery) Limit(limit int) *MatchQuery { func (_q *MatchQuery) Limit(limit int) *MatchQuery {
mq.ctx.Limit = &limit _q.ctx.Limit = &limit
return mq return _q
} }
// Offset to start from. // Offset to start from.
func (mq *MatchQuery) Offset(offset int) *MatchQuery { func (_q *MatchQuery) Offset(offset int) *MatchQuery {
mq.ctx.Offset = &offset _q.ctx.Offset = &offset
return mq return _q
} }
// Unique configures the query builder to filter duplicate records on query. // 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. // By default, unique is set to true, and can be disabled using this method.
func (mq *MatchQuery) Unique(unique bool) *MatchQuery { func (_q *MatchQuery) Unique(unique bool) *MatchQuery {
mq.ctx.Unique = &unique _q.ctx.Unique = &unique
return mq return _q
} }
// Order specifies how the records should be ordered. // Order specifies how the records should be ordered.
func (mq *MatchQuery) Order(o ...match.OrderOption) *MatchQuery { func (_q *MatchQuery) Order(o ...match.OrderOption) *MatchQuery {
mq.order = append(mq.order, o...) _q.order = append(_q.order, o...)
return mq return _q
} }
// QueryStats chains the current query on the "stats" edge. // QueryStats chains the current query on the "stats" edge.
func (mq *MatchQuery) QueryStats() *MatchPlayerQuery { func (_q *MatchQuery) QueryStats() *MatchPlayerQuery {
query := (&MatchPlayerClient{config: mq.config}).Query() query := (&MatchPlayerClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { 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 return nil, err
} }
selector := mq.sqlQuery(ctx) selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return nil, err return nil, err
} }
@@ -79,20 +80,20 @@ func (mq *MatchQuery) QueryStats() *MatchPlayerQuery {
sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, match.StatsTable, match.StatsColumn), 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 fromU, nil
} }
return query return query
} }
// QueryPlayers chains the current query on the "players" edge. // QueryPlayers chains the current query on the "players" edge.
func (mq *MatchQuery) QueryPlayers() *PlayerQuery { func (_q *MatchQuery) QueryPlayers() *PlayerQuery {
query := (&PlayerClient{config: mq.config}).Query() query := (&PlayerClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { 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 return nil, err
} }
selector := mq.sqlQuery(ctx) selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return nil, err return nil, err
} }
@@ -101,7 +102,7 @@ func (mq *MatchQuery) QueryPlayers() *PlayerQuery {
sqlgraph.To(player.Table, player.FieldID), sqlgraph.To(player.Table, player.FieldID),
sqlgraph.Edge(sqlgraph.M2M, true, match.PlayersTable, match.PlayersPrimaryKey...), 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 fromU, nil
} }
return query return query
@@ -109,8 +110,8 @@ func (mq *MatchQuery) QueryPlayers() *PlayerQuery {
// First returns the first Match entity from the query. // First returns the first Match entity from the query.
// Returns a *NotFoundError when no Match was found. // Returns a *NotFoundError when no Match was found.
func (mq *MatchQuery) First(ctx context.Context) (*Match, error) { func (_q *MatchQuery) First(ctx context.Context) (*Match, error) {
nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, "First")) nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
if err != nil { if err != nil {
return nil, err 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. // FirstX is like First, but panics if an error occurs.
func (mq *MatchQuery) FirstX(ctx context.Context) *Match { func (_q *MatchQuery) FirstX(ctx context.Context) *Match {
node, err := mq.First(ctx) node, err := _q.First(ctx)
if err != nil && !IsNotFound(err) { if err != nil && !IsNotFound(err) {
panic(err) panic(err)
} }
@@ -131,9 +132,9 @@ func (mq *MatchQuery) FirstX(ctx context.Context) *Match {
// FirstID returns the first Match ID from the query. // FirstID returns the first Match ID from the query.
// Returns a *NotFoundError when no Match ID was found. // 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 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 return
} }
if len(ids) == 0 { 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. // FirstIDX is like FirstID, but panics if an error occurs.
func (mq *MatchQuery) FirstIDX(ctx context.Context) uint64 { func (_q *MatchQuery) FirstIDX(ctx context.Context) uint64 {
id, err := mq.FirstID(ctx) id, err := _q.FirstID(ctx)
if err != nil && !IsNotFound(err) { if err != nil && !IsNotFound(err) {
panic(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. // 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 *NotSingularError when more than one Match entity is found.
// Returns a *NotFoundError when no Match entities are found. // Returns a *NotFoundError when no Match entities are found.
func (mq *MatchQuery) Only(ctx context.Context) (*Match, error) { func (_q *MatchQuery) Only(ctx context.Context) (*Match, error) {
nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, "Only")) nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
if err != nil { if err != nil {
return nil, err 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. // OnlyX is like Only, but panics if an error occurs.
func (mq *MatchQuery) OnlyX(ctx context.Context) *Match { func (_q *MatchQuery) OnlyX(ctx context.Context) *Match {
node, err := mq.Only(ctx) node, err := _q.Only(ctx)
if err != nil { if err != nil {
panic(err) 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. // 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 *NotSingularError when more than one Match ID is found.
// Returns a *NotFoundError when no entities are 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 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 return
} }
switch len(ids) { 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. // OnlyIDX is like OnlyID, but panics if an error occurs.
func (mq *MatchQuery) OnlyIDX(ctx context.Context) uint64 { func (_q *MatchQuery) OnlyIDX(ctx context.Context) uint64 {
id, err := mq.OnlyID(ctx) id, err := _q.OnlyID(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -208,18 +209,18 @@ func (mq *MatchQuery) OnlyIDX(ctx context.Context) uint64 {
} }
// All executes the query and returns a list of Matches. // All executes the query and returns a list of Matches.
func (mq *MatchQuery) All(ctx context.Context) ([]*Match, error) { func (_q *MatchQuery) All(ctx context.Context) ([]*Match, error) {
ctx = setContextOp(ctx, mq.ctx, "All") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
if err := mq.prepareQuery(ctx); err != nil { if err := _q.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
qr := querierAll[[]*Match, *MatchQuery]() 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. // AllX is like All, but panics if an error occurs.
func (mq *MatchQuery) AllX(ctx context.Context) []*Match { func (_q *MatchQuery) AllX(ctx context.Context) []*Match {
nodes, err := mq.All(ctx) nodes, err := _q.All(ctx)
if err != nil { if err != nil {
panic(err) 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. // IDs executes the query and returns a list of Match IDs.
func (mq *MatchQuery) IDs(ctx context.Context) (ids []uint64, err error) { func (_q *MatchQuery) IDs(ctx context.Context) (ids []uint64, err error) {
if mq.ctx.Unique == nil && mq.path != nil { if _q.ctx.Unique == nil && _q.path != nil {
mq.Unique(true) _q.Unique(true)
} }
ctx = setContextOp(ctx, mq.ctx, "IDs") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
if err = mq.Select(match.FieldID).Scan(ctx, &ids); err != nil { if err = _q.Select(match.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
return ids, nil return ids, nil
} }
// IDsX is like IDs, but panics if an error occurs. // IDsX is like IDs, but panics if an error occurs.
func (mq *MatchQuery) IDsX(ctx context.Context) []uint64 { func (_q *MatchQuery) IDsX(ctx context.Context) []uint64 {
ids, err := mq.IDs(ctx) ids, err := _q.IDs(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -248,17 +249,17 @@ func (mq *MatchQuery) IDsX(ctx context.Context) []uint64 {
} }
// Count returns the count of the given query. // Count returns the count of the given query.
func (mq *MatchQuery) Count(ctx context.Context) (int, error) { func (_q *MatchQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, mq.ctx, "Count") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
if err := mq.prepareQuery(ctx); err != nil { if err := _q.prepareQuery(ctx); err != nil {
return 0, err 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. // CountX is like Count, but panics if an error occurs.
func (mq *MatchQuery) CountX(ctx context.Context) int { func (_q *MatchQuery) CountX(ctx context.Context) int {
count, err := mq.Count(ctx) count, err := _q.Count(ctx)
if err != nil { if err != nil {
panic(err) 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. // Exist returns true if the query has elements in the graph.
func (mq *MatchQuery) Exist(ctx context.Context) (bool, error) { func (_q *MatchQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, mq.ctx, "Exist") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
switch _, err := mq.FirstID(ctx); { switch _, err := _q.FirstID(ctx); {
case IsNotFound(err): case IsNotFound(err):
return false, nil return false, nil
case err != 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. // ExistX is like Exist, but panics if an error occurs.
func (mq *MatchQuery) ExistX(ctx context.Context) bool { func (_q *MatchQuery) ExistX(ctx context.Context) bool {
exist, err := mq.Exist(ctx) exist, err := _q.Exist(ctx)
if err != nil { if err != nil {
panic(err) 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 // 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. // used to prepare common query builders and use them differently after the clone is made.
func (mq *MatchQuery) Clone() *MatchQuery { func (_q *MatchQuery) Clone() *MatchQuery {
if mq == nil { if _q == nil {
return nil return nil
} }
return &MatchQuery{ return &MatchQuery{
config: mq.config, config: _q.config,
ctx: mq.ctx.Clone(), ctx: _q.ctx.Clone(),
order: append([]match.OrderOption{}, mq.order...), order: append([]match.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, mq.inters...), inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.Match{}, mq.predicates...), predicates: append([]predicate.Match{}, _q.predicates...),
withStats: mq.withStats.Clone(), withStats: _q.withStats.Clone(),
withPlayers: mq.withPlayers.Clone(), withPlayers: _q.withPlayers.Clone(),
// clone intermediate query. // clone intermediate query.
sql: mq.sql.Clone(), sql: _q.sql.Clone(),
path: mq.path, path: _q.path,
modifiers: append([]func(*sql.Selector){}, _q.modifiers...),
} }
} }
// WithStats tells the query-builder to eager-load the nodes that are connected to // 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. // the "stats" edge. The optional arguments are used to configure the query builder of the edge.
func (mq *MatchQuery) WithStats(opts ...func(*MatchPlayerQuery)) *MatchQuery { func (_q *MatchQuery) WithStats(opts ...func(*MatchPlayerQuery)) *MatchQuery {
query := (&MatchPlayerClient{config: mq.config}).Query() query := (&MatchPlayerClient{config: _q.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
mq.withStats = query _q.withStats = query
return mq return _q
} }
// WithPlayers tells the query-builder to eager-load the nodes that are connected to // 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. // the "players" edge. The optional arguments are used to configure the query builder of the edge.
func (mq *MatchQuery) WithPlayers(opts ...func(*PlayerQuery)) *MatchQuery { func (_q *MatchQuery) WithPlayers(opts ...func(*PlayerQuery)) *MatchQuery {
query := (&PlayerClient{config: mq.config}).Query() query := (&PlayerClient{config: _q.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
mq.withPlayers = query _q.withPlayers = query
return mq return _q
} }
// GroupBy is used to group vertices by one or more fields/columns. // 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). // GroupBy(match.FieldShareCode).
// Aggregate(ent.Count()). // Aggregate(ent.Count()).
// Scan(ctx, &v) // Scan(ctx, &v)
func (mq *MatchQuery) GroupBy(field string, fields ...string) *MatchGroupBy { func (_q *MatchQuery) GroupBy(field string, fields ...string) *MatchGroupBy {
mq.ctx.Fields = append([]string{field}, fields...) _q.ctx.Fields = append([]string{field}, fields...)
grbuild := &MatchGroupBy{build: mq} grbuild := &MatchGroupBy{build: _q}
grbuild.flds = &mq.ctx.Fields grbuild.flds = &_q.ctx.Fields
grbuild.label = match.Label grbuild.label = match.Label
grbuild.scan = grbuild.Scan grbuild.scan = grbuild.Scan
return grbuild return grbuild
@@ -364,84 +366,84 @@ func (mq *MatchQuery) GroupBy(field string, fields ...string) *MatchGroupBy {
// client.Match.Query(). // client.Match.Query().
// Select(match.FieldShareCode). // Select(match.FieldShareCode).
// Scan(ctx, &v) // Scan(ctx, &v)
func (mq *MatchQuery) Select(fields ...string) *MatchSelect { func (_q *MatchQuery) Select(fields ...string) *MatchSelect {
mq.ctx.Fields = append(mq.ctx.Fields, fields...) _q.ctx.Fields = append(_q.ctx.Fields, fields...)
sbuild := &MatchSelect{MatchQuery: mq} sbuild := &MatchSelect{MatchQuery: _q}
sbuild.label = match.Label sbuild.label = match.Label
sbuild.flds, sbuild.scan = &mq.ctx.Fields, sbuild.Scan sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
return sbuild return sbuild
} }
// Aggregate returns a MatchSelect configured with the given aggregations. // Aggregate returns a MatchSelect configured with the given aggregations.
func (mq *MatchQuery) Aggregate(fns ...AggregateFunc) *MatchSelect { func (_q *MatchQuery) Aggregate(fns ...AggregateFunc) *MatchSelect {
return mq.Select().Aggregate(fns...) return _q.Select().Aggregate(fns...)
} }
func (mq *MatchQuery) prepareQuery(ctx context.Context) error { func (_q *MatchQuery) prepareQuery(ctx context.Context) error {
for _, inter := range mq.inters { for _, inter := range _q.inters {
if inter == nil { if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
} }
if trv, ok := inter.(Traverser); ok { if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, mq); err != nil { if err := trv.Traverse(ctx, _q); err != nil {
return err return err
} }
} }
} }
for _, f := range mq.ctx.Fields { for _, f := range _q.ctx.Fields {
if !match.ValidColumn(f) { if !match.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
} }
} }
if mq.path != nil { if _q.path != nil {
prev, err := mq.path(ctx) prev, err := _q.path(ctx)
if err != nil { if err != nil {
return err return err
} }
mq.sql = prev _q.sql = prev
} }
return nil 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 ( var (
nodes = []*Match{} nodes = []*Match{}
_spec = mq.querySpec() _spec = _q.querySpec()
loadedTypes = [2]bool{ loadedTypes = [2]bool{
mq.withStats != nil, _q.withStats != nil,
mq.withPlayers != nil, _q.withPlayers != nil,
} }
) )
_spec.ScanValues = func(columns []string) ([]any, error) { _spec.ScanValues = func(columns []string) ([]any, error) {
return (*Match).scanValues(nil, columns) return (*Match).scanValues(nil, columns)
} }
_spec.Assign = func(columns []string, values []any) error { _spec.Assign = func(columns []string, values []any) error {
node := &Match{config: mq.config} node := &Match{config: _q.config}
nodes = append(nodes, node) nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values) return node.assignValues(columns, values)
} }
if len(mq.modifiers) > 0 { if len(_q.modifiers) > 0 {
_spec.Modifiers = mq.modifiers _spec.Modifiers = _q.modifiers
} }
for i := range hooks { for i := range hooks {
hooks[i](ctx, _spec) 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 return nil, err
} }
if len(nodes) == 0 { if len(nodes) == 0 {
return nodes, nil return nodes, nil
} }
if query := mq.withStats; query != nil { if query := _q.withStats; query != nil {
if err := mq.loadStats(ctx, query, nodes, if err := _q.loadStats(ctx, query, nodes,
func(n *Match) { n.Edges.Stats = []*MatchPlayer{} }, func(n *Match) { n.Edges.Stats = []*MatchPlayer{} },
func(n *Match, e *MatchPlayer) { n.Edges.Stats = append(n.Edges.Stats, e) }); err != nil { func(n *Match, e *MatchPlayer) { n.Edges.Stats = append(n.Edges.Stats, e) }); err != nil {
return nil, err return nil, err
} }
} }
if query := mq.withPlayers; query != nil { if query := _q.withPlayers; query != nil {
if err := mq.loadPlayers(ctx, query, nodes, if err := _q.loadPlayers(ctx, query, nodes,
func(n *Match) { n.Edges.Players = []*Player{} }, func(n *Match) { n.Edges.Players = []*Player{} },
func(n *Match, e *Player) { n.Edges.Players = append(n.Edges.Players, e) }); err != nil { func(n *Match, e *Player) { n.Edges.Players = append(n.Edges.Players, e) }); err != nil {
return nil, err return nil, err
@@ -450,7 +452,7 @@ func (mq *MatchQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Match,
return nodes, nil 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)) fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[uint64]*Match) nodeids := make(map[uint64]*Match)
for i := range nodes { for i := range nodes {
@@ -480,7 +482,7 @@ func (mq *MatchQuery) loadStats(ctx context.Context, query *MatchPlayerQuery, no
} }
return nil 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)) edgeIDs := make([]driver.Value, len(nodes))
byID := make(map[uint64]*Match) byID := make(map[uint64]*Match)
nids := make(map[uint64]map[*Match]struct{}) nids := make(map[uint64]map[*Match]struct{})
@@ -542,27 +544,27 @@ func (mq *MatchQuery) loadPlayers(ctx context.Context, query *PlayerQuery, nodes
return nil return nil
} }
func (mq *MatchQuery) sqlCount(ctx context.Context) (int, error) { func (_q *MatchQuery) sqlCount(ctx context.Context) (int, error) {
_spec := mq.querySpec() _spec := _q.querySpec()
if len(mq.modifiers) > 0 { if len(_q.modifiers) > 0 {
_spec.Modifiers = mq.modifiers _spec.Modifiers = _q.modifiers
} }
_spec.Node.Columns = mq.ctx.Fields _spec.Node.Columns = _q.ctx.Fields
if len(mq.ctx.Fields) > 0 { if len(_q.ctx.Fields) > 0 {
_spec.Unique = mq.ctx.Unique != nil && *mq.ctx.Unique _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 := sqlgraph.NewQuerySpec(match.Table, match.Columns, sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64))
_spec.From = mq.sql _spec.From = _q.sql
if unique := mq.ctx.Unique; unique != nil { if unique := _q.ctx.Unique; unique != nil {
_spec.Unique = *unique _spec.Unique = *unique
} else if mq.path != nil { } else if _q.path != nil {
_spec.Unique = true _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 = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, match.FieldID) _spec.Node.Columns = append(_spec.Node.Columns, match.FieldID)
for i := range fields { 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) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) ps[i](selector)
} }
} }
} }
if limit := mq.ctx.Limit; limit != nil { if limit := _q.ctx.Limit; limit != nil {
_spec.Limit = *limit _spec.Limit = *limit
} }
if offset := mq.ctx.Offset; offset != nil { if offset := _q.ctx.Offset; offset != nil {
_spec.Offset = *offset _spec.Offset = *offset
} }
if ps := mq.order; len(ps) > 0 { if ps := _q.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) { _spec.Order = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) ps[i](selector)
@@ -594,45 +596,45 @@ func (mq *MatchQuery) querySpec() *sqlgraph.QuerySpec {
return _spec return _spec
} }
func (mq *MatchQuery) sqlQuery(ctx context.Context) *sql.Selector { func (_q *MatchQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(mq.driver.Dialect()) builder := sql.Dialect(_q.driver.Dialect())
t1 := builder.Table(match.Table) t1 := builder.Table(match.Table)
columns := mq.ctx.Fields columns := _q.ctx.Fields
if len(columns) == 0 { if len(columns) == 0 {
columns = match.Columns columns = match.Columns
} }
selector := builder.Select(t1.Columns(columns...)...).From(t1) selector := builder.Select(t1.Columns(columns...)...).From(t1)
if mq.sql != nil { if _q.sql != nil {
selector = mq.sql selector = _q.sql
selector.Select(selector.Columns(columns...)...) selector.Select(selector.Columns(columns...)...)
} }
if mq.ctx.Unique != nil && *mq.ctx.Unique { if _q.ctx.Unique != nil && *_q.ctx.Unique {
selector.Distinct() selector.Distinct()
} }
for _, m := range mq.modifiers { for _, m := range _q.modifiers {
m(selector) m(selector)
} }
for _, p := range mq.predicates { for _, p := range _q.predicates {
p(selector) p(selector)
} }
for _, p := range mq.order { for _, p := range _q.order {
p(selector) p(selector)
} }
if offset := mq.ctx.Offset; offset != nil { if offset := _q.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start // limit is mandatory for offset clause. We start
// with default value, and override it below if needed. // with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32) selector.Offset(*offset).Limit(math.MaxInt32)
} }
if limit := mq.ctx.Limit; limit != nil { if limit := _q.ctx.Limit; limit != nil {
selector.Limit(*limit) selector.Limit(*limit)
} }
return selector return selector
} }
// Modify adds a query modifier for attaching custom logic to queries. // Modify adds a query modifier for attaching custom logic to queries.
func (mq *MatchQuery) Modify(modifiers ...func(s *sql.Selector)) *MatchSelect { func (_q *MatchQuery) Modify(modifiers ...func(s *sql.Selector)) *MatchSelect {
mq.modifiers = append(mq.modifiers, modifiers...) _q.modifiers = append(_q.modifiers, modifiers...)
return mq.Select() return _q.Select()
} }
// MatchGroupBy is the group-by builder for Match entities. // 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. // Aggregate adds the given aggregation functions to the group-by query.
func (mgb *MatchGroupBy) Aggregate(fns ...AggregateFunc) *MatchGroupBy { func (_g *MatchGroupBy) Aggregate(fns ...AggregateFunc) *MatchGroupBy {
mgb.fns = append(mgb.fns, fns...) _g.fns = append(_g.fns, fns...)
return mgb return _g
} }
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (mgb *MatchGroupBy) Scan(ctx context.Context, v any) error { func (_g *MatchGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, mgb.build.ctx, "GroupBy") ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
if err := mgb.build.prepareQuery(ctx); err != nil { if err := _g.build.prepareQuery(ctx); err != nil {
return err 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() selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(mgb.fns)) aggregation := make([]string, 0, len(_g.fns))
for _, fn := range mgb.fns { for _, fn := range _g.fns {
aggregation = append(aggregation, fn(selector)) aggregation = append(aggregation, fn(selector))
} }
if len(selector.SelectedColumns()) == 0 { if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*mgb.flds)+len(mgb.fns)) columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
for _, f := range *mgb.flds { for _, f := range *_g.flds {
columns = append(columns, selector.C(f)) columns = append(columns, selector.C(f))
} }
columns = append(columns, aggregation...) columns = append(columns, aggregation...)
selector.Select(columns...) selector.Select(columns...)
} }
selector.GroupBy(selector.Columns(*mgb.flds...)...) selector.GroupBy(selector.Columns(*_g.flds...)...)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return err return err
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := selector.Query() 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 return err
} }
defer rows.Close() defer rows.Close()
@@ -690,27 +692,27 @@ type MatchSelect struct {
} }
// Aggregate adds the given aggregation functions to the selector query. // Aggregate adds the given aggregation functions to the selector query.
func (ms *MatchSelect) Aggregate(fns ...AggregateFunc) *MatchSelect { func (_s *MatchSelect) Aggregate(fns ...AggregateFunc) *MatchSelect {
ms.fns = append(ms.fns, fns...) _s.fns = append(_s.fns, fns...)
return ms return _s
} }
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (ms *MatchSelect) Scan(ctx context.Context, v any) error { func (_s *MatchSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, ms.ctx, "Select") ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
if err := ms.prepareQuery(ctx); err != nil { if err := _s.prepareQuery(ctx); err != nil {
return err 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) selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(ms.fns)) aggregation := make([]string, 0, len(_s.fns))
for _, fn := range ms.fns { for _, fn := range _s.fns {
aggregation = append(aggregation, fn(selector)) aggregation = append(aggregation, fn(selector))
} }
switch n := len(*ms.selector.flds); { switch n := len(*_s.selector.flds); {
case n == 0 && len(aggregation) > 0: case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...) selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0: 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{} rows := &sql.Rows{}
query, args := selector.Query() 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 return err
} }
defer rows.Close() 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. // Modify adds a query modifier for attaching custom logic to queries.
func (ms *MatchSelect) Modify(modifiers ...func(s *sql.Selector)) *MatchSelect { func (_s *MatchSelect) Modify(modifiers ...func(s *sql.Selector)) *MatchSelect {
ms.modifiers = append(ms.modifiers, modifiers...) _s.modifiers = append(_s.modifiers, modifiers...)
return ms return _s
} }

File diff suppressed because it is too large Load Diff

View File

@@ -112,12 +112,10 @@ type MatchPlayerEdges struct {
// MatchesOrErr returns the Matches value or an error if the edge // MatchesOrErr returns the Matches value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found. // was not loaded in eager-loading, or loaded but was not found.
func (e MatchPlayerEdges) MatchesOrErr() (*Match, error) { func (e MatchPlayerEdges) MatchesOrErr() (*Match, error) {
if e.loadedTypes[0] { if e.Matches != nil {
if e.Matches == nil {
// Edge was loaded but was not found.
return nil, &NotFoundError{label: match.Label}
}
return e.Matches, nil return e.Matches, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: match.Label}
} }
return nil, &NotLoadedError{edge: "matches"} 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 // PlayersOrErr returns the Players value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found. // was not loaded in eager-loading, or loaded but was not found.
func (e MatchPlayerEdges) PlayersOrErr() (*Player, error) { func (e MatchPlayerEdges) PlayersOrErr() (*Player, error) {
if e.loadedTypes[1] { if e.Players != nil {
if e.Players == nil {
// Edge was loaded but was not found.
return nil, &NotFoundError{label: player.Label}
}
return e.Players, nil return e.Players, nil
} else if e.loadedTypes[1] {
return nil, &NotFoundError{label: player.Label}
} }
return nil, &NotLoadedError{edge: "players"} 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) // assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the MatchPlayer fields. // 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 { if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", 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 { if !ok {
return fmt.Errorf("unexpected type %T for field id", value) return fmt.Errorf("unexpected type %T for field id", value)
} }
mp.ID = int(value.Int64) _m.ID = int(value.Int64)
case matchplayer.FieldTeamID: case matchplayer.FieldTeamID:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field team_id", values[i]) return fmt.Errorf("unexpected type %T for field team_id", values[i])
} else if value.Valid { } else if value.Valid {
mp.TeamID = int(value.Int64) _m.TeamID = int(value.Int64)
} }
case matchplayer.FieldKills: case matchplayer.FieldKills:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field kills", values[i]) return fmt.Errorf("unexpected type %T for field kills", values[i])
} else if value.Valid { } else if value.Valid {
mp.Kills = int(value.Int64) _m.Kills = int(value.Int64)
} }
case matchplayer.FieldDeaths: case matchplayer.FieldDeaths:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field deaths", values[i]) return fmt.Errorf("unexpected type %T for field deaths", values[i])
} else if value.Valid { } else if value.Valid {
mp.Deaths = int(value.Int64) _m.Deaths = int(value.Int64)
} }
case matchplayer.FieldAssists: case matchplayer.FieldAssists:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field assists", values[i]) return fmt.Errorf("unexpected type %T for field assists", values[i])
} else if value.Valid { } else if value.Valid {
mp.Assists = int(value.Int64) _m.Assists = int(value.Int64)
} }
case matchplayer.FieldHeadshot: case matchplayer.FieldHeadshot:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field headshot", values[i]) return fmt.Errorf("unexpected type %T for field headshot", values[i])
} else if value.Valid { } else if value.Valid {
mp.Headshot = int(value.Int64) _m.Headshot = int(value.Int64)
} }
case matchplayer.FieldMvp: case matchplayer.FieldMvp:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field mvp", values[i]) return fmt.Errorf("unexpected type %T for field mvp", values[i])
} else if value.Valid { } else if value.Valid {
mp.Mvp = uint(value.Int64) _m.Mvp = uint(value.Int64)
} }
case matchplayer.FieldScore: case matchplayer.FieldScore:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field score", values[i]) return fmt.Errorf("unexpected type %T for field score", values[i])
} else if value.Valid { } else if value.Valid {
mp.Score = int(value.Int64) _m.Score = int(value.Int64)
} }
case matchplayer.FieldRankNew: case matchplayer.FieldRankNew:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field rank_new", values[i]) return fmt.Errorf("unexpected type %T for field rank_new", values[i])
} else if value.Valid { } else if value.Valid {
mp.RankNew = int(value.Int64) _m.RankNew = int(value.Int64)
} }
case matchplayer.FieldRankOld: case matchplayer.FieldRankOld:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field rank_old", values[i]) return fmt.Errorf("unexpected type %T for field rank_old", values[i])
} else if value.Valid { } else if value.Valid {
mp.RankOld = int(value.Int64) _m.RankOld = int(value.Int64)
} }
case matchplayer.FieldMk2: case matchplayer.FieldMk2:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field mk_2", values[i]) return fmt.Errorf("unexpected type %T for field mk_2", values[i])
} else if value.Valid { } else if value.Valid {
mp.Mk2 = uint(value.Int64) _m.Mk2 = uint(value.Int64)
} }
case matchplayer.FieldMk3: case matchplayer.FieldMk3:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field mk_3", values[i]) return fmt.Errorf("unexpected type %T for field mk_3", values[i])
} else if value.Valid { } else if value.Valid {
mp.Mk3 = uint(value.Int64) _m.Mk3 = uint(value.Int64)
} }
case matchplayer.FieldMk4: case matchplayer.FieldMk4:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field mk_4", values[i]) return fmt.Errorf("unexpected type %T for field mk_4", values[i])
} else if value.Valid { } else if value.Valid {
mp.Mk4 = uint(value.Int64) _m.Mk4 = uint(value.Int64)
} }
case matchplayer.FieldMk5: case matchplayer.FieldMk5:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field mk_5", values[i]) return fmt.Errorf("unexpected type %T for field mk_5", values[i])
} else if value.Valid { } else if value.Valid {
mp.Mk5 = uint(value.Int64) _m.Mk5 = uint(value.Int64)
} }
case matchplayer.FieldDmgEnemy: case matchplayer.FieldDmgEnemy:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field dmg_enemy", values[i]) return fmt.Errorf("unexpected type %T for field dmg_enemy", values[i])
} else if value.Valid { } else if value.Valid {
mp.DmgEnemy = uint(value.Int64) _m.DmgEnemy = uint(value.Int64)
} }
case matchplayer.FieldDmgTeam: case matchplayer.FieldDmgTeam:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field dmg_team", values[i]) return fmt.Errorf("unexpected type %T for field dmg_team", values[i])
} else if value.Valid { } else if value.Valid {
mp.DmgTeam = uint(value.Int64) _m.DmgTeam = uint(value.Int64)
} }
case matchplayer.FieldUdHe: case matchplayer.FieldUdHe:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field ud_he", values[i]) return fmt.Errorf("unexpected type %T for field ud_he", values[i])
} else if value.Valid { } else if value.Valid {
mp.UdHe = uint(value.Int64) _m.UdHe = uint(value.Int64)
} }
case matchplayer.FieldUdFlames: case matchplayer.FieldUdFlames:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field ud_flames", values[i]) return fmt.Errorf("unexpected type %T for field ud_flames", values[i])
} else if value.Valid { } else if value.Valid {
mp.UdFlames = uint(value.Int64) _m.UdFlames = uint(value.Int64)
} }
case matchplayer.FieldUdFlash: case matchplayer.FieldUdFlash:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field ud_flash", values[i]) return fmt.Errorf("unexpected type %T for field ud_flash", values[i])
} else if value.Valid { } else if value.Valid {
mp.UdFlash = uint(value.Int64) _m.UdFlash = uint(value.Int64)
} }
case matchplayer.FieldUdDecoy: case matchplayer.FieldUdDecoy:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field ud_decoy", values[i]) return fmt.Errorf("unexpected type %T for field ud_decoy", values[i])
} else if value.Valid { } else if value.Valid {
mp.UdDecoy = uint(value.Int64) _m.UdDecoy = uint(value.Int64)
} }
case matchplayer.FieldUdSmoke: case matchplayer.FieldUdSmoke:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field ud_smoke", values[i]) return fmt.Errorf("unexpected type %T for field ud_smoke", values[i])
} else if value.Valid { } else if value.Valid {
mp.UdSmoke = uint(value.Int64) _m.UdSmoke = uint(value.Int64)
} }
case matchplayer.FieldCrosshair: case matchplayer.FieldCrosshair:
if value, ok := values[i].(*sql.NullString); !ok { if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field crosshair", values[i]) return fmt.Errorf("unexpected type %T for field crosshair", values[i])
} else if value.Valid { } else if value.Valid {
mp.Crosshair = value.String _m.Crosshair = value.String
} }
case matchplayer.FieldColor: case matchplayer.FieldColor:
if value, ok := values[i].(*sql.NullString); !ok { if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field color", values[i]) return fmt.Errorf("unexpected type %T for field color", values[i])
} else if value.Valid { } else if value.Valid {
mp.Color = matchplayer.Color(value.String) _m.Color = matchplayer.Color(value.String)
} }
case matchplayer.FieldKast: case matchplayer.FieldKast:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field kast", values[i]) return fmt.Errorf("unexpected type %T for field kast", values[i])
} else if value.Valid { } else if value.Valid {
mp.Kast = int(value.Int64) _m.Kast = int(value.Int64)
} }
case matchplayer.FieldFlashDurationSelf: case matchplayer.FieldFlashDurationSelf:
if value, ok := values[i].(*sql.NullFloat64); !ok { if value, ok := values[i].(*sql.NullFloat64); !ok {
return fmt.Errorf("unexpected type %T for field flash_duration_self", values[i]) return fmt.Errorf("unexpected type %T for field flash_duration_self", values[i])
} else if value.Valid { } else if value.Valid {
mp.FlashDurationSelf = float32(value.Float64) _m.FlashDurationSelf = float32(value.Float64)
} }
case matchplayer.FieldFlashDurationTeam: case matchplayer.FieldFlashDurationTeam:
if value, ok := values[i].(*sql.NullFloat64); !ok { if value, ok := values[i].(*sql.NullFloat64); !ok {
return fmt.Errorf("unexpected type %T for field flash_duration_team", values[i]) return fmt.Errorf("unexpected type %T for field flash_duration_team", values[i])
} else if value.Valid { } else if value.Valid {
mp.FlashDurationTeam = float32(value.Float64) _m.FlashDurationTeam = float32(value.Float64)
} }
case matchplayer.FieldFlashDurationEnemy: case matchplayer.FieldFlashDurationEnemy:
if value, ok := values[i].(*sql.NullFloat64); !ok { if value, ok := values[i].(*sql.NullFloat64); !ok {
return fmt.Errorf("unexpected type %T for field flash_duration_enemy", values[i]) return fmt.Errorf("unexpected type %T for field flash_duration_enemy", values[i])
} else if value.Valid { } else if value.Valid {
mp.FlashDurationEnemy = float32(value.Float64) _m.FlashDurationEnemy = float32(value.Float64)
} }
case matchplayer.FieldFlashTotalSelf: case matchplayer.FieldFlashTotalSelf:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field flash_total_self", values[i]) return fmt.Errorf("unexpected type %T for field flash_total_self", values[i])
} else if value.Valid { } else if value.Valid {
mp.FlashTotalSelf = uint(value.Int64) _m.FlashTotalSelf = uint(value.Int64)
} }
case matchplayer.FieldFlashTotalTeam: case matchplayer.FieldFlashTotalTeam:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field flash_total_team", values[i]) return fmt.Errorf("unexpected type %T for field flash_total_team", values[i])
} else if value.Valid { } else if value.Valid {
mp.FlashTotalTeam = uint(value.Int64) _m.FlashTotalTeam = uint(value.Int64)
} }
case matchplayer.FieldFlashTotalEnemy: case matchplayer.FieldFlashTotalEnemy:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field flash_total_enemy", values[i]) return fmt.Errorf("unexpected type %T for field flash_total_enemy", values[i])
} else if value.Valid { } else if value.Valid {
mp.FlashTotalEnemy = uint(value.Int64) _m.FlashTotalEnemy = uint(value.Int64)
} }
case matchplayer.FieldMatchStats: case matchplayer.FieldMatchStats:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field match_stats", values[i]) return fmt.Errorf("unexpected type %T for field match_stats", values[i])
} else if value.Valid { } else if value.Valid {
mp.MatchStats = uint64(value.Int64) _m.MatchStats = uint64(value.Int64)
} }
case matchplayer.FieldPlayerStats: case matchplayer.FieldPlayerStats:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field player_stats", values[i]) return fmt.Errorf("unexpected type %T for field player_stats", values[i])
} else if value.Valid { } else if value.Valid {
mp.PlayerStats = uint64(value.Int64) _m.PlayerStats = uint64(value.Int64)
} }
case matchplayer.FieldFlashAssists: case matchplayer.FieldFlashAssists:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field flash_assists", values[i]) return fmt.Errorf("unexpected type %T for field flash_assists", values[i])
} else if value.Valid { } else if value.Valid {
mp.FlashAssists = int(value.Int64) _m.FlashAssists = int(value.Int64)
} }
case matchplayer.FieldAvgPing: case matchplayer.FieldAvgPing:
if value, ok := values[i].(*sql.NullFloat64); !ok { if value, ok := values[i].(*sql.NullFloat64); !ok {
return fmt.Errorf("unexpected type %T for field avg_ping", values[i]) return fmt.Errorf("unexpected type %T for field avg_ping", values[i])
} else if value.Valid { } else if value.Valid {
mp.AvgPing = value.Float64 _m.AvgPing = value.Float64
} }
default: default:
mp.selectValues.Set(columns[i], values[i]) _m.selectValues.Set(columns[i], values[i])
} }
} }
return nil 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. // Value returns the ent.Value that was dynamically selected and assigned to the MatchPlayer.
// This includes values selected through modifiers, order, etc. // This includes values selected through modifiers, order, etc.
func (mp *MatchPlayer) Value(name string) (ent.Value, error) { func (_m *MatchPlayer) Value(name string) (ent.Value, error) {
return mp.selectValues.Get(name) return _m.selectValues.Get(name)
} }
// QueryMatches queries the "matches" edge of the MatchPlayer entity. // QueryMatches queries the "matches" edge of the MatchPlayer entity.
func (mp *MatchPlayer) QueryMatches() *MatchQuery { func (_m *MatchPlayer) QueryMatches() *MatchQuery {
return NewMatchPlayerClient(mp.config).QueryMatches(mp) return NewMatchPlayerClient(_m.config).QueryMatches(_m)
} }
// QueryPlayers queries the "players" edge of the MatchPlayer entity. // QueryPlayers queries the "players" edge of the MatchPlayer entity.
func (mp *MatchPlayer) QueryPlayers() *PlayerQuery { func (_m *MatchPlayer) QueryPlayers() *PlayerQuery {
return NewMatchPlayerClient(mp.config).QueryPlayers(mp) return NewMatchPlayerClient(_m.config).QueryPlayers(_m)
} }
// QueryWeaponStats queries the "weapon_stats" edge of the MatchPlayer entity. // QueryWeaponStats queries the "weapon_stats" edge of the MatchPlayer entity.
func (mp *MatchPlayer) QueryWeaponStats() *WeaponQuery { func (_m *MatchPlayer) QueryWeaponStats() *WeaponQuery {
return NewMatchPlayerClient(mp.config).QueryWeaponStats(mp) return NewMatchPlayerClient(_m.config).QueryWeaponStats(_m)
} }
// QueryRoundStats queries the "round_stats" edge of the MatchPlayer entity. // QueryRoundStats queries the "round_stats" edge of the MatchPlayer entity.
func (mp *MatchPlayer) QueryRoundStats() *RoundStatsQuery { func (_m *MatchPlayer) QueryRoundStats() *RoundStatsQuery {
return NewMatchPlayerClient(mp.config).QueryRoundStats(mp) return NewMatchPlayerClient(_m.config).QueryRoundStats(_m)
} }
// QuerySpray queries the "spray" edge of the MatchPlayer entity. // QuerySpray queries the "spray" edge of the MatchPlayer entity.
func (mp *MatchPlayer) QuerySpray() *SprayQuery { func (_m *MatchPlayer) QuerySpray() *SprayQuery {
return NewMatchPlayerClient(mp.config).QuerySpray(mp) return NewMatchPlayerClient(_m.config).QuerySpray(_m)
} }
// QueryMessages queries the "messages" edge of the MatchPlayer entity. // QueryMessages queries the "messages" edge of the MatchPlayer entity.
func (mp *MatchPlayer) QueryMessages() *MessagesQuery { func (_m *MatchPlayer) QueryMessages() *MessagesQuery {
return NewMatchPlayerClient(mp.config).QueryMessages(mp) return NewMatchPlayerClient(_m.config).QueryMessages(_m)
} }
// Update returns a builder for updating this MatchPlayer. // Update returns a builder for updating this MatchPlayer.
// Note that you need to call MatchPlayer.Unwrap() before calling this method if 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. // was returned from a transaction, and the transaction was committed or rolled back.
func (mp *MatchPlayer) Update() *MatchPlayerUpdateOne { func (_m *MatchPlayer) Update() *MatchPlayerUpdateOne {
return NewMatchPlayerClient(mp.config).UpdateOne(mp) return NewMatchPlayerClient(_m.config).UpdateOne(_m)
} }
// Unwrap unwraps the MatchPlayer entity that was returned from a transaction after it was closed, // 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. // so that all future queries will be executed through the driver which created the transaction.
func (mp *MatchPlayer) Unwrap() *MatchPlayer { func (_m *MatchPlayer) Unwrap() *MatchPlayer {
_tx, ok := mp.config.driver.(*txDriver) _tx, ok := _m.config.driver.(*txDriver)
if !ok { if !ok {
panic("ent: MatchPlayer is not a transactional entity") panic("ent: MatchPlayer is not a transactional entity")
} }
mp.config.driver = _tx.drv _m.config.driver = _tx.drv
return mp return _m
} }
// String implements the fmt.Stringer. // String implements the fmt.Stringer.
func (mp *MatchPlayer) String() string { func (_m *MatchPlayer) String() string {
var builder strings.Builder var builder strings.Builder
builder.WriteString("MatchPlayer(") 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("team_id=")
builder.WriteString(fmt.Sprintf("%v", mp.TeamID)) builder.WriteString(fmt.Sprintf("%v", _m.TeamID))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("kills=") builder.WriteString("kills=")
builder.WriteString(fmt.Sprintf("%v", mp.Kills)) builder.WriteString(fmt.Sprintf("%v", _m.Kills))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("deaths=") builder.WriteString("deaths=")
builder.WriteString(fmt.Sprintf("%v", mp.Deaths)) builder.WriteString(fmt.Sprintf("%v", _m.Deaths))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("assists=") builder.WriteString("assists=")
builder.WriteString(fmt.Sprintf("%v", mp.Assists)) builder.WriteString(fmt.Sprintf("%v", _m.Assists))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("headshot=") builder.WriteString("headshot=")
builder.WriteString(fmt.Sprintf("%v", mp.Headshot)) builder.WriteString(fmt.Sprintf("%v", _m.Headshot))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("mvp=") builder.WriteString("mvp=")
builder.WriteString(fmt.Sprintf("%v", mp.Mvp)) builder.WriteString(fmt.Sprintf("%v", _m.Mvp))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("score=") builder.WriteString("score=")
builder.WriteString(fmt.Sprintf("%v", mp.Score)) builder.WriteString(fmt.Sprintf("%v", _m.Score))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("rank_new=") builder.WriteString("rank_new=")
builder.WriteString(fmt.Sprintf("%v", mp.RankNew)) builder.WriteString(fmt.Sprintf("%v", _m.RankNew))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("rank_old=") builder.WriteString("rank_old=")
builder.WriteString(fmt.Sprintf("%v", mp.RankOld)) builder.WriteString(fmt.Sprintf("%v", _m.RankOld))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("mk_2=") builder.WriteString("mk_2=")
builder.WriteString(fmt.Sprintf("%v", mp.Mk2)) builder.WriteString(fmt.Sprintf("%v", _m.Mk2))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("mk_3=") builder.WriteString("mk_3=")
builder.WriteString(fmt.Sprintf("%v", mp.Mk3)) builder.WriteString(fmt.Sprintf("%v", _m.Mk3))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("mk_4=") builder.WriteString("mk_4=")
builder.WriteString(fmt.Sprintf("%v", mp.Mk4)) builder.WriteString(fmt.Sprintf("%v", _m.Mk4))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("mk_5=") builder.WriteString("mk_5=")
builder.WriteString(fmt.Sprintf("%v", mp.Mk5)) builder.WriteString(fmt.Sprintf("%v", _m.Mk5))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("dmg_enemy=") builder.WriteString("dmg_enemy=")
builder.WriteString(fmt.Sprintf("%v", mp.DmgEnemy)) builder.WriteString(fmt.Sprintf("%v", _m.DmgEnemy))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("dmg_team=") builder.WriteString("dmg_team=")
builder.WriteString(fmt.Sprintf("%v", mp.DmgTeam)) builder.WriteString(fmt.Sprintf("%v", _m.DmgTeam))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("ud_he=") builder.WriteString("ud_he=")
builder.WriteString(fmt.Sprintf("%v", mp.UdHe)) builder.WriteString(fmt.Sprintf("%v", _m.UdHe))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("ud_flames=") builder.WriteString("ud_flames=")
builder.WriteString(fmt.Sprintf("%v", mp.UdFlames)) builder.WriteString(fmt.Sprintf("%v", _m.UdFlames))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("ud_flash=") builder.WriteString("ud_flash=")
builder.WriteString(fmt.Sprintf("%v", mp.UdFlash)) builder.WriteString(fmt.Sprintf("%v", _m.UdFlash))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("ud_decoy=") builder.WriteString("ud_decoy=")
builder.WriteString(fmt.Sprintf("%v", mp.UdDecoy)) builder.WriteString(fmt.Sprintf("%v", _m.UdDecoy))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("ud_smoke=") builder.WriteString("ud_smoke=")
builder.WriteString(fmt.Sprintf("%v", mp.UdSmoke)) builder.WriteString(fmt.Sprintf("%v", _m.UdSmoke))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("crosshair=") builder.WriteString("crosshair=")
builder.WriteString(mp.Crosshair) builder.WriteString(_m.Crosshair)
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("color=") builder.WriteString("color=")
builder.WriteString(fmt.Sprintf("%v", mp.Color)) builder.WriteString(fmt.Sprintf("%v", _m.Color))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("kast=") builder.WriteString("kast=")
builder.WriteString(fmt.Sprintf("%v", mp.Kast)) builder.WriteString(fmt.Sprintf("%v", _m.Kast))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("flash_duration_self=") builder.WriteString("flash_duration_self=")
builder.WriteString(fmt.Sprintf("%v", mp.FlashDurationSelf)) builder.WriteString(fmt.Sprintf("%v", _m.FlashDurationSelf))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("flash_duration_team=") builder.WriteString("flash_duration_team=")
builder.WriteString(fmt.Sprintf("%v", mp.FlashDurationTeam)) builder.WriteString(fmt.Sprintf("%v", _m.FlashDurationTeam))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("flash_duration_enemy=") builder.WriteString("flash_duration_enemy=")
builder.WriteString(fmt.Sprintf("%v", mp.FlashDurationEnemy)) builder.WriteString(fmt.Sprintf("%v", _m.FlashDurationEnemy))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("flash_total_self=") builder.WriteString("flash_total_self=")
builder.WriteString(fmt.Sprintf("%v", mp.FlashTotalSelf)) builder.WriteString(fmt.Sprintf("%v", _m.FlashTotalSelf))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("flash_total_team=") builder.WriteString("flash_total_team=")
builder.WriteString(fmt.Sprintf("%v", mp.FlashTotalTeam)) builder.WriteString(fmt.Sprintf("%v", _m.FlashTotalTeam))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("flash_total_enemy=") builder.WriteString("flash_total_enemy=")
builder.WriteString(fmt.Sprintf("%v", mp.FlashTotalEnemy)) builder.WriteString(fmt.Sprintf("%v", _m.FlashTotalEnemy))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("match_stats=") builder.WriteString("match_stats=")
builder.WriteString(fmt.Sprintf("%v", mp.MatchStats)) builder.WriteString(fmt.Sprintf("%v", _m.MatchStats))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("player_stats=") builder.WriteString("player_stats=")
builder.WriteString(fmt.Sprintf("%v", mp.PlayerStats)) builder.WriteString(fmt.Sprintf("%v", _m.PlayerStats))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("flash_assists=") builder.WriteString("flash_assists=")
builder.WriteString(fmt.Sprintf("%v", mp.FlashAssists)) builder.WriteString(fmt.Sprintf("%v", _m.FlashAssists))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("avg_ping=") builder.WriteString("avg_ping=")
builder.WriteString(fmt.Sprintf("%v", mp.AvgPing)) builder.WriteString(fmt.Sprintf("%v", _m.AvgPing))
builder.WriteByte(')') builder.WriteByte(')')
return builder.String() return builder.String()
} }

View File

@@ -1898,32 +1898,15 @@ func HasMessagesWith(preds ...predicate.Messages) predicate.MatchPlayer {
// And groups predicates with the AND operator between them. // And groups predicates with the AND operator between them.
func And(predicates ...predicate.MatchPlayer) predicate.MatchPlayer { func And(predicates ...predicate.MatchPlayer) predicate.MatchPlayer {
return predicate.MatchPlayer(func(s *sql.Selector) { return predicate.MatchPlayer(sql.AndPredicates(predicates...))
s1 := s.Clone().SetP(nil)
for _, p := range predicates {
p(s1)
}
s.Where(s1.P())
})
} }
// Or groups predicates with the OR operator between them. // Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.MatchPlayer) predicate.MatchPlayer { func Or(predicates ...predicate.MatchPlayer) predicate.MatchPlayer {
return predicate.MatchPlayer(func(s *sql.Selector) { return predicate.MatchPlayer(sql.OrPredicates(predicates...))
s1 := s.Clone().SetP(nil)
for i, p := range predicates {
if i > 0 {
s1.Or()
}
p(s1)
}
s.Where(s1.P())
})
} }
// Not applies the not operator on the given predicate. // Not applies the not operator on the given predicate.
func Not(p predicate.MatchPlayer) predicate.MatchPlayer { func Not(p predicate.MatchPlayer) predicate.MatchPlayer {
return predicate.MatchPlayer(func(s *sql.Selector) { return predicate.MatchPlayer(sql.NotPredicates(p))
p(s.Not())
})
} }

File diff suppressed because it is too large Load Diff

View File

@@ -20,56 +20,56 @@ type MatchPlayerDelete struct {
} }
// Where appends a list predicates to the MatchPlayerDelete builder. // Where appends a list predicates to the MatchPlayerDelete builder.
func (mpd *MatchPlayerDelete) Where(ps ...predicate.MatchPlayer) *MatchPlayerDelete { func (_d *MatchPlayerDelete) Where(ps ...predicate.MatchPlayer) *MatchPlayerDelete {
mpd.mutation.Where(ps...) _d.mutation.Where(ps...)
return mpd return _d
} }
// Exec executes the deletion query and returns how many vertices were deleted. // Exec executes the deletion query and returns how many vertices were deleted.
func (mpd *MatchPlayerDelete) Exec(ctx context.Context) (int, error) { func (_d *MatchPlayerDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, mpd.sqlExec, mpd.mutation, mpd.hooks) return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (mpd *MatchPlayerDelete) ExecX(ctx context.Context) int { func (_d *MatchPlayerDelete) ExecX(ctx context.Context) int {
n, err := mpd.Exec(ctx) n, err := _d.Exec(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
return n 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)) _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) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) 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) { if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
mpd.mutation.done = true _d.mutation.done = true
return affected, err return affected, err
} }
// MatchPlayerDeleteOne is the builder for deleting a single MatchPlayer entity. // MatchPlayerDeleteOne is the builder for deleting a single MatchPlayer entity.
type MatchPlayerDeleteOne struct { type MatchPlayerDeleteOne struct {
mpd *MatchPlayerDelete _d *MatchPlayerDelete
} }
// Where appends a list predicates to the MatchPlayerDelete builder. // Where appends a list predicates to the MatchPlayerDelete builder.
func (mpdo *MatchPlayerDeleteOne) Where(ps ...predicate.MatchPlayer) *MatchPlayerDeleteOne { func (_d *MatchPlayerDeleteOne) Where(ps ...predicate.MatchPlayer) *MatchPlayerDeleteOne {
mpdo.mpd.mutation.Where(ps...) _d._d.mutation.Where(ps...)
return mpdo return _d
} }
// Exec executes the deletion query. // Exec executes the deletion query.
func (mpdo *MatchPlayerDeleteOne) Exec(ctx context.Context) error { func (_d *MatchPlayerDeleteOne) Exec(ctx context.Context) error {
n, err := mpdo.mpd.Exec(ctx) n, err := _d._d.Exec(ctx)
switch { switch {
case err != nil: case err != nil:
return err return err
@@ -81,8 +81,8 @@ func (mpdo *MatchPlayerDeleteOne) Exec(ctx context.Context) error {
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (mpdo *MatchPlayerDeleteOne) ExecX(ctx context.Context) { func (_d *MatchPlayerDeleteOne) ExecX(ctx context.Context) {
if err := mpdo.Exec(ctx); err != nil { if err := _d.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }

View File

@@ -8,6 +8,7 @@ import (
"fmt" "fmt"
"math" "math"
"entgo.io/ent"
"entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field" "entgo.io/ent/schema/field"
@@ -41,44 +42,44 @@ type MatchPlayerQuery struct {
} }
// Where adds a new predicate for the MatchPlayerQuery builder. // Where adds a new predicate for the MatchPlayerQuery builder.
func (mpq *MatchPlayerQuery) Where(ps ...predicate.MatchPlayer) *MatchPlayerQuery { func (_q *MatchPlayerQuery) Where(ps ...predicate.MatchPlayer) *MatchPlayerQuery {
mpq.predicates = append(mpq.predicates, ps...) _q.predicates = append(_q.predicates, ps...)
return mpq return _q
} }
// Limit the number of records to be returned by this query. // Limit the number of records to be returned by this query.
func (mpq *MatchPlayerQuery) Limit(limit int) *MatchPlayerQuery { func (_q *MatchPlayerQuery) Limit(limit int) *MatchPlayerQuery {
mpq.ctx.Limit = &limit _q.ctx.Limit = &limit
return mpq return _q
} }
// Offset to start from. // Offset to start from.
func (mpq *MatchPlayerQuery) Offset(offset int) *MatchPlayerQuery { func (_q *MatchPlayerQuery) Offset(offset int) *MatchPlayerQuery {
mpq.ctx.Offset = &offset _q.ctx.Offset = &offset
return mpq return _q
} }
// Unique configures the query builder to filter duplicate records on query. // 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. // By default, unique is set to true, and can be disabled using this method.
func (mpq *MatchPlayerQuery) Unique(unique bool) *MatchPlayerQuery { func (_q *MatchPlayerQuery) Unique(unique bool) *MatchPlayerQuery {
mpq.ctx.Unique = &unique _q.ctx.Unique = &unique
return mpq return _q
} }
// Order specifies how the records should be ordered. // Order specifies how the records should be ordered.
func (mpq *MatchPlayerQuery) Order(o ...matchplayer.OrderOption) *MatchPlayerQuery { func (_q *MatchPlayerQuery) Order(o ...matchplayer.OrderOption) *MatchPlayerQuery {
mpq.order = append(mpq.order, o...) _q.order = append(_q.order, o...)
return mpq return _q
} }
// QueryMatches chains the current query on the "matches" edge. // QueryMatches chains the current query on the "matches" edge.
func (mpq *MatchPlayerQuery) QueryMatches() *MatchQuery { func (_q *MatchPlayerQuery) QueryMatches() *MatchQuery {
query := (&MatchClient{config: mpq.config}).Query() query := (&MatchClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { 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 return nil, err
} }
selector := mpq.sqlQuery(ctx) selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return nil, err return nil, err
} }
@@ -87,20 +88,20 @@ func (mpq *MatchPlayerQuery) QueryMatches() *MatchQuery {
sqlgraph.To(match.Table, match.FieldID), sqlgraph.To(match.Table, match.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, matchplayer.MatchesTable, matchplayer.MatchesColumn), 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 fromU, nil
} }
return query return query
} }
// QueryPlayers chains the current query on the "players" edge. // QueryPlayers chains the current query on the "players" edge.
func (mpq *MatchPlayerQuery) QueryPlayers() *PlayerQuery { func (_q *MatchPlayerQuery) QueryPlayers() *PlayerQuery {
query := (&PlayerClient{config: mpq.config}).Query() query := (&PlayerClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { 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 return nil, err
} }
selector := mpq.sqlQuery(ctx) selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return nil, err return nil, err
} }
@@ -109,20 +110,20 @@ func (mpq *MatchPlayerQuery) QueryPlayers() *PlayerQuery {
sqlgraph.To(player.Table, player.FieldID), sqlgraph.To(player.Table, player.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, matchplayer.PlayersTable, matchplayer.PlayersColumn), 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 fromU, nil
} }
return query return query
} }
// QueryWeaponStats chains the current query on the "weapon_stats" edge. // QueryWeaponStats chains the current query on the "weapon_stats" edge.
func (mpq *MatchPlayerQuery) QueryWeaponStats() *WeaponQuery { func (_q *MatchPlayerQuery) QueryWeaponStats() *WeaponQuery {
query := (&WeaponClient{config: mpq.config}).Query() query := (&WeaponClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { 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 return nil, err
} }
selector := mpq.sqlQuery(ctx) selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return nil, err return nil, err
} }
@@ -131,20 +132,20 @@ func (mpq *MatchPlayerQuery) QueryWeaponStats() *WeaponQuery {
sqlgraph.To(weapon.Table, weapon.FieldID), sqlgraph.To(weapon.Table, weapon.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.WeaponStatsTable, matchplayer.WeaponStatsColumn), 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 fromU, nil
} }
return query return query
} }
// QueryRoundStats chains the current query on the "round_stats" edge. // QueryRoundStats chains the current query on the "round_stats" edge.
func (mpq *MatchPlayerQuery) QueryRoundStats() *RoundStatsQuery { func (_q *MatchPlayerQuery) QueryRoundStats() *RoundStatsQuery {
query := (&RoundStatsClient{config: mpq.config}).Query() query := (&RoundStatsClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { 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 return nil, err
} }
selector := mpq.sqlQuery(ctx) selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return nil, err return nil, err
} }
@@ -153,20 +154,20 @@ func (mpq *MatchPlayerQuery) QueryRoundStats() *RoundStatsQuery {
sqlgraph.To(roundstats.Table, roundstats.FieldID), sqlgraph.To(roundstats.Table, roundstats.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.RoundStatsTable, matchplayer.RoundStatsColumn), 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 fromU, nil
} }
return query return query
} }
// QuerySpray chains the current query on the "spray" edge. // QuerySpray chains the current query on the "spray" edge.
func (mpq *MatchPlayerQuery) QuerySpray() *SprayQuery { func (_q *MatchPlayerQuery) QuerySpray() *SprayQuery {
query := (&SprayClient{config: mpq.config}).Query() query := (&SprayClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { 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 return nil, err
} }
selector := mpq.sqlQuery(ctx) selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return nil, err return nil, err
} }
@@ -175,20 +176,20 @@ func (mpq *MatchPlayerQuery) QuerySpray() *SprayQuery {
sqlgraph.To(spray.Table, spray.FieldID), sqlgraph.To(spray.Table, spray.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.SprayTable, matchplayer.SprayColumn), 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 fromU, nil
} }
return query return query
} }
// QueryMessages chains the current query on the "messages" edge. // QueryMessages chains the current query on the "messages" edge.
func (mpq *MatchPlayerQuery) QueryMessages() *MessagesQuery { func (_q *MatchPlayerQuery) QueryMessages() *MessagesQuery {
query := (&MessagesClient{config: mpq.config}).Query() query := (&MessagesClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { 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 return nil, err
} }
selector := mpq.sqlQuery(ctx) selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return nil, err return nil, err
} }
@@ -197,7 +198,7 @@ func (mpq *MatchPlayerQuery) QueryMessages() *MessagesQuery {
sqlgraph.To(messages.Table, messages.FieldID), sqlgraph.To(messages.Table, messages.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.MessagesTable, matchplayer.MessagesColumn), 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 fromU, nil
} }
return query return query
@@ -205,8 +206,8 @@ func (mpq *MatchPlayerQuery) QueryMessages() *MessagesQuery {
// First returns the first MatchPlayer entity from the query. // First returns the first MatchPlayer entity from the query.
// Returns a *NotFoundError when no MatchPlayer was found. // Returns a *NotFoundError when no MatchPlayer was found.
func (mpq *MatchPlayerQuery) First(ctx context.Context) (*MatchPlayer, error) { func (_q *MatchPlayerQuery) First(ctx context.Context) (*MatchPlayer, error) {
nodes, err := mpq.Limit(1).All(setContextOp(ctx, mpq.ctx, "First")) nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
if err != nil { if err != nil {
return nil, err 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. // FirstX is like First, but panics if an error occurs.
func (mpq *MatchPlayerQuery) FirstX(ctx context.Context) *MatchPlayer { func (_q *MatchPlayerQuery) FirstX(ctx context.Context) *MatchPlayer {
node, err := mpq.First(ctx) node, err := _q.First(ctx)
if err != nil && !IsNotFound(err) { if err != nil && !IsNotFound(err) {
panic(err) panic(err)
} }
@@ -227,9 +228,9 @@ func (mpq *MatchPlayerQuery) FirstX(ctx context.Context) *MatchPlayer {
// FirstID returns the first MatchPlayer ID from the query. // FirstID returns the first MatchPlayer ID from the query.
// Returns a *NotFoundError when no MatchPlayer ID was found. // 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 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 return
} }
if len(ids) == 0 { 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. // FirstIDX is like FirstID, but panics if an error occurs.
func (mpq *MatchPlayerQuery) FirstIDX(ctx context.Context) int { func (_q *MatchPlayerQuery) FirstIDX(ctx context.Context) int {
id, err := mpq.FirstID(ctx) id, err := _q.FirstID(ctx)
if err != nil && !IsNotFound(err) { if err != nil && !IsNotFound(err) {
panic(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. // 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 *NotSingularError when more than one MatchPlayer entity is found.
// Returns a *NotFoundError when no MatchPlayer entities are found. // Returns a *NotFoundError when no MatchPlayer entities are found.
func (mpq *MatchPlayerQuery) Only(ctx context.Context) (*MatchPlayer, error) { func (_q *MatchPlayerQuery) Only(ctx context.Context) (*MatchPlayer, error) {
nodes, err := mpq.Limit(2).All(setContextOp(ctx, mpq.ctx, "Only")) nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
if err != nil { if err != nil {
return nil, err 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. // OnlyX is like Only, but panics if an error occurs.
func (mpq *MatchPlayerQuery) OnlyX(ctx context.Context) *MatchPlayer { func (_q *MatchPlayerQuery) OnlyX(ctx context.Context) *MatchPlayer {
node, err := mpq.Only(ctx) node, err := _q.Only(ctx)
if err != nil { if err != nil {
panic(err) 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. // 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 *NotSingularError when more than one MatchPlayer ID is found.
// Returns a *NotFoundError when no entities are 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 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 return
} }
switch len(ids) { 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. // OnlyIDX is like OnlyID, but panics if an error occurs.
func (mpq *MatchPlayerQuery) OnlyIDX(ctx context.Context) int { func (_q *MatchPlayerQuery) OnlyIDX(ctx context.Context) int {
id, err := mpq.OnlyID(ctx) id, err := _q.OnlyID(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -304,18 +305,18 @@ func (mpq *MatchPlayerQuery) OnlyIDX(ctx context.Context) int {
} }
// All executes the query and returns a list of MatchPlayers. // All executes the query and returns a list of MatchPlayers.
func (mpq *MatchPlayerQuery) All(ctx context.Context) ([]*MatchPlayer, error) { func (_q *MatchPlayerQuery) All(ctx context.Context) ([]*MatchPlayer, error) {
ctx = setContextOp(ctx, mpq.ctx, "All") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
if err := mpq.prepareQuery(ctx); err != nil { if err := _q.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
qr := querierAll[[]*MatchPlayer, *MatchPlayerQuery]() 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. // AllX is like All, but panics if an error occurs.
func (mpq *MatchPlayerQuery) AllX(ctx context.Context) []*MatchPlayer { func (_q *MatchPlayerQuery) AllX(ctx context.Context) []*MatchPlayer {
nodes, err := mpq.All(ctx) nodes, err := _q.All(ctx)
if err != nil { if err != nil {
panic(err) 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. // IDs executes the query and returns a list of MatchPlayer IDs.
func (mpq *MatchPlayerQuery) IDs(ctx context.Context) (ids []int, err error) { func (_q *MatchPlayerQuery) IDs(ctx context.Context) (ids []int, err error) {
if mpq.ctx.Unique == nil && mpq.path != nil { if _q.ctx.Unique == nil && _q.path != nil {
mpq.Unique(true) _q.Unique(true)
} }
ctx = setContextOp(ctx, mpq.ctx, "IDs") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
if err = mpq.Select(matchplayer.FieldID).Scan(ctx, &ids); err != nil { if err = _q.Select(matchplayer.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
return ids, nil return ids, nil
} }
// IDsX is like IDs, but panics if an error occurs. // IDsX is like IDs, but panics if an error occurs.
func (mpq *MatchPlayerQuery) IDsX(ctx context.Context) []int { func (_q *MatchPlayerQuery) IDsX(ctx context.Context) []int {
ids, err := mpq.IDs(ctx) ids, err := _q.IDs(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -344,17 +345,17 @@ func (mpq *MatchPlayerQuery) IDsX(ctx context.Context) []int {
} }
// Count returns the count of the given query. // Count returns the count of the given query.
func (mpq *MatchPlayerQuery) Count(ctx context.Context) (int, error) { func (_q *MatchPlayerQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, mpq.ctx, "Count") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
if err := mpq.prepareQuery(ctx); err != nil { if err := _q.prepareQuery(ctx); err != nil {
return 0, err 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. // CountX is like Count, but panics if an error occurs.
func (mpq *MatchPlayerQuery) CountX(ctx context.Context) int { func (_q *MatchPlayerQuery) CountX(ctx context.Context) int {
count, err := mpq.Count(ctx) count, err := _q.Count(ctx)
if err != nil { if err != nil {
panic(err) 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. // Exist returns true if the query has elements in the graph.
func (mpq *MatchPlayerQuery) Exist(ctx context.Context) (bool, error) { func (_q *MatchPlayerQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, mpq.ctx, "Exist") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
switch _, err := mpq.FirstID(ctx); { switch _, err := _q.FirstID(ctx); {
case IsNotFound(err): case IsNotFound(err):
return false, nil return false, nil
case err != 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. // ExistX is like Exist, but panics if an error occurs.
func (mpq *MatchPlayerQuery) ExistX(ctx context.Context) bool { func (_q *MatchPlayerQuery) ExistX(ctx context.Context) bool {
exist, err := mpq.Exist(ctx) exist, err := _q.Exist(ctx)
if err != nil { if err != nil {
panic(err) 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 // 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. // used to prepare common query builders and use them differently after the clone is made.
func (mpq *MatchPlayerQuery) Clone() *MatchPlayerQuery { func (_q *MatchPlayerQuery) Clone() *MatchPlayerQuery {
if mpq == nil { if _q == nil {
return nil return nil
} }
return &MatchPlayerQuery{ return &MatchPlayerQuery{
config: mpq.config, config: _q.config,
ctx: mpq.ctx.Clone(), ctx: _q.ctx.Clone(),
order: append([]matchplayer.OrderOption{}, mpq.order...), order: append([]matchplayer.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, mpq.inters...), inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.MatchPlayer{}, mpq.predicates...), predicates: append([]predicate.MatchPlayer{}, _q.predicates...),
withMatches: mpq.withMatches.Clone(), withMatches: _q.withMatches.Clone(),
withPlayers: mpq.withPlayers.Clone(), withPlayers: _q.withPlayers.Clone(),
withWeaponStats: mpq.withWeaponStats.Clone(), withWeaponStats: _q.withWeaponStats.Clone(),
withRoundStats: mpq.withRoundStats.Clone(), withRoundStats: _q.withRoundStats.Clone(),
withSpray: mpq.withSpray.Clone(), withSpray: _q.withSpray.Clone(),
withMessages: mpq.withMessages.Clone(), withMessages: _q.withMessages.Clone(),
// clone intermediate query. // clone intermediate query.
sql: mpq.sql.Clone(), sql: _q.sql.Clone(),
path: mpq.path, path: _q.path,
modifiers: append([]func(*sql.Selector){}, _q.modifiers...),
} }
} }
// WithMatches tells the query-builder to eager-load the nodes that are connected to // 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. // the "matches" edge. The optional arguments are used to configure the query builder of the edge.
func (mpq *MatchPlayerQuery) WithMatches(opts ...func(*MatchQuery)) *MatchPlayerQuery { func (_q *MatchPlayerQuery) WithMatches(opts ...func(*MatchQuery)) *MatchPlayerQuery {
query := (&MatchClient{config: mpq.config}).Query() query := (&MatchClient{config: _q.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
mpq.withMatches = query _q.withMatches = query
return mpq return _q
} }
// WithPlayers tells the query-builder to eager-load the nodes that are connected to // 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. // the "players" edge. The optional arguments are used to configure the query builder of the edge.
func (mpq *MatchPlayerQuery) WithPlayers(opts ...func(*PlayerQuery)) *MatchPlayerQuery { func (_q *MatchPlayerQuery) WithPlayers(opts ...func(*PlayerQuery)) *MatchPlayerQuery {
query := (&PlayerClient{config: mpq.config}).Query() query := (&PlayerClient{config: _q.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
mpq.withPlayers = query _q.withPlayers = query
return mpq return _q
} }
// WithWeaponStats tells the query-builder to eager-load the nodes that are connected to // 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. // 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 { func (_q *MatchPlayerQuery) WithWeaponStats(opts ...func(*WeaponQuery)) *MatchPlayerQuery {
query := (&WeaponClient{config: mpq.config}).Query() query := (&WeaponClient{config: _q.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
mpq.withWeaponStats = query _q.withWeaponStats = query
return mpq return _q
} }
// WithRoundStats tells the query-builder to eager-load the nodes that are connected to // 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. // 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 { func (_q *MatchPlayerQuery) WithRoundStats(opts ...func(*RoundStatsQuery)) *MatchPlayerQuery {
query := (&RoundStatsClient{config: mpq.config}).Query() query := (&RoundStatsClient{config: _q.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
mpq.withRoundStats = query _q.withRoundStats = query
return mpq return _q
} }
// WithSpray tells the query-builder to eager-load the nodes that are connected to // 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. // the "spray" edge. The optional arguments are used to configure the query builder of the edge.
func (mpq *MatchPlayerQuery) WithSpray(opts ...func(*SprayQuery)) *MatchPlayerQuery { func (_q *MatchPlayerQuery) WithSpray(opts ...func(*SprayQuery)) *MatchPlayerQuery {
query := (&SprayClient{config: mpq.config}).Query() query := (&SprayClient{config: _q.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
mpq.withSpray = query _q.withSpray = query
return mpq return _q
} }
// WithMessages tells the query-builder to eager-load the nodes that are connected to // 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. // the "messages" edge. The optional arguments are used to configure the query builder of the edge.
func (mpq *MatchPlayerQuery) WithMessages(opts ...func(*MessagesQuery)) *MatchPlayerQuery { func (_q *MatchPlayerQuery) WithMessages(opts ...func(*MessagesQuery)) *MatchPlayerQuery {
query := (&MessagesClient{config: mpq.config}).Query() query := (&MessagesClient{config: _q.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
mpq.withMessages = query _q.withMessages = query
return mpq return _q
} }
// GroupBy is used to group vertices by one or more fields/columns. // 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). // GroupBy(matchplayer.FieldTeamID).
// Aggregate(ent.Count()). // Aggregate(ent.Count()).
// Scan(ctx, &v) // Scan(ctx, &v)
func (mpq *MatchPlayerQuery) GroupBy(field string, fields ...string) *MatchPlayerGroupBy { func (_q *MatchPlayerQuery) GroupBy(field string, fields ...string) *MatchPlayerGroupBy {
mpq.ctx.Fields = append([]string{field}, fields...) _q.ctx.Fields = append([]string{field}, fields...)
grbuild := &MatchPlayerGroupBy{build: mpq} grbuild := &MatchPlayerGroupBy{build: _q}
grbuild.flds = &mpq.ctx.Fields grbuild.flds = &_q.ctx.Fields
grbuild.label = matchplayer.Label grbuild.label = matchplayer.Label
grbuild.scan = grbuild.Scan grbuild.scan = grbuild.Scan
return grbuild return grbuild
@@ -508,114 +510,114 @@ func (mpq *MatchPlayerQuery) GroupBy(field string, fields ...string) *MatchPlaye
// client.MatchPlayer.Query(). // client.MatchPlayer.Query().
// Select(matchplayer.FieldTeamID). // Select(matchplayer.FieldTeamID).
// Scan(ctx, &v) // Scan(ctx, &v)
func (mpq *MatchPlayerQuery) Select(fields ...string) *MatchPlayerSelect { func (_q *MatchPlayerQuery) Select(fields ...string) *MatchPlayerSelect {
mpq.ctx.Fields = append(mpq.ctx.Fields, fields...) _q.ctx.Fields = append(_q.ctx.Fields, fields...)
sbuild := &MatchPlayerSelect{MatchPlayerQuery: mpq} sbuild := &MatchPlayerSelect{MatchPlayerQuery: _q}
sbuild.label = matchplayer.Label sbuild.label = matchplayer.Label
sbuild.flds, sbuild.scan = &mpq.ctx.Fields, sbuild.Scan sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
return sbuild return sbuild
} }
// Aggregate returns a MatchPlayerSelect configured with the given aggregations. // Aggregate returns a MatchPlayerSelect configured with the given aggregations.
func (mpq *MatchPlayerQuery) Aggregate(fns ...AggregateFunc) *MatchPlayerSelect { func (_q *MatchPlayerQuery) Aggregate(fns ...AggregateFunc) *MatchPlayerSelect {
return mpq.Select().Aggregate(fns...) return _q.Select().Aggregate(fns...)
} }
func (mpq *MatchPlayerQuery) prepareQuery(ctx context.Context) error { func (_q *MatchPlayerQuery) prepareQuery(ctx context.Context) error {
for _, inter := range mpq.inters { for _, inter := range _q.inters {
if inter == nil { if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
} }
if trv, ok := inter.(Traverser); ok { if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, mpq); err != nil { if err := trv.Traverse(ctx, _q); err != nil {
return err return err
} }
} }
} }
for _, f := range mpq.ctx.Fields { for _, f := range _q.ctx.Fields {
if !matchplayer.ValidColumn(f) { if !matchplayer.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
} }
} }
if mpq.path != nil { if _q.path != nil {
prev, err := mpq.path(ctx) prev, err := _q.path(ctx)
if err != nil { if err != nil {
return err return err
} }
mpq.sql = prev _q.sql = prev
} }
return nil 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 ( var (
nodes = []*MatchPlayer{} nodes = []*MatchPlayer{}
_spec = mpq.querySpec() _spec = _q.querySpec()
loadedTypes = [6]bool{ loadedTypes = [6]bool{
mpq.withMatches != nil, _q.withMatches != nil,
mpq.withPlayers != nil, _q.withPlayers != nil,
mpq.withWeaponStats != nil, _q.withWeaponStats != nil,
mpq.withRoundStats != nil, _q.withRoundStats != nil,
mpq.withSpray != nil, _q.withSpray != nil,
mpq.withMessages != nil, _q.withMessages != nil,
} }
) )
_spec.ScanValues = func(columns []string) ([]any, error) { _spec.ScanValues = func(columns []string) ([]any, error) {
return (*MatchPlayer).scanValues(nil, columns) return (*MatchPlayer).scanValues(nil, columns)
} }
_spec.Assign = func(columns []string, values []any) error { _spec.Assign = func(columns []string, values []any) error {
node := &MatchPlayer{config: mpq.config} node := &MatchPlayer{config: _q.config}
nodes = append(nodes, node) nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values) return node.assignValues(columns, values)
} }
if len(mpq.modifiers) > 0 { if len(_q.modifiers) > 0 {
_spec.Modifiers = mpq.modifiers _spec.Modifiers = _q.modifiers
} }
for i := range hooks { for i := range hooks {
hooks[i](ctx, _spec) 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 return nil, err
} }
if len(nodes) == 0 { if len(nodes) == 0 {
return nodes, nil return nodes, nil
} }
if query := mpq.withMatches; query != nil { if query := _q.withMatches; query != nil {
if err := mpq.loadMatches(ctx, query, nodes, nil, if err := _q.loadMatches(ctx, query, nodes, nil,
func(n *MatchPlayer, e *Match) { n.Edges.Matches = e }); err != nil { func(n *MatchPlayer, e *Match) { n.Edges.Matches = e }); err != nil {
return nil, err return nil, err
} }
} }
if query := mpq.withPlayers; query != nil { if query := _q.withPlayers; query != nil {
if err := mpq.loadPlayers(ctx, query, nodes, nil, if err := _q.loadPlayers(ctx, query, nodes, nil,
func(n *MatchPlayer, e *Player) { n.Edges.Players = e }); err != nil { func(n *MatchPlayer, e *Player) { n.Edges.Players = e }); err != nil {
return nil, err return nil, err
} }
} }
if query := mpq.withWeaponStats; query != nil { if query := _q.withWeaponStats; query != nil {
if err := mpq.loadWeaponStats(ctx, query, nodes, if err := _q.loadWeaponStats(ctx, query, nodes,
func(n *MatchPlayer) { n.Edges.WeaponStats = []*Weapon{} }, func(n *MatchPlayer) { n.Edges.WeaponStats = []*Weapon{} },
func(n *MatchPlayer, e *Weapon) { n.Edges.WeaponStats = append(n.Edges.WeaponStats, e) }); err != nil { func(n *MatchPlayer, e *Weapon) { n.Edges.WeaponStats = append(n.Edges.WeaponStats, e) }); err != nil {
return nil, err return nil, err
} }
} }
if query := mpq.withRoundStats; query != nil { if query := _q.withRoundStats; query != nil {
if err := mpq.loadRoundStats(ctx, query, nodes, if err := _q.loadRoundStats(ctx, query, nodes,
func(n *MatchPlayer) { n.Edges.RoundStats = []*RoundStats{} }, func(n *MatchPlayer) { n.Edges.RoundStats = []*RoundStats{} },
func(n *MatchPlayer, e *RoundStats) { n.Edges.RoundStats = append(n.Edges.RoundStats, e) }); err != nil { func(n *MatchPlayer, e *RoundStats) { n.Edges.RoundStats = append(n.Edges.RoundStats, e) }); err != nil {
return nil, err return nil, err
} }
} }
if query := mpq.withSpray; query != nil { if query := _q.withSpray; query != nil {
if err := mpq.loadSpray(ctx, query, nodes, if err := _q.loadSpray(ctx, query, nodes,
func(n *MatchPlayer) { n.Edges.Spray = []*Spray{} }, func(n *MatchPlayer) { n.Edges.Spray = []*Spray{} },
func(n *MatchPlayer, e *Spray) { n.Edges.Spray = append(n.Edges.Spray, e) }); err != nil { func(n *MatchPlayer, e *Spray) { n.Edges.Spray = append(n.Edges.Spray, e) }); err != nil {
return nil, err return nil, err
} }
} }
if query := mpq.withMessages; query != nil { if query := _q.withMessages; query != nil {
if err := mpq.loadMessages(ctx, query, nodes, if err := _q.loadMessages(ctx, query, nodes,
func(n *MatchPlayer) { n.Edges.Messages = []*Messages{} }, func(n *MatchPlayer) { n.Edges.Messages = []*Messages{} },
func(n *MatchPlayer, e *Messages) { n.Edges.Messages = append(n.Edges.Messages, e) }); err != nil { func(n *MatchPlayer, e *Messages) { n.Edges.Messages = append(n.Edges.Messages, e) }); err != nil {
return nil, err return nil, err
@@ -624,7 +626,7 @@ func (mpq *MatchPlayerQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]
return nodes, nil 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)) ids := make([]uint64, 0, len(nodes))
nodeids := make(map[uint64][]*MatchPlayer) nodeids := make(map[uint64][]*MatchPlayer)
for i := range nodes { for i := range nodes {
@@ -653,7 +655,7 @@ func (mpq *MatchPlayerQuery) loadMatches(ctx context.Context, query *MatchQuery,
} }
return nil 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)) ids := make([]uint64, 0, len(nodes))
nodeids := make(map[uint64][]*MatchPlayer) nodeids := make(map[uint64][]*MatchPlayer)
for i := range nodes { for i := range nodes {
@@ -682,7 +684,7 @@ func (mpq *MatchPlayerQuery) loadPlayers(ctx context.Context, query *PlayerQuery
} }
return nil 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)) fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[int]*MatchPlayer) nodeids := make(map[int]*MatchPlayer)
for i := range nodes { for i := range nodes {
@@ -713,7 +715,7 @@ func (mpq *MatchPlayerQuery) loadWeaponStats(ctx context.Context, query *WeaponQ
} }
return nil 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)) fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[int]*MatchPlayer) nodeids := make(map[int]*MatchPlayer)
for i := range nodes { for i := range nodes {
@@ -744,7 +746,7 @@ func (mpq *MatchPlayerQuery) loadRoundStats(ctx context.Context, query *RoundSta
} }
return nil 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)) fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[int]*MatchPlayer) nodeids := make(map[int]*MatchPlayer)
for i := range nodes { for i := range nodes {
@@ -775,7 +777,7 @@ func (mpq *MatchPlayerQuery) loadSpray(ctx context.Context, query *SprayQuery, n
} }
return nil 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)) fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[int]*MatchPlayer) nodeids := make(map[int]*MatchPlayer)
for i := range nodes { for i := range nodes {
@@ -807,27 +809,27 @@ func (mpq *MatchPlayerQuery) loadMessages(ctx context.Context, query *MessagesQu
return nil return nil
} }
func (mpq *MatchPlayerQuery) sqlCount(ctx context.Context) (int, error) { func (_q *MatchPlayerQuery) sqlCount(ctx context.Context) (int, error) {
_spec := mpq.querySpec() _spec := _q.querySpec()
if len(mpq.modifiers) > 0 { if len(_q.modifiers) > 0 {
_spec.Modifiers = mpq.modifiers _spec.Modifiers = _q.modifiers
} }
_spec.Node.Columns = mpq.ctx.Fields _spec.Node.Columns = _q.ctx.Fields
if len(mpq.ctx.Fields) > 0 { if len(_q.ctx.Fields) > 0 {
_spec.Unique = mpq.ctx.Unique != nil && *mpq.ctx.Unique _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 := sqlgraph.NewQuerySpec(matchplayer.Table, matchplayer.Columns, sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt))
_spec.From = mpq.sql _spec.From = _q.sql
if unique := mpq.ctx.Unique; unique != nil { if unique := _q.ctx.Unique; unique != nil {
_spec.Unique = *unique _spec.Unique = *unique
} else if mpq.path != nil { } else if _q.path != nil {
_spec.Unique = true _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 = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, matchplayer.FieldID) _spec.Node.Columns = append(_spec.Node.Columns, matchplayer.FieldID)
for i := range fields { for i := range fields {
@@ -835,27 +837,27 @@ func (mpq *MatchPlayerQuery) querySpec() *sqlgraph.QuerySpec {
_spec.Node.Columns = append(_spec.Node.Columns, fields[i]) _spec.Node.Columns = append(_spec.Node.Columns, fields[i])
} }
} }
if mpq.withMatches != nil { if _q.withMatches != nil {
_spec.Node.AddColumnOnce(matchplayer.FieldMatchStats) _spec.Node.AddColumnOnce(matchplayer.FieldMatchStats)
} }
if mpq.withPlayers != nil { if _q.withPlayers != nil {
_spec.Node.AddColumnOnce(matchplayer.FieldPlayerStats) _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) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) ps[i](selector)
} }
} }
} }
if limit := mpq.ctx.Limit; limit != nil { if limit := _q.ctx.Limit; limit != nil {
_spec.Limit = *limit _spec.Limit = *limit
} }
if offset := mpq.ctx.Offset; offset != nil { if offset := _q.ctx.Offset; offset != nil {
_spec.Offset = *offset _spec.Offset = *offset
} }
if ps := mpq.order; len(ps) > 0 { if ps := _q.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) { _spec.Order = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) ps[i](selector)
@@ -865,45 +867,45 @@ func (mpq *MatchPlayerQuery) querySpec() *sqlgraph.QuerySpec {
return _spec return _spec
} }
func (mpq *MatchPlayerQuery) sqlQuery(ctx context.Context) *sql.Selector { func (_q *MatchPlayerQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(mpq.driver.Dialect()) builder := sql.Dialect(_q.driver.Dialect())
t1 := builder.Table(matchplayer.Table) t1 := builder.Table(matchplayer.Table)
columns := mpq.ctx.Fields columns := _q.ctx.Fields
if len(columns) == 0 { if len(columns) == 0 {
columns = matchplayer.Columns columns = matchplayer.Columns
} }
selector := builder.Select(t1.Columns(columns...)...).From(t1) selector := builder.Select(t1.Columns(columns...)...).From(t1)
if mpq.sql != nil { if _q.sql != nil {
selector = mpq.sql selector = _q.sql
selector.Select(selector.Columns(columns...)...) selector.Select(selector.Columns(columns...)...)
} }
if mpq.ctx.Unique != nil && *mpq.ctx.Unique { if _q.ctx.Unique != nil && *_q.ctx.Unique {
selector.Distinct() selector.Distinct()
} }
for _, m := range mpq.modifiers { for _, m := range _q.modifiers {
m(selector) m(selector)
} }
for _, p := range mpq.predicates { for _, p := range _q.predicates {
p(selector) p(selector)
} }
for _, p := range mpq.order { for _, p := range _q.order {
p(selector) p(selector)
} }
if offset := mpq.ctx.Offset; offset != nil { if offset := _q.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start // limit is mandatory for offset clause. We start
// with default value, and override it below if needed. // with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32) selector.Offset(*offset).Limit(math.MaxInt32)
} }
if limit := mpq.ctx.Limit; limit != nil { if limit := _q.ctx.Limit; limit != nil {
selector.Limit(*limit) selector.Limit(*limit)
} }
return selector return selector
} }
// Modify adds a query modifier for attaching custom logic to queries. // Modify adds a query modifier for attaching custom logic to queries.
func (mpq *MatchPlayerQuery) Modify(modifiers ...func(s *sql.Selector)) *MatchPlayerSelect { func (_q *MatchPlayerQuery) Modify(modifiers ...func(s *sql.Selector)) *MatchPlayerSelect {
mpq.modifiers = append(mpq.modifiers, modifiers...) _q.modifiers = append(_q.modifiers, modifiers...)
return mpq.Select() return _q.Select()
} }
// MatchPlayerGroupBy is the group-by builder for MatchPlayer entities. // 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. // Aggregate adds the given aggregation functions to the group-by query.
func (mpgb *MatchPlayerGroupBy) Aggregate(fns ...AggregateFunc) *MatchPlayerGroupBy { func (_g *MatchPlayerGroupBy) Aggregate(fns ...AggregateFunc) *MatchPlayerGroupBy {
mpgb.fns = append(mpgb.fns, fns...) _g.fns = append(_g.fns, fns...)
return mpgb return _g
} }
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (mpgb *MatchPlayerGroupBy) Scan(ctx context.Context, v any) error { func (_g *MatchPlayerGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, mpgb.build.ctx, "GroupBy") ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
if err := mpgb.build.prepareQuery(ctx); err != nil { if err := _g.build.prepareQuery(ctx); err != nil {
return err 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() selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(mpgb.fns)) aggregation := make([]string, 0, len(_g.fns))
for _, fn := range mpgb.fns { for _, fn := range _g.fns {
aggregation = append(aggregation, fn(selector)) aggregation = append(aggregation, fn(selector))
} }
if len(selector.SelectedColumns()) == 0 { if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*mpgb.flds)+len(mpgb.fns)) columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
for _, f := range *mpgb.flds { for _, f := range *_g.flds {
columns = append(columns, selector.C(f)) columns = append(columns, selector.C(f))
} }
columns = append(columns, aggregation...) columns = append(columns, aggregation...)
selector.Select(columns...) selector.Select(columns...)
} }
selector.GroupBy(selector.Columns(*mpgb.flds...)...) selector.GroupBy(selector.Columns(*_g.flds...)...)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return err return err
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := selector.Query() 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 return err
} }
defer rows.Close() defer rows.Close()
@@ -961,27 +963,27 @@ type MatchPlayerSelect struct {
} }
// Aggregate adds the given aggregation functions to the selector query. // Aggregate adds the given aggregation functions to the selector query.
func (mps *MatchPlayerSelect) Aggregate(fns ...AggregateFunc) *MatchPlayerSelect { func (_s *MatchPlayerSelect) Aggregate(fns ...AggregateFunc) *MatchPlayerSelect {
mps.fns = append(mps.fns, fns...) _s.fns = append(_s.fns, fns...)
return mps return _s
} }
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (mps *MatchPlayerSelect) Scan(ctx context.Context, v any) error { func (_s *MatchPlayerSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, mps.ctx, "Select") ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
if err := mps.prepareQuery(ctx); err != nil { if err := _s.prepareQuery(ctx); err != nil {
return err 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) selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(mps.fns)) aggregation := make([]string, 0, len(_s.fns))
for _, fn := range mps.fns { for _, fn := range _s.fns {
aggregation = append(aggregation, fn(selector)) aggregation = append(aggregation, fn(selector))
} }
switch n := len(*mps.selector.flds); { switch n := len(*_s.selector.flds); {
case n == 0 && len(aggregation) > 0: case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...) selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0: case n != 0 && len(aggregation) > 0:
@@ -989,7 +991,7 @@ func (mps *MatchPlayerSelect) sqlScan(ctx context.Context, root *MatchPlayerQuer
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := selector.Query() 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 return err
} }
defer rows.Close() 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. // Modify adds a query modifier for attaching custom logic to queries.
func (mps *MatchPlayerSelect) Modify(modifiers ...func(s *sql.Selector)) *MatchPlayerSelect { func (_s *MatchPlayerSelect) Modify(modifiers ...func(s *sql.Selector)) *MatchPlayerSelect {
mps.modifiers = append(mps.modifiers, modifiers...) _s.modifiers = append(_s.modifiers, modifiers...)
return mps return _s
} }

File diff suppressed because it is too large Load Diff

View File

@@ -42,12 +42,10 @@ type MessagesEdges struct {
// MatchPlayerOrErr returns the MatchPlayer value or an error if the edge // MatchPlayerOrErr returns the MatchPlayer value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found. // was not loaded in eager-loading, or loaded but was not found.
func (e MessagesEdges) MatchPlayerOrErr() (*MatchPlayer, error) { func (e MessagesEdges) MatchPlayerOrErr() (*MatchPlayer, error) {
if e.loadedTypes[0] { if e.MatchPlayer != nil {
if e.MatchPlayer == nil {
// Edge was loaded but was not found.
return nil, &NotFoundError{label: matchplayer.Label}
}
return e.MatchPlayer, nil return e.MatchPlayer, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: matchplayer.Label}
} }
return nil, &NotLoadedError{edge: "match_player"} 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) // assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Messages fields. // 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 { if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", 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 { if !ok {
return fmt.Errorf("unexpected type %T for field id", value) return fmt.Errorf("unexpected type %T for field id", value)
} }
m.ID = int(value.Int64) _m.ID = int(value.Int64)
case messages.FieldMessage: case messages.FieldMessage:
if value, ok := values[i].(*sql.NullString); !ok { if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field message", values[i]) return fmt.Errorf("unexpected type %T for field message", values[i])
} else if value.Valid { } else if value.Valid {
m.Message = value.String _m.Message = value.String
} }
case messages.FieldAllChat: case messages.FieldAllChat:
if value, ok := values[i].(*sql.NullBool); !ok { if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field all_chat", values[i]) return fmt.Errorf("unexpected type %T for field all_chat", values[i])
} else if value.Valid { } else if value.Valid {
m.AllChat = value.Bool _m.AllChat = value.Bool
} }
case messages.FieldTick: case messages.FieldTick:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field tick", values[i]) return fmt.Errorf("unexpected type %T for field tick", values[i])
} else if value.Valid { } else if value.Valid {
m.Tick = int(value.Int64) _m.Tick = int(value.Int64)
} }
case messages.ForeignKeys[0]: case messages.ForeignKeys[0]:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for edge-field match_player_messages", value) return fmt.Errorf("unexpected type %T for edge-field match_player_messages", value)
} else if value.Valid { } else if value.Valid {
m.match_player_messages = new(int) _m.match_player_messages = new(int)
*m.match_player_messages = int(value.Int64) *_m.match_player_messages = int(value.Int64)
} }
default: default:
m.selectValues.Set(columns[i], values[i]) _m.selectValues.Set(columns[i], values[i])
} }
} }
return nil 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. // Value returns the ent.Value that was dynamically selected and assigned to the Messages.
// This includes values selected through modifiers, order, etc. // This includes values selected through modifiers, order, etc.
func (m *Messages) Value(name string) (ent.Value, error) { func (_m *Messages) Value(name string) (ent.Value, error) {
return m.selectValues.Get(name) return _m.selectValues.Get(name)
} }
// QueryMatchPlayer queries the "match_player" edge of the Messages entity. // QueryMatchPlayer queries the "match_player" edge of the Messages entity.
func (m *Messages) QueryMatchPlayer() *MatchPlayerQuery { func (_m *Messages) QueryMatchPlayer() *MatchPlayerQuery {
return NewMessagesClient(m.config).QueryMatchPlayer(m) return NewMessagesClient(_m.config).QueryMatchPlayer(_m)
} }
// Update returns a builder for updating this Messages. // Update returns a builder for updating this Messages.
// Note that you need to call Messages.Unwrap() before calling this method if 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. // was returned from a transaction, and the transaction was committed or rolled back.
func (m *Messages) Update() *MessagesUpdateOne { func (_m *Messages) Update() *MessagesUpdateOne {
return NewMessagesClient(m.config).UpdateOne(m) return NewMessagesClient(_m.config).UpdateOne(_m)
} }
// Unwrap unwraps the Messages entity that was returned from a transaction after it was closed, // 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. // so that all future queries will be executed through the driver which created the transaction.
func (m *Messages) Unwrap() *Messages { func (_m *Messages) Unwrap() *Messages {
_tx, ok := m.config.driver.(*txDriver) _tx, ok := _m.config.driver.(*txDriver)
if !ok { if !ok {
panic("ent: Messages is not a transactional entity") panic("ent: Messages is not a transactional entity")
} }
m.config.driver = _tx.drv _m.config.driver = _tx.drv
return m return _m
} }
// String implements the fmt.Stringer. // String implements the fmt.Stringer.
func (m *Messages) String() string { func (_m *Messages) String() string {
var builder strings.Builder var builder strings.Builder
builder.WriteString("Messages(") builder.WriteString("Messages(")
builder.WriteString(fmt.Sprintf("id=%v, ", m.ID)) builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("message=") builder.WriteString("message=")
builder.WriteString(m.Message) builder.WriteString(_m.Message)
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("all_chat=") builder.WriteString("all_chat=")
builder.WriteString(fmt.Sprintf("%v", m.AllChat)) builder.WriteString(fmt.Sprintf("%v", _m.AllChat))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("tick=") builder.WriteString("tick=")
builder.WriteString(fmt.Sprintf("%v", m.Tick)) builder.WriteString(fmt.Sprintf("%v", _m.Tick))
builder.WriteByte(')') builder.WriteByte(')')
return builder.String() return builder.String()
} }

View File

@@ -208,32 +208,15 @@ func HasMatchPlayerWith(preds ...predicate.MatchPlayer) predicate.Messages {
// And groups predicates with the AND operator between them. // And groups predicates with the AND operator between them.
func And(predicates ...predicate.Messages) predicate.Messages { func And(predicates ...predicate.Messages) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) { return predicate.Messages(sql.AndPredicates(predicates...))
s1 := s.Clone().SetP(nil)
for _, p := range predicates {
p(s1)
}
s.Where(s1.P())
})
} }
// Or groups predicates with the OR operator between them. // Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.Messages) predicate.Messages { func Or(predicates ...predicate.Messages) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) { return predicate.Messages(sql.OrPredicates(predicates...))
s1 := s.Clone().SetP(nil)
for i, p := range predicates {
if i > 0 {
s1.Or()
}
p(s1)
}
s.Where(s1.P())
})
} }
// Not applies the not operator on the given predicate. // Not applies the not operator on the given predicate.
func Not(p predicate.Messages) predicate.Messages { func Not(p predicate.Messages) predicate.Messages {
return predicate.Messages(func(s *sql.Selector) { return predicate.Messages(sql.NotPredicates(p))
p(s.Not())
})
} }

View File

@@ -21,55 +21,55 @@ type MessagesCreate struct {
} }
// SetMessage sets the "message" field. // SetMessage sets the "message" field.
func (mc *MessagesCreate) SetMessage(s string) *MessagesCreate { func (_c *MessagesCreate) SetMessage(v string) *MessagesCreate {
mc.mutation.SetMessage(s) _c.mutation.SetMessage(v)
return mc return _c
} }
// SetAllChat sets the "all_chat" field. // SetAllChat sets the "all_chat" field.
func (mc *MessagesCreate) SetAllChat(b bool) *MessagesCreate { func (_c *MessagesCreate) SetAllChat(v bool) *MessagesCreate {
mc.mutation.SetAllChat(b) _c.mutation.SetAllChat(v)
return mc return _c
} }
// SetTick sets the "tick" field. // SetTick sets the "tick" field.
func (mc *MessagesCreate) SetTick(i int) *MessagesCreate { func (_c *MessagesCreate) SetTick(v int) *MessagesCreate {
mc.mutation.SetTick(i) _c.mutation.SetTick(v)
return mc return _c
} }
// SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID. // SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID.
func (mc *MessagesCreate) SetMatchPlayerID(id int) *MessagesCreate { func (_c *MessagesCreate) SetMatchPlayerID(id int) *MessagesCreate {
mc.mutation.SetMatchPlayerID(id) _c.mutation.SetMatchPlayerID(id)
return mc return _c
} }
// SetNillableMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID if the given value is not nil. // 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 { 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. // SetMatchPlayer sets the "match_player" edge to the MatchPlayer entity.
func (mc *MessagesCreate) SetMatchPlayer(m *MatchPlayer) *MessagesCreate { func (_c *MessagesCreate) SetMatchPlayer(v *MatchPlayer) *MessagesCreate {
return mc.SetMatchPlayerID(m.ID) return _c.SetMatchPlayerID(v.ID)
} }
// Mutation returns the MessagesMutation object of the builder. // Mutation returns the MessagesMutation object of the builder.
func (mc *MessagesCreate) Mutation() *MessagesMutation { func (_c *MessagesCreate) Mutation() *MessagesMutation {
return mc.mutation return _c.mutation
} }
// Save creates the Messages in the database. // Save creates the Messages in the database.
func (mc *MessagesCreate) Save(ctx context.Context) (*Messages, error) { func (_c *MessagesCreate) Save(ctx context.Context) (*Messages, error) {
return withHooks(ctx, mc.sqlSave, mc.mutation, mc.hooks) return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
} }
// SaveX calls Save and panics if Save returns an error. // SaveX calls Save and panics if Save returns an error.
func (mc *MessagesCreate) SaveX(ctx context.Context) *Messages { func (_c *MessagesCreate) SaveX(ctx context.Context) *Messages {
v, err := mc.Save(ctx) v, err := _c.Save(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -77,38 +77,38 @@ func (mc *MessagesCreate) SaveX(ctx context.Context) *Messages {
} }
// Exec executes the query. // Exec executes the query.
func (mc *MessagesCreate) Exec(ctx context.Context) error { func (_c *MessagesCreate) Exec(ctx context.Context) error {
_, err := mc.Save(ctx) _, err := _c.Save(ctx)
return err return err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (mc *MessagesCreate) ExecX(ctx context.Context) { func (_c *MessagesCreate) ExecX(ctx context.Context) {
if err := mc.Exec(ctx); err != nil { if err := _c.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }
// check runs all checks and user-defined validators on the builder. // check runs all checks and user-defined validators on the builder.
func (mc *MessagesCreate) check() error { func (_c *MessagesCreate) check() error {
if _, ok := mc.mutation.Message(); !ok { if _, ok := _c.mutation.Message(); !ok {
return &ValidationError{Name: "message", err: errors.New(`ent: missing required field "Messages.message"`)} 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"`)} 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 &ValidationError{Name: "tick", err: errors.New(`ent: missing required field "Messages.tick"`)}
} }
return nil return nil
} }
func (mc *MessagesCreate) sqlSave(ctx context.Context) (*Messages, error) { func (_c *MessagesCreate) sqlSave(ctx context.Context) (*Messages, error) {
if err := mc.check(); err != nil { if err := _c.check(); err != nil {
return nil, err return nil, err
} }
_node, _spec := mc.createSpec() _node, _spec := _c.createSpec()
if err := sqlgraph.CreateNode(ctx, mc.driver, _spec); err != nil { if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) { if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: 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) id := _spec.ID.Value.(int64)
_node.ID = int(id) _node.ID = int(id)
mc.mutation.id = &_node.ID _c.mutation.id = &_node.ID
mc.mutation.done = true _c.mutation.done = true
return _node, nil return _node, nil
} }
func (mc *MessagesCreate) createSpec() (*Messages, *sqlgraph.CreateSpec) { func (_c *MessagesCreate) createSpec() (*Messages, *sqlgraph.CreateSpec) {
var ( var (
_node = &Messages{config: mc.config} _node = &Messages{config: _c.config}
_spec = sqlgraph.NewCreateSpec(messages.Table, sqlgraph.NewFieldSpec(messages.FieldID, field.TypeInt)) _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) _spec.SetField(messages.FieldMessage, field.TypeString, value)
_node.Message = 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) _spec.SetField(messages.FieldAllChat, field.TypeBool, value)
_node.AllChat = 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) _spec.SetField(messages.FieldTick, field.TypeInt, value)
_node.Tick = value _node.Tick = value
} }
if nodes := mc.mutation.MatchPlayerIDs(); len(nodes) > 0 { if nodes := _c.mutation.MatchPlayerIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{ edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O, Rel: sqlgraph.M2O,
Inverse: true, Inverse: true,
@@ -161,17 +161,21 @@ func (mc *MessagesCreate) createSpec() (*Messages, *sqlgraph.CreateSpec) {
// MessagesCreateBulk is the builder for creating many Messages entities in bulk. // MessagesCreateBulk is the builder for creating many Messages entities in bulk.
type MessagesCreateBulk struct { type MessagesCreateBulk struct {
config config
err error
builders []*MessagesCreate builders []*MessagesCreate
} }
// Save creates the Messages entities in the database. // Save creates the Messages entities in the database.
func (mcb *MessagesCreateBulk) Save(ctx context.Context) ([]*Messages, error) { func (_c *MessagesCreateBulk) Save(ctx context.Context) ([]*Messages, error) {
specs := make([]*sqlgraph.CreateSpec, len(mcb.builders)) if _c.err != nil {
nodes := make([]*Messages, len(mcb.builders)) return nil, _c.err
mutators := make([]Mutator, len(mcb.builders)) }
for i := range mcb.builders { 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) { 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) { var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*MessagesMutation) mutation, ok := m.(*MessagesMutation)
if !ok { if !ok {
@@ -184,11 +188,11 @@ func (mcb *MessagesCreateBulk) Save(ctx context.Context) ([]*Messages, error) {
var err error var err error
nodes[i], specs[i] = builder.createSpec() nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 { 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 { } else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs} spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain. // 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) { if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
@@ -212,7 +216,7 @@ func (mcb *MessagesCreateBulk) Save(ctx context.Context) ([]*Messages, error) {
}(i, ctx) }(i, ctx)
} }
if len(mutators) > 0 { 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 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. // SaveX is like Save, but panics if an error occurs.
func (mcb *MessagesCreateBulk) SaveX(ctx context.Context) []*Messages { func (_c *MessagesCreateBulk) SaveX(ctx context.Context) []*Messages {
v, err := mcb.Save(ctx) v, err := _c.Save(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -229,14 +233,14 @@ func (mcb *MessagesCreateBulk) SaveX(ctx context.Context) []*Messages {
} }
// Exec executes the query. // Exec executes the query.
func (mcb *MessagesCreateBulk) Exec(ctx context.Context) error { func (_c *MessagesCreateBulk) Exec(ctx context.Context) error {
_, err := mcb.Save(ctx) _, err := _c.Save(ctx)
return err return err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (mcb *MessagesCreateBulk) ExecX(ctx context.Context) { func (_c *MessagesCreateBulk) ExecX(ctx context.Context) {
if err := mcb.Exec(ctx); err != nil { if err := _c.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }

View File

@@ -20,56 +20,56 @@ type MessagesDelete struct {
} }
// Where appends a list predicates to the MessagesDelete builder. // Where appends a list predicates to the MessagesDelete builder.
func (md *MessagesDelete) Where(ps ...predicate.Messages) *MessagesDelete { func (_d *MessagesDelete) Where(ps ...predicate.Messages) *MessagesDelete {
md.mutation.Where(ps...) _d.mutation.Where(ps...)
return md return _d
} }
// Exec executes the deletion query and returns how many vertices were deleted. // Exec executes the deletion query and returns how many vertices were deleted.
func (md *MessagesDelete) Exec(ctx context.Context) (int, error) { func (_d *MessagesDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, md.sqlExec, md.mutation, md.hooks) return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (md *MessagesDelete) ExecX(ctx context.Context) int { func (_d *MessagesDelete) ExecX(ctx context.Context) int {
n, err := md.Exec(ctx) n, err := _d.Exec(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
return n 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)) _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) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) 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) { if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
md.mutation.done = true _d.mutation.done = true
return affected, err return affected, err
} }
// MessagesDeleteOne is the builder for deleting a single Messages entity. // MessagesDeleteOne is the builder for deleting a single Messages entity.
type MessagesDeleteOne struct { type MessagesDeleteOne struct {
md *MessagesDelete _d *MessagesDelete
} }
// Where appends a list predicates to the MessagesDelete builder. // Where appends a list predicates to the MessagesDelete builder.
func (mdo *MessagesDeleteOne) Where(ps ...predicate.Messages) *MessagesDeleteOne { func (_d *MessagesDeleteOne) Where(ps ...predicate.Messages) *MessagesDeleteOne {
mdo.md.mutation.Where(ps...) _d._d.mutation.Where(ps...)
return mdo return _d
} }
// Exec executes the deletion query. // Exec executes the deletion query.
func (mdo *MessagesDeleteOne) Exec(ctx context.Context) error { func (_d *MessagesDeleteOne) Exec(ctx context.Context) error {
n, err := mdo.md.Exec(ctx) n, err := _d._d.Exec(ctx)
switch { switch {
case err != nil: case err != nil:
return err return err
@@ -81,8 +81,8 @@ func (mdo *MessagesDeleteOne) Exec(ctx context.Context) error {
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (mdo *MessagesDeleteOne) ExecX(ctx context.Context) { func (_d *MessagesDeleteOne) ExecX(ctx context.Context) {
if err := mdo.Exec(ctx); err != nil { if err := _d.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }

View File

@@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"math" "math"
"entgo.io/ent"
"entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field" "entgo.io/ent/schema/field"
@@ -31,44 +32,44 @@ type MessagesQuery struct {
} }
// Where adds a new predicate for the MessagesQuery builder. // Where adds a new predicate for the MessagesQuery builder.
func (mq *MessagesQuery) Where(ps ...predicate.Messages) *MessagesQuery { func (_q *MessagesQuery) Where(ps ...predicate.Messages) *MessagesQuery {
mq.predicates = append(mq.predicates, ps...) _q.predicates = append(_q.predicates, ps...)
return mq return _q
} }
// Limit the number of records to be returned by this query. // Limit the number of records to be returned by this query.
func (mq *MessagesQuery) Limit(limit int) *MessagesQuery { func (_q *MessagesQuery) Limit(limit int) *MessagesQuery {
mq.ctx.Limit = &limit _q.ctx.Limit = &limit
return mq return _q
} }
// Offset to start from. // Offset to start from.
func (mq *MessagesQuery) Offset(offset int) *MessagesQuery { func (_q *MessagesQuery) Offset(offset int) *MessagesQuery {
mq.ctx.Offset = &offset _q.ctx.Offset = &offset
return mq return _q
} }
// Unique configures the query builder to filter duplicate records on query. // 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. // By default, unique is set to true, and can be disabled using this method.
func (mq *MessagesQuery) Unique(unique bool) *MessagesQuery { func (_q *MessagesQuery) Unique(unique bool) *MessagesQuery {
mq.ctx.Unique = &unique _q.ctx.Unique = &unique
return mq return _q
} }
// Order specifies how the records should be ordered. // Order specifies how the records should be ordered.
func (mq *MessagesQuery) Order(o ...messages.OrderOption) *MessagesQuery { func (_q *MessagesQuery) Order(o ...messages.OrderOption) *MessagesQuery {
mq.order = append(mq.order, o...) _q.order = append(_q.order, o...)
return mq return _q
} }
// QueryMatchPlayer chains the current query on the "match_player" edge. // QueryMatchPlayer chains the current query on the "match_player" edge.
func (mq *MessagesQuery) QueryMatchPlayer() *MatchPlayerQuery { func (_q *MessagesQuery) QueryMatchPlayer() *MatchPlayerQuery {
query := (&MatchPlayerClient{config: mq.config}).Query() query := (&MatchPlayerClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { 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 return nil, err
} }
selector := mq.sqlQuery(ctx) selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return nil, err return nil, err
} }
@@ -77,7 +78,7 @@ func (mq *MessagesQuery) QueryMatchPlayer() *MatchPlayerQuery {
sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, messages.MatchPlayerTable, messages.MatchPlayerColumn), 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 fromU, nil
} }
return query return query
@@ -85,8 +86,8 @@ func (mq *MessagesQuery) QueryMatchPlayer() *MatchPlayerQuery {
// First returns the first Messages entity from the query. // First returns the first Messages entity from the query.
// Returns a *NotFoundError when no Messages was found. // Returns a *NotFoundError when no Messages was found.
func (mq *MessagesQuery) First(ctx context.Context) (*Messages, error) { func (_q *MessagesQuery) First(ctx context.Context) (*Messages, error) {
nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, "First")) nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
if err != nil { if err != nil {
return nil, err 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. // FirstX is like First, but panics if an error occurs.
func (mq *MessagesQuery) FirstX(ctx context.Context) *Messages { func (_q *MessagesQuery) FirstX(ctx context.Context) *Messages {
node, err := mq.First(ctx) node, err := _q.First(ctx)
if err != nil && !IsNotFound(err) { if err != nil && !IsNotFound(err) {
panic(err) panic(err)
} }
@@ -107,9 +108,9 @@ func (mq *MessagesQuery) FirstX(ctx context.Context) *Messages {
// FirstID returns the first Messages ID from the query. // FirstID returns the first Messages ID from the query.
// Returns a *NotFoundError when no Messages ID was found. // 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 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 return
} }
if len(ids) == 0 { 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. // FirstIDX is like FirstID, but panics if an error occurs.
func (mq *MessagesQuery) FirstIDX(ctx context.Context) int { func (_q *MessagesQuery) FirstIDX(ctx context.Context) int {
id, err := mq.FirstID(ctx) id, err := _q.FirstID(ctx)
if err != nil && !IsNotFound(err) { if err != nil && !IsNotFound(err) {
panic(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. // 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 *NotSingularError when more than one Messages entity is found.
// Returns a *NotFoundError when no Messages entities are found. // Returns a *NotFoundError when no Messages entities are found.
func (mq *MessagesQuery) Only(ctx context.Context) (*Messages, error) { func (_q *MessagesQuery) Only(ctx context.Context) (*Messages, error) {
nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, "Only")) nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
if err != nil { if err != nil {
return nil, err 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. // OnlyX is like Only, but panics if an error occurs.
func (mq *MessagesQuery) OnlyX(ctx context.Context) *Messages { func (_q *MessagesQuery) OnlyX(ctx context.Context) *Messages {
node, err := mq.Only(ctx) node, err := _q.Only(ctx)
if err != nil { if err != nil {
panic(err) 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. // 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 *NotSingularError when more than one Messages ID is found.
// Returns a *NotFoundError when no entities are 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 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 return
} }
switch len(ids) { 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. // OnlyIDX is like OnlyID, but panics if an error occurs.
func (mq *MessagesQuery) OnlyIDX(ctx context.Context) int { func (_q *MessagesQuery) OnlyIDX(ctx context.Context) int {
id, err := mq.OnlyID(ctx) id, err := _q.OnlyID(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -184,18 +185,18 @@ func (mq *MessagesQuery) OnlyIDX(ctx context.Context) int {
} }
// All executes the query and returns a list of MessagesSlice. // All executes the query and returns a list of MessagesSlice.
func (mq *MessagesQuery) All(ctx context.Context) ([]*Messages, error) { func (_q *MessagesQuery) All(ctx context.Context) ([]*Messages, error) {
ctx = setContextOp(ctx, mq.ctx, "All") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
if err := mq.prepareQuery(ctx); err != nil { if err := _q.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
qr := querierAll[[]*Messages, *MessagesQuery]() 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. // AllX is like All, but panics if an error occurs.
func (mq *MessagesQuery) AllX(ctx context.Context) []*Messages { func (_q *MessagesQuery) AllX(ctx context.Context) []*Messages {
nodes, err := mq.All(ctx) nodes, err := _q.All(ctx)
if err != nil { if err != nil {
panic(err) 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. // IDs executes the query and returns a list of Messages IDs.
func (mq *MessagesQuery) IDs(ctx context.Context) (ids []int, err error) { func (_q *MessagesQuery) IDs(ctx context.Context) (ids []int, err error) {
if mq.ctx.Unique == nil && mq.path != nil { if _q.ctx.Unique == nil && _q.path != nil {
mq.Unique(true) _q.Unique(true)
} }
ctx = setContextOp(ctx, mq.ctx, "IDs") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
if err = mq.Select(messages.FieldID).Scan(ctx, &ids); err != nil { if err = _q.Select(messages.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
return ids, nil return ids, nil
} }
// IDsX is like IDs, but panics if an error occurs. // IDsX is like IDs, but panics if an error occurs.
func (mq *MessagesQuery) IDsX(ctx context.Context) []int { func (_q *MessagesQuery) IDsX(ctx context.Context) []int {
ids, err := mq.IDs(ctx) ids, err := _q.IDs(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -224,17 +225,17 @@ func (mq *MessagesQuery) IDsX(ctx context.Context) []int {
} }
// Count returns the count of the given query. // Count returns the count of the given query.
func (mq *MessagesQuery) Count(ctx context.Context) (int, error) { func (_q *MessagesQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, mq.ctx, "Count") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
if err := mq.prepareQuery(ctx); err != nil { if err := _q.prepareQuery(ctx); err != nil {
return 0, err 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. // CountX is like Count, but panics if an error occurs.
func (mq *MessagesQuery) CountX(ctx context.Context) int { func (_q *MessagesQuery) CountX(ctx context.Context) int {
count, err := mq.Count(ctx) count, err := _q.Count(ctx)
if err != nil { if err != nil {
panic(err) 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. // Exist returns true if the query has elements in the graph.
func (mq *MessagesQuery) Exist(ctx context.Context) (bool, error) { func (_q *MessagesQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, mq.ctx, "Exist") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
switch _, err := mq.FirstID(ctx); { switch _, err := _q.FirstID(ctx); {
case IsNotFound(err): case IsNotFound(err):
return false, nil return false, nil
case err != 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. // ExistX is like Exist, but panics if an error occurs.
func (mq *MessagesQuery) ExistX(ctx context.Context) bool { func (_q *MessagesQuery) ExistX(ctx context.Context) bool {
exist, err := mq.Exist(ctx) exist, err := _q.Exist(ctx)
if err != nil { if err != nil {
panic(err) 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 // 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. // used to prepare common query builders and use them differently after the clone is made.
func (mq *MessagesQuery) Clone() *MessagesQuery { func (_q *MessagesQuery) Clone() *MessagesQuery {
if mq == nil { if _q == nil {
return nil return nil
} }
return &MessagesQuery{ return &MessagesQuery{
config: mq.config, config: _q.config,
ctx: mq.ctx.Clone(), ctx: _q.ctx.Clone(),
order: append([]messages.OrderOption{}, mq.order...), order: append([]messages.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, mq.inters...), inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.Messages{}, mq.predicates...), predicates: append([]predicate.Messages{}, _q.predicates...),
withMatchPlayer: mq.withMatchPlayer.Clone(), withMatchPlayer: _q.withMatchPlayer.Clone(),
// clone intermediate query. // clone intermediate query.
sql: mq.sql.Clone(), sql: _q.sql.Clone(),
path: mq.path, path: _q.path,
modifiers: append([]func(*sql.Selector){}, _q.modifiers...),
} }
} }
// WithMatchPlayer tells the query-builder to eager-load the nodes that are connected to // 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. // 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 { func (_q *MessagesQuery) WithMatchPlayer(opts ...func(*MatchPlayerQuery)) *MessagesQuery {
query := (&MatchPlayerClient{config: mq.config}).Query() query := (&MatchPlayerClient{config: _q.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
mq.withMatchPlayer = query _q.withMatchPlayer = query
return mq return _q
} }
// GroupBy is used to group vertices by one or more fields/columns. // 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). // GroupBy(messages.FieldMessage).
// Aggregate(ent.Count()). // Aggregate(ent.Count()).
// Scan(ctx, &v) // Scan(ctx, &v)
func (mq *MessagesQuery) GroupBy(field string, fields ...string) *MessagesGroupBy { func (_q *MessagesQuery) GroupBy(field string, fields ...string) *MessagesGroupBy {
mq.ctx.Fields = append([]string{field}, fields...) _q.ctx.Fields = append([]string{field}, fields...)
grbuild := &MessagesGroupBy{build: mq} grbuild := &MessagesGroupBy{build: _q}
grbuild.flds = &mq.ctx.Fields grbuild.flds = &_q.ctx.Fields
grbuild.label = messages.Label grbuild.label = messages.Label
grbuild.scan = grbuild.Scan grbuild.scan = grbuild.Scan
return grbuild return grbuild
@@ -328,55 +330,55 @@ func (mq *MessagesQuery) GroupBy(field string, fields ...string) *MessagesGroupB
// client.Messages.Query(). // client.Messages.Query().
// Select(messages.FieldMessage). // Select(messages.FieldMessage).
// Scan(ctx, &v) // Scan(ctx, &v)
func (mq *MessagesQuery) Select(fields ...string) *MessagesSelect { func (_q *MessagesQuery) Select(fields ...string) *MessagesSelect {
mq.ctx.Fields = append(mq.ctx.Fields, fields...) _q.ctx.Fields = append(_q.ctx.Fields, fields...)
sbuild := &MessagesSelect{MessagesQuery: mq} sbuild := &MessagesSelect{MessagesQuery: _q}
sbuild.label = messages.Label sbuild.label = messages.Label
sbuild.flds, sbuild.scan = &mq.ctx.Fields, sbuild.Scan sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
return sbuild return sbuild
} }
// Aggregate returns a MessagesSelect configured with the given aggregations. // Aggregate returns a MessagesSelect configured with the given aggregations.
func (mq *MessagesQuery) Aggregate(fns ...AggregateFunc) *MessagesSelect { func (_q *MessagesQuery) Aggregate(fns ...AggregateFunc) *MessagesSelect {
return mq.Select().Aggregate(fns...) return _q.Select().Aggregate(fns...)
} }
func (mq *MessagesQuery) prepareQuery(ctx context.Context) error { func (_q *MessagesQuery) prepareQuery(ctx context.Context) error {
for _, inter := range mq.inters { for _, inter := range _q.inters {
if inter == nil { if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
} }
if trv, ok := inter.(Traverser); ok { if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, mq); err != nil { if err := trv.Traverse(ctx, _q); err != nil {
return err return err
} }
} }
} }
for _, f := range mq.ctx.Fields { for _, f := range _q.ctx.Fields {
if !messages.ValidColumn(f) { if !messages.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
} }
} }
if mq.path != nil { if _q.path != nil {
prev, err := mq.path(ctx) prev, err := _q.path(ctx)
if err != nil { if err != nil {
return err return err
} }
mq.sql = prev _q.sql = prev
} }
return nil 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 ( var (
nodes = []*Messages{} nodes = []*Messages{}
withFKs = mq.withFKs withFKs = _q.withFKs
_spec = mq.querySpec() _spec = _q.querySpec()
loadedTypes = [1]bool{ loadedTypes = [1]bool{
mq.withMatchPlayer != nil, _q.withMatchPlayer != nil,
} }
) )
if mq.withMatchPlayer != nil { if _q.withMatchPlayer != nil {
withFKs = true withFKs = true
} }
if withFKs { if withFKs {
@@ -386,25 +388,25 @@ func (mq *MessagesQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Mes
return (*Messages).scanValues(nil, columns) return (*Messages).scanValues(nil, columns)
} }
_spec.Assign = func(columns []string, values []any) error { _spec.Assign = func(columns []string, values []any) error {
node := &Messages{config: mq.config} node := &Messages{config: _q.config}
nodes = append(nodes, node) nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values) return node.assignValues(columns, values)
} }
if len(mq.modifiers) > 0 { if len(_q.modifiers) > 0 {
_spec.Modifiers = mq.modifiers _spec.Modifiers = _q.modifiers
} }
for i := range hooks { for i := range hooks {
hooks[i](ctx, _spec) 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 return nil, err
} }
if len(nodes) == 0 { if len(nodes) == 0 {
return nodes, nil return nodes, nil
} }
if query := mq.withMatchPlayer; query != nil { if query := _q.withMatchPlayer; query != nil {
if err := mq.loadMatchPlayer(ctx, query, nodes, nil, if err := _q.loadMatchPlayer(ctx, query, nodes, nil,
func(n *Messages, e *MatchPlayer) { n.Edges.MatchPlayer = e }); err != nil { func(n *Messages, e *MatchPlayer) { n.Edges.MatchPlayer = e }); err != nil {
return nil, err return nil, err
} }
@@ -412,7 +414,7 @@ func (mq *MessagesQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Mes
return nodes, nil 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)) ids := make([]int, 0, len(nodes))
nodeids := make(map[int][]*Messages) nodeids := make(map[int][]*Messages)
for i := range nodes { for i := range nodes {
@@ -445,27 +447,27 @@ func (mq *MessagesQuery) loadMatchPlayer(ctx context.Context, query *MatchPlayer
return nil return nil
} }
func (mq *MessagesQuery) sqlCount(ctx context.Context) (int, error) { func (_q *MessagesQuery) sqlCount(ctx context.Context) (int, error) {
_spec := mq.querySpec() _spec := _q.querySpec()
if len(mq.modifiers) > 0 { if len(_q.modifiers) > 0 {
_spec.Modifiers = mq.modifiers _spec.Modifiers = _q.modifiers
} }
_spec.Node.Columns = mq.ctx.Fields _spec.Node.Columns = _q.ctx.Fields
if len(mq.ctx.Fields) > 0 { if len(_q.ctx.Fields) > 0 {
_spec.Unique = mq.ctx.Unique != nil && *mq.ctx.Unique _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 := sqlgraph.NewQuerySpec(messages.Table, messages.Columns, sqlgraph.NewFieldSpec(messages.FieldID, field.TypeInt))
_spec.From = mq.sql _spec.From = _q.sql
if unique := mq.ctx.Unique; unique != nil { if unique := _q.ctx.Unique; unique != nil {
_spec.Unique = *unique _spec.Unique = *unique
} else if mq.path != nil { } else if _q.path != nil {
_spec.Unique = true _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 = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, messages.FieldID) _spec.Node.Columns = append(_spec.Node.Columns, messages.FieldID)
for i := range fields { 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) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) ps[i](selector)
} }
} }
} }
if limit := mq.ctx.Limit; limit != nil { if limit := _q.ctx.Limit; limit != nil {
_spec.Limit = *limit _spec.Limit = *limit
} }
if offset := mq.ctx.Offset; offset != nil { if offset := _q.ctx.Offset; offset != nil {
_spec.Offset = *offset _spec.Offset = *offset
} }
if ps := mq.order; len(ps) > 0 { if ps := _q.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) { _spec.Order = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) ps[i](selector)
@@ -497,45 +499,45 @@ func (mq *MessagesQuery) querySpec() *sqlgraph.QuerySpec {
return _spec return _spec
} }
func (mq *MessagesQuery) sqlQuery(ctx context.Context) *sql.Selector { func (_q *MessagesQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(mq.driver.Dialect()) builder := sql.Dialect(_q.driver.Dialect())
t1 := builder.Table(messages.Table) t1 := builder.Table(messages.Table)
columns := mq.ctx.Fields columns := _q.ctx.Fields
if len(columns) == 0 { if len(columns) == 0 {
columns = messages.Columns columns = messages.Columns
} }
selector := builder.Select(t1.Columns(columns...)...).From(t1) selector := builder.Select(t1.Columns(columns...)...).From(t1)
if mq.sql != nil { if _q.sql != nil {
selector = mq.sql selector = _q.sql
selector.Select(selector.Columns(columns...)...) selector.Select(selector.Columns(columns...)...)
} }
if mq.ctx.Unique != nil && *mq.ctx.Unique { if _q.ctx.Unique != nil && *_q.ctx.Unique {
selector.Distinct() selector.Distinct()
} }
for _, m := range mq.modifiers { for _, m := range _q.modifiers {
m(selector) m(selector)
} }
for _, p := range mq.predicates { for _, p := range _q.predicates {
p(selector) p(selector)
} }
for _, p := range mq.order { for _, p := range _q.order {
p(selector) p(selector)
} }
if offset := mq.ctx.Offset; offset != nil { if offset := _q.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start // limit is mandatory for offset clause. We start
// with default value, and override it below if needed. // with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32) selector.Offset(*offset).Limit(math.MaxInt32)
} }
if limit := mq.ctx.Limit; limit != nil { if limit := _q.ctx.Limit; limit != nil {
selector.Limit(*limit) selector.Limit(*limit)
} }
return selector return selector
} }
// Modify adds a query modifier for attaching custom logic to queries. // Modify adds a query modifier for attaching custom logic to queries.
func (mq *MessagesQuery) Modify(modifiers ...func(s *sql.Selector)) *MessagesSelect { func (_q *MessagesQuery) Modify(modifiers ...func(s *sql.Selector)) *MessagesSelect {
mq.modifiers = append(mq.modifiers, modifiers...) _q.modifiers = append(_q.modifiers, modifiers...)
return mq.Select() return _q.Select()
} }
// MessagesGroupBy is the group-by builder for Messages entities. // 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. // Aggregate adds the given aggregation functions to the group-by query.
func (mgb *MessagesGroupBy) Aggregate(fns ...AggregateFunc) *MessagesGroupBy { func (_g *MessagesGroupBy) Aggregate(fns ...AggregateFunc) *MessagesGroupBy {
mgb.fns = append(mgb.fns, fns...) _g.fns = append(_g.fns, fns...)
return mgb return _g
} }
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (mgb *MessagesGroupBy) Scan(ctx context.Context, v any) error { func (_g *MessagesGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, mgb.build.ctx, "GroupBy") ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
if err := mgb.build.prepareQuery(ctx); err != nil { if err := _g.build.prepareQuery(ctx); err != nil {
return err 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() selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(mgb.fns)) aggregation := make([]string, 0, len(_g.fns))
for _, fn := range mgb.fns { for _, fn := range _g.fns {
aggregation = append(aggregation, fn(selector)) aggregation = append(aggregation, fn(selector))
} }
if len(selector.SelectedColumns()) == 0 { if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*mgb.flds)+len(mgb.fns)) columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
for _, f := range *mgb.flds { for _, f := range *_g.flds {
columns = append(columns, selector.C(f)) columns = append(columns, selector.C(f))
} }
columns = append(columns, aggregation...) columns = append(columns, aggregation...)
selector.Select(columns...) selector.Select(columns...)
} }
selector.GroupBy(selector.Columns(*mgb.flds...)...) selector.GroupBy(selector.Columns(*_g.flds...)...)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return err return err
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := selector.Query() 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 return err
} }
defer rows.Close() defer rows.Close()
@@ -593,27 +595,27 @@ type MessagesSelect struct {
} }
// Aggregate adds the given aggregation functions to the selector query. // Aggregate adds the given aggregation functions to the selector query.
func (ms *MessagesSelect) Aggregate(fns ...AggregateFunc) *MessagesSelect { func (_s *MessagesSelect) Aggregate(fns ...AggregateFunc) *MessagesSelect {
ms.fns = append(ms.fns, fns...) _s.fns = append(_s.fns, fns...)
return ms return _s
} }
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (ms *MessagesSelect) Scan(ctx context.Context, v any) error { func (_s *MessagesSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, ms.ctx, "Select") ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
if err := ms.prepareQuery(ctx); err != nil { if err := _s.prepareQuery(ctx); err != nil {
return err 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) selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(ms.fns)) aggregation := make([]string, 0, len(_s.fns))
for _, fn := range ms.fns { for _, fn := range _s.fns {
aggregation = append(aggregation, fn(selector)) aggregation = append(aggregation, fn(selector))
} }
switch n := len(*ms.selector.flds); { switch n := len(*_s.selector.flds); {
case n == 0 && len(aggregation) > 0: case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...) selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0: case n != 0 && len(aggregation) > 0:
@@ -621,7 +623,7 @@ func (ms *MessagesSelect) sqlScan(ctx context.Context, root *MessagesQuery, v an
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := selector.Query() 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 return err
} }
defer rows.Close() 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. // Modify adds a query modifier for attaching custom logic to queries.
func (ms *MessagesSelect) Modify(modifiers ...func(s *sql.Selector)) *MessagesSelect { func (_s *MessagesSelect) Modify(modifiers ...func(s *sql.Selector)) *MessagesSelect {
ms.modifiers = append(ms.modifiers, modifiers...) _s.modifiers = append(_s.modifiers, modifiers...)
return ms return _s
} }

View File

@@ -24,74 +24,98 @@ type MessagesUpdate struct {
} }
// Where appends a list predicates to the MessagesUpdate builder. // Where appends a list predicates to the MessagesUpdate builder.
func (mu *MessagesUpdate) Where(ps ...predicate.Messages) *MessagesUpdate { func (_u *MessagesUpdate) Where(ps ...predicate.Messages) *MessagesUpdate {
mu.mutation.Where(ps...) _u.mutation.Where(ps...)
return mu return _u
} }
// SetMessage sets the "message" field. // SetMessage sets the "message" field.
func (mu *MessagesUpdate) SetMessage(s string) *MessagesUpdate { func (_u *MessagesUpdate) SetMessage(v string) *MessagesUpdate {
mu.mutation.SetMessage(s) _u.mutation.SetMessage(v)
return mu 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. // SetAllChat sets the "all_chat" field.
func (mu *MessagesUpdate) SetAllChat(b bool) *MessagesUpdate { func (_u *MessagesUpdate) SetAllChat(v bool) *MessagesUpdate {
mu.mutation.SetAllChat(b) _u.mutation.SetAllChat(v)
return mu 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. // SetTick sets the "tick" field.
func (mu *MessagesUpdate) SetTick(i int) *MessagesUpdate { func (_u *MessagesUpdate) SetTick(v int) *MessagesUpdate {
mu.mutation.ResetTick() _u.mutation.ResetTick()
mu.mutation.SetTick(i) _u.mutation.SetTick(v)
return mu return _u
} }
// AddTick adds i to the "tick" field. // SetNillableTick sets the "tick" field if the given value is not nil.
func (mu *MessagesUpdate) AddTick(i int) *MessagesUpdate { func (_u *MessagesUpdate) SetNillableTick(v *int) *MessagesUpdate {
mu.mutation.AddTick(i) if v != nil {
return mu _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. // SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID.
func (mu *MessagesUpdate) SetMatchPlayerID(id int) *MessagesUpdate { func (_u *MessagesUpdate) SetMatchPlayerID(id int) *MessagesUpdate {
mu.mutation.SetMatchPlayerID(id) _u.mutation.SetMatchPlayerID(id)
return mu return _u
} }
// SetNillableMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID if the given value is not nil. // 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 { 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. // SetMatchPlayer sets the "match_player" edge to the MatchPlayer entity.
func (mu *MessagesUpdate) SetMatchPlayer(m *MatchPlayer) *MessagesUpdate { func (_u *MessagesUpdate) SetMatchPlayer(v *MatchPlayer) *MessagesUpdate {
return mu.SetMatchPlayerID(m.ID) return _u.SetMatchPlayerID(v.ID)
} }
// Mutation returns the MessagesMutation object of the builder. // Mutation returns the MessagesMutation object of the builder.
func (mu *MessagesUpdate) Mutation() *MessagesMutation { func (_u *MessagesUpdate) Mutation() *MessagesMutation {
return mu.mutation return _u.mutation
} }
// ClearMatchPlayer clears the "match_player" edge to the MatchPlayer entity. // ClearMatchPlayer clears the "match_player" edge to the MatchPlayer entity.
func (mu *MessagesUpdate) ClearMatchPlayer() *MessagesUpdate { func (_u *MessagesUpdate) ClearMatchPlayer() *MessagesUpdate {
mu.mutation.ClearMatchPlayer() _u.mutation.ClearMatchPlayer()
return mu return _u
} }
// Save executes the query and returns the number of nodes affected by the update operation. // Save executes the query and returns the number of nodes affected by the update operation.
func (mu *MessagesUpdate) Save(ctx context.Context) (int, error) { func (_u *MessagesUpdate) Save(ctx context.Context) (int, error) {
return withHooks(ctx, mu.sqlSave, mu.mutation, mu.hooks) return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
func (mu *MessagesUpdate) SaveX(ctx context.Context) int { func (_u *MessagesUpdate) SaveX(ctx context.Context) int {
affected, err := mu.Save(ctx) affected, err := _u.Save(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -99,46 +123,46 @@ func (mu *MessagesUpdate) SaveX(ctx context.Context) int {
} }
// Exec executes the query. // Exec executes the query.
func (mu *MessagesUpdate) Exec(ctx context.Context) error { func (_u *MessagesUpdate) Exec(ctx context.Context) error {
_, err := mu.Save(ctx) _, err := _u.Save(ctx)
return err return err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (mu *MessagesUpdate) ExecX(ctx context.Context) { func (_u *MessagesUpdate) ExecX(ctx context.Context) {
if err := mu.Exec(ctx); err != nil { if err := _u.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. // Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (mu *MessagesUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MessagesUpdate { func (_u *MessagesUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MessagesUpdate {
mu.modifiers = append(mu.modifiers, modifiers...) _u.modifiers = append(_u.modifiers, modifiers...)
return mu 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)) _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) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) ps[i](selector)
} }
} }
} }
if value, ok := mu.mutation.Message(); ok { if value, ok := _u.mutation.Message(); ok {
_spec.SetField(messages.FieldMessage, field.TypeString, value) _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) _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) _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) _spec.AddField(messages.FieldTick, field.TypeInt, value)
} }
if mu.mutation.MatchPlayerCleared() { if _u.mutation.MatchPlayerCleared() {
edge := &sqlgraph.EdgeSpec{ edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O, Rel: sqlgraph.M2O,
Inverse: true, 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) _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{ edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O, Rel: sqlgraph.M2O,
Inverse: true, 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.Edges.Add = append(_spec.Edges.Add, edge)
} }
_spec.AddModifiers(mu.modifiers...) _spec.AddModifiers(_u.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, mu.driver, _spec); err != nil { if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok { if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{messages.Label} err = &NotFoundError{messages.Label}
} else if sqlgraph.IsConstraintError(err) { } else if sqlgraph.IsConstraintError(err) {
@@ -176,8 +200,8 @@ func (mu *MessagesUpdate) sqlSave(ctx context.Context) (n int, err error) {
} }
return 0, err return 0, err
} }
mu.mutation.done = true _u.mutation.done = true
return n, nil return _node, nil
} }
// MessagesUpdateOne is the builder for updating a single Messages entity. // MessagesUpdateOne is the builder for updating a single Messages entity.
@@ -190,81 +214,105 @@ type MessagesUpdateOne struct {
} }
// SetMessage sets the "message" field. // SetMessage sets the "message" field.
func (muo *MessagesUpdateOne) SetMessage(s string) *MessagesUpdateOne { func (_u *MessagesUpdateOne) SetMessage(v string) *MessagesUpdateOne {
muo.mutation.SetMessage(s) _u.mutation.SetMessage(v)
return muo 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. // SetAllChat sets the "all_chat" field.
func (muo *MessagesUpdateOne) SetAllChat(b bool) *MessagesUpdateOne { func (_u *MessagesUpdateOne) SetAllChat(v bool) *MessagesUpdateOne {
muo.mutation.SetAllChat(b) _u.mutation.SetAllChat(v)
return muo 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. // SetTick sets the "tick" field.
func (muo *MessagesUpdateOne) SetTick(i int) *MessagesUpdateOne { func (_u *MessagesUpdateOne) SetTick(v int) *MessagesUpdateOne {
muo.mutation.ResetTick() _u.mutation.ResetTick()
muo.mutation.SetTick(i) _u.mutation.SetTick(v)
return muo return _u
} }
// AddTick adds i to the "tick" field. // SetNillableTick sets the "tick" field if the given value is not nil.
func (muo *MessagesUpdateOne) AddTick(i int) *MessagesUpdateOne { func (_u *MessagesUpdateOne) SetNillableTick(v *int) *MessagesUpdateOne {
muo.mutation.AddTick(i) if v != nil {
return muo _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. // SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID.
func (muo *MessagesUpdateOne) SetMatchPlayerID(id int) *MessagesUpdateOne { func (_u *MessagesUpdateOne) SetMatchPlayerID(id int) *MessagesUpdateOne {
muo.mutation.SetMatchPlayerID(id) _u.mutation.SetMatchPlayerID(id)
return muo return _u
} }
// SetNillableMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID if the given value is not nil. // 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 { 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. // SetMatchPlayer sets the "match_player" edge to the MatchPlayer entity.
func (muo *MessagesUpdateOne) SetMatchPlayer(m *MatchPlayer) *MessagesUpdateOne { func (_u *MessagesUpdateOne) SetMatchPlayer(v *MatchPlayer) *MessagesUpdateOne {
return muo.SetMatchPlayerID(m.ID) return _u.SetMatchPlayerID(v.ID)
} }
// Mutation returns the MessagesMutation object of the builder. // Mutation returns the MessagesMutation object of the builder.
func (muo *MessagesUpdateOne) Mutation() *MessagesMutation { func (_u *MessagesUpdateOne) Mutation() *MessagesMutation {
return muo.mutation return _u.mutation
} }
// ClearMatchPlayer clears the "match_player" edge to the MatchPlayer entity. // ClearMatchPlayer clears the "match_player" edge to the MatchPlayer entity.
func (muo *MessagesUpdateOne) ClearMatchPlayer() *MessagesUpdateOne { func (_u *MessagesUpdateOne) ClearMatchPlayer() *MessagesUpdateOne {
muo.mutation.ClearMatchPlayer() _u.mutation.ClearMatchPlayer()
return muo return _u
} }
// Where appends a list predicates to the MessagesUpdate builder. // Where appends a list predicates to the MessagesUpdate builder.
func (muo *MessagesUpdateOne) Where(ps ...predicate.Messages) *MessagesUpdateOne { func (_u *MessagesUpdateOne) Where(ps ...predicate.Messages) *MessagesUpdateOne {
muo.mutation.Where(ps...) _u.mutation.Where(ps...)
return muo return _u
} }
// Select allows selecting one or more fields (columns) of the returned entity. // Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema. // The default is selecting all fields defined in the entity schema.
func (muo *MessagesUpdateOne) Select(field string, fields ...string) *MessagesUpdateOne { func (_u *MessagesUpdateOne) Select(field string, fields ...string) *MessagesUpdateOne {
muo.fields = append([]string{field}, fields...) _u.fields = append([]string{field}, fields...)
return muo return _u
} }
// Save executes the query and returns the updated Messages entity. // Save executes the query and returns the updated Messages entity.
func (muo *MessagesUpdateOne) Save(ctx context.Context) (*Messages, error) { func (_u *MessagesUpdateOne) Save(ctx context.Context) (*Messages, error) {
return withHooks(ctx, muo.sqlSave, muo.mutation, muo.hooks) return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
func (muo *MessagesUpdateOne) SaveX(ctx context.Context) *Messages { func (_u *MessagesUpdateOne) SaveX(ctx context.Context) *Messages {
node, err := muo.Save(ctx) node, err := _u.Save(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -272,32 +320,32 @@ func (muo *MessagesUpdateOne) SaveX(ctx context.Context) *Messages {
} }
// Exec executes the query on the entity. // Exec executes the query on the entity.
func (muo *MessagesUpdateOne) Exec(ctx context.Context) error { func (_u *MessagesUpdateOne) Exec(ctx context.Context) error {
_, err := muo.Save(ctx) _, err := _u.Save(ctx)
return err return err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (muo *MessagesUpdateOne) ExecX(ctx context.Context) { func (_u *MessagesUpdateOne) ExecX(ctx context.Context) {
if err := muo.Exec(ctx); err != nil { if err := _u.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. // Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (muo *MessagesUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MessagesUpdateOne { func (_u *MessagesUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MessagesUpdateOne {
muo.modifiers = append(muo.modifiers, modifiers...) _u.modifiers = append(_u.modifiers, modifiers...)
return muo 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)) _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 { if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Messages.id" for update`)} return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Messages.id" for update`)}
} }
_spec.Node.ID.Value = id _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 = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, messages.FieldID) _spec.Node.Columns = append(_spec.Node.Columns, messages.FieldID)
for _, f := range fields { 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) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) ps[i](selector)
} }
} }
} }
if value, ok := muo.mutation.Message(); ok { if value, ok := _u.mutation.Message(); ok {
_spec.SetField(messages.FieldMessage, field.TypeString, value) _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) _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) _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) _spec.AddField(messages.FieldTick, field.TypeInt, value)
} }
if muo.mutation.MatchPlayerCleared() { if _u.mutation.MatchPlayerCleared() {
edge := &sqlgraph.EdgeSpec{ edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O, Rel: sqlgraph.M2O,
Inverse: true, Inverse: true,
@@ -341,7 +389,7 @@ func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err
} }
_spec.Edges.Clear = append(_spec.Edges.Clear, edge) _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{ edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O, Rel: sqlgraph.M2O,
Inverse: true, 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.Edges.Add = append(_spec.Edges.Add, edge)
} }
_spec.AddModifiers(muo.modifiers...) _spec.AddModifiers(_u.modifiers...)
_node = &Messages{config: muo.config} _node = &Messages{config: _u.config}
_spec.Assign = _node.assignValues _spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues _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 { if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{messages.Label} err = &NotFoundError{messages.Label}
} else if sqlgraph.IsConstraintError(err) { } else if sqlgraph.IsConstraintError(err) {
@@ -369,6 +417,6 @@ func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err
} }
return nil, err return nil, err
} }
muo.mutation.done = true _u.mutation.done = true
return _node, nil return _node, nil
} }

View File

@@ -3852,6 +3852,7 @@ func (m *MatchPlayerMutation) SetMatchesID(id uint64) {
// ClearMatches clears the "matches" edge to the Match entity. // ClearMatches clears the "matches" edge to the Match entity.
func (m *MatchPlayerMutation) ClearMatches() { func (m *MatchPlayerMutation) ClearMatches() {
m.clearedmatches = true m.clearedmatches = true
m.clearedFields[matchplayer.FieldMatchStats] = struct{}{}
} }
// MatchesCleared reports if the "matches" edge to the Match entity was cleared. // 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. // ClearPlayers clears the "players" edge to the Player entity.
func (m *MatchPlayerMutation) ClearPlayers() { func (m *MatchPlayerMutation) ClearPlayers() {
m.clearedplayers = true m.clearedplayers = true
m.clearedFields[matchplayer.FieldPlayerStats] = struct{}{}
} }
// PlayersCleared reports if the "players" edge to the Player entity was cleared. // PlayersCleared reports if the "players" edge to the Player entity was cleared.

View File

@@ -104,7 +104,7 @@ func (*Player) scanValues(columns []string) ([]any, error) {
// assignValues assigns the values that were returned from sql.Rows (after scanning) // assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Player fields. // 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 { if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", 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 { if !ok {
return fmt.Errorf("unexpected type %T for field id", value) return fmt.Errorf("unexpected type %T for field id", value)
} }
pl.ID = uint64(value.Int64) _m.ID = uint64(value.Int64)
case player.FieldName: case player.FieldName:
if value, ok := values[i].(*sql.NullString); !ok { if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field name", values[i]) return fmt.Errorf("unexpected type %T for field name", values[i])
} else if value.Valid { } else if value.Valid {
pl.Name = value.String _m.Name = value.String
} }
case player.FieldAvatar: case player.FieldAvatar:
if value, ok := values[i].(*sql.NullString); !ok { if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field avatar", values[i]) return fmt.Errorf("unexpected type %T for field avatar", values[i])
} else if value.Valid { } else if value.Valid {
pl.Avatar = value.String _m.Avatar = value.String
} }
case player.FieldVanityURL: case player.FieldVanityURL:
if value, ok := values[i].(*sql.NullString); !ok { if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field vanity_url", values[i]) return fmt.Errorf("unexpected type %T for field vanity_url", values[i])
} else if value.Valid { } else if value.Valid {
pl.VanityURL = value.String _m.VanityURL = value.String
} }
case player.FieldVanityURLReal: case player.FieldVanityURLReal:
if value, ok := values[i].(*sql.NullString); !ok { if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field vanity_url_real", values[i]) return fmt.Errorf("unexpected type %T for field vanity_url_real", values[i])
} else if value.Valid { } else if value.Valid {
pl.VanityURLReal = value.String _m.VanityURLReal = value.String
} }
case player.FieldVacDate: case player.FieldVacDate:
if value, ok := values[i].(*sql.NullTime); !ok { if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field vac_date", values[i]) return fmt.Errorf("unexpected type %T for field vac_date", values[i])
} else if value.Valid { } else if value.Valid {
pl.VacDate = value.Time _m.VacDate = value.Time
} }
case player.FieldVacCount: case player.FieldVacCount:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field vac_count", values[i]) return fmt.Errorf("unexpected type %T for field vac_count", values[i])
} else if value.Valid { } else if value.Valid {
pl.VacCount = int(value.Int64) _m.VacCount = int(value.Int64)
} }
case player.FieldGameBanDate: case player.FieldGameBanDate:
if value, ok := values[i].(*sql.NullTime); !ok { if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field game_ban_date", values[i]) return fmt.Errorf("unexpected type %T for field game_ban_date", values[i])
} else if value.Valid { } else if value.Valid {
pl.GameBanDate = value.Time _m.GameBanDate = value.Time
} }
case player.FieldGameBanCount: case player.FieldGameBanCount:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field game_ban_count", values[i]) return fmt.Errorf("unexpected type %T for field game_ban_count", values[i])
} else if value.Valid { } else if value.Valid {
pl.GameBanCount = int(value.Int64) _m.GameBanCount = int(value.Int64)
} }
case player.FieldSteamUpdated: case player.FieldSteamUpdated:
if value, ok := values[i].(*sql.NullTime); !ok { if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field steam_updated", values[i]) return fmt.Errorf("unexpected type %T for field steam_updated", values[i])
} else if value.Valid { } else if value.Valid {
pl.SteamUpdated = value.Time _m.SteamUpdated = value.Time
} }
case player.FieldSharecodeUpdated: case player.FieldSharecodeUpdated:
if value, ok := values[i].(*sql.NullTime); !ok { if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field sharecode_updated", values[i]) return fmt.Errorf("unexpected type %T for field sharecode_updated", values[i])
} else if value.Valid { } else if value.Valid {
pl.SharecodeUpdated = value.Time _m.SharecodeUpdated = value.Time
} }
case player.FieldAuthCode: case player.FieldAuthCode:
if value, ok := values[i].(*sql.NullString); !ok { if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field auth_code", values[i]) return fmt.Errorf("unexpected type %T for field auth_code", values[i])
} else if value.Valid { } else if value.Valid {
pl.AuthCode = value.String _m.AuthCode = value.String
} }
case player.FieldProfileCreated: case player.FieldProfileCreated:
if value, ok := values[i].(*sql.NullTime); !ok { if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field profile_created", values[i]) return fmt.Errorf("unexpected type %T for field profile_created", values[i])
} else if value.Valid { } else if value.Valid {
pl.ProfileCreated = value.Time _m.ProfileCreated = value.Time
} }
case player.FieldOldestSharecodeSeen: case player.FieldOldestSharecodeSeen:
if value, ok := values[i].(*sql.NullString); !ok { if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field oldest_sharecode_seen", values[i]) return fmt.Errorf("unexpected type %T for field oldest_sharecode_seen", values[i])
} else if value.Valid { } else if value.Valid {
pl.OldestSharecodeSeen = value.String _m.OldestSharecodeSeen = value.String
} }
case player.FieldWins: case player.FieldWins:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field wins", values[i]) return fmt.Errorf("unexpected type %T for field wins", values[i])
} else if value.Valid { } else if value.Valid {
pl.Wins = int(value.Int64) _m.Wins = int(value.Int64)
} }
case player.FieldLooses: case player.FieldLooses:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field looses", values[i]) return fmt.Errorf("unexpected type %T for field looses", values[i])
} else if value.Valid { } else if value.Valid {
pl.Looses = int(value.Int64) _m.Looses = int(value.Int64)
} }
case player.FieldTies: case player.FieldTies:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field ties", values[i]) return fmt.Errorf("unexpected type %T for field ties", values[i])
} else if value.Valid { } else if value.Valid {
pl.Ties = int(value.Int64) _m.Ties = int(value.Int64)
} }
default: default:
pl.selectValues.Set(columns[i], values[i]) _m.selectValues.Set(columns[i], values[i])
} }
} }
return nil 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. // Value returns the ent.Value that was dynamically selected and assigned to the Player.
// This includes values selected through modifiers, order, etc. // This includes values selected through modifiers, order, etc.
func (pl *Player) Value(name string) (ent.Value, error) { func (_m *Player) Value(name string) (ent.Value, error) {
return pl.selectValues.Get(name) return _m.selectValues.Get(name)
} }
// QueryStats queries the "stats" edge of the Player entity. // QueryStats queries the "stats" edge of the Player entity.
func (pl *Player) QueryStats() *MatchPlayerQuery { func (_m *Player) QueryStats() *MatchPlayerQuery {
return NewPlayerClient(pl.config).QueryStats(pl) return NewPlayerClient(_m.config).QueryStats(_m)
} }
// QueryMatches queries the "matches" edge of the Player entity. // QueryMatches queries the "matches" edge of the Player entity.
func (pl *Player) QueryMatches() *MatchQuery { func (_m *Player) QueryMatches() *MatchQuery {
return NewPlayerClient(pl.config).QueryMatches(pl) return NewPlayerClient(_m.config).QueryMatches(_m)
} }
// Update returns a builder for updating this Player. // Update returns a builder for updating this Player.
// Note that you need to call Player.Unwrap() before calling this method if 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. // was returned from a transaction, and the transaction was committed or rolled back.
func (pl *Player) Update() *PlayerUpdateOne { func (_m *Player) Update() *PlayerUpdateOne {
return NewPlayerClient(pl.config).UpdateOne(pl) return NewPlayerClient(_m.config).UpdateOne(_m)
} }
// Unwrap unwraps the Player entity that was returned from a transaction after it was closed, // 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. // so that all future queries will be executed through the driver which created the transaction.
func (pl *Player) Unwrap() *Player { func (_m *Player) Unwrap() *Player {
_tx, ok := pl.config.driver.(*txDriver) _tx, ok := _m.config.driver.(*txDriver)
if !ok { if !ok {
panic("ent: Player is not a transactional entity") panic("ent: Player is not a transactional entity")
} }
pl.config.driver = _tx.drv _m.config.driver = _tx.drv
return pl return _m
} }
// String implements the fmt.Stringer. // String implements the fmt.Stringer.
func (pl *Player) String() string { func (_m *Player) String() string {
var builder strings.Builder var builder strings.Builder
builder.WriteString("Player(") builder.WriteString("Player(")
builder.WriteString(fmt.Sprintf("id=%v, ", pl.ID)) builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("name=") builder.WriteString("name=")
builder.WriteString(pl.Name) builder.WriteString(_m.Name)
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("avatar=") builder.WriteString("avatar=")
builder.WriteString(pl.Avatar) builder.WriteString(_m.Avatar)
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("vanity_url=") builder.WriteString("vanity_url=")
builder.WriteString(pl.VanityURL) builder.WriteString(_m.VanityURL)
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("vanity_url_real=") builder.WriteString("vanity_url_real=")
builder.WriteString(pl.VanityURLReal) builder.WriteString(_m.VanityURLReal)
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("vac_date=") builder.WriteString("vac_date=")
builder.WriteString(pl.VacDate.Format(time.ANSIC)) builder.WriteString(_m.VacDate.Format(time.ANSIC))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("vac_count=") builder.WriteString("vac_count=")
builder.WriteString(fmt.Sprintf("%v", pl.VacCount)) builder.WriteString(fmt.Sprintf("%v", _m.VacCount))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("game_ban_date=") builder.WriteString("game_ban_date=")
builder.WriteString(pl.GameBanDate.Format(time.ANSIC)) builder.WriteString(_m.GameBanDate.Format(time.ANSIC))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("game_ban_count=") builder.WriteString("game_ban_count=")
builder.WriteString(fmt.Sprintf("%v", pl.GameBanCount)) builder.WriteString(fmt.Sprintf("%v", _m.GameBanCount))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("steam_updated=") builder.WriteString("steam_updated=")
builder.WriteString(pl.SteamUpdated.Format(time.ANSIC)) builder.WriteString(_m.SteamUpdated.Format(time.ANSIC))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("sharecode_updated=") builder.WriteString("sharecode_updated=")
builder.WriteString(pl.SharecodeUpdated.Format(time.ANSIC)) builder.WriteString(_m.SharecodeUpdated.Format(time.ANSIC))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("auth_code=<sensitive>") builder.WriteString("auth_code=<sensitive>")
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("profile_created=") builder.WriteString("profile_created=")
builder.WriteString(pl.ProfileCreated.Format(time.ANSIC)) builder.WriteString(_m.ProfileCreated.Format(time.ANSIC))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("oldest_sharecode_seen=") builder.WriteString("oldest_sharecode_seen=")
builder.WriteString(pl.OldestSharecodeSeen) builder.WriteString(_m.OldestSharecodeSeen)
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("wins=") builder.WriteString("wins=")
builder.WriteString(fmt.Sprintf("%v", pl.Wins)) builder.WriteString(fmt.Sprintf("%v", _m.Wins))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("looses=") builder.WriteString("looses=")
builder.WriteString(fmt.Sprintf("%v", pl.Looses)) builder.WriteString(fmt.Sprintf("%v", _m.Looses))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("ties=") builder.WriteString("ties=")
builder.WriteString(fmt.Sprintf("%v", pl.Ties)) builder.WriteString(fmt.Sprintf("%v", _m.Ties))
builder.WriteByte(')') builder.WriteByte(')')
return builder.String() return builder.String()
} }

View File

@@ -1123,32 +1123,15 @@ func HasMatchesWith(preds ...predicate.Match) predicate.Player {
// And groups predicates with the AND operator between them. // And groups predicates with the AND operator between them.
func And(predicates ...predicate.Player) predicate.Player { func And(predicates ...predicate.Player) predicate.Player {
return predicate.Player(func(s *sql.Selector) { return predicate.Player(sql.AndPredicates(predicates...))
s1 := s.Clone().SetP(nil)
for _, p := range predicates {
p(s1)
}
s.Where(s1.P())
})
} }
// Or groups predicates with the OR operator between them. // Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.Player) predicate.Player { func Or(predicates ...predicate.Player) predicate.Player {
return predicate.Player(func(s *sql.Selector) { return predicate.Player(sql.OrPredicates(predicates...))
s1 := s.Clone().SetP(nil)
for i, p := range predicates {
if i > 0 {
s1.Or()
}
p(s1)
}
s.Where(s1.P())
})
} }
// Not applies the not operator on the given predicate. // Not applies the not operator on the given predicate.
func Not(p predicate.Player) predicate.Player { func Not(p predicate.Player) predicate.Player {
return predicate.Player(func(s *sql.Selector) { return predicate.Player(sql.NotPredicates(p))
p(s.Not())
})
} }

View File

@@ -23,279 +23,279 @@ type PlayerCreate struct {
} }
// SetName sets the "name" field. // SetName sets the "name" field.
func (pc *PlayerCreate) SetName(s string) *PlayerCreate { func (_c *PlayerCreate) SetName(v string) *PlayerCreate {
pc.mutation.SetName(s) _c.mutation.SetName(v)
return pc return _c
} }
// SetNillableName sets the "name" field if the given value is not nil. // SetNillableName sets the "name" field if the given value is not nil.
func (pc *PlayerCreate) SetNillableName(s *string) *PlayerCreate { func (_c *PlayerCreate) SetNillableName(v *string) *PlayerCreate {
if s != nil { if v != nil {
pc.SetName(*s) _c.SetName(*v)
} }
return pc return _c
} }
// SetAvatar sets the "avatar" field. // SetAvatar sets the "avatar" field.
func (pc *PlayerCreate) SetAvatar(s string) *PlayerCreate { func (_c *PlayerCreate) SetAvatar(v string) *PlayerCreate {
pc.mutation.SetAvatar(s) _c.mutation.SetAvatar(v)
return pc return _c
} }
// SetNillableAvatar sets the "avatar" field if the given value is not nil. // SetNillableAvatar sets the "avatar" field if the given value is not nil.
func (pc *PlayerCreate) SetNillableAvatar(s *string) *PlayerCreate { func (_c *PlayerCreate) SetNillableAvatar(v *string) *PlayerCreate {
if s != nil { if v != nil {
pc.SetAvatar(*s) _c.SetAvatar(*v)
} }
return pc return _c
} }
// SetVanityURL sets the "vanity_url" field. // SetVanityURL sets the "vanity_url" field.
func (pc *PlayerCreate) SetVanityURL(s string) *PlayerCreate { func (_c *PlayerCreate) SetVanityURL(v string) *PlayerCreate {
pc.mutation.SetVanityURL(s) _c.mutation.SetVanityURL(v)
return pc return _c
} }
// SetNillableVanityURL sets the "vanity_url" field if the given value is not nil. // SetNillableVanityURL sets the "vanity_url" field if the given value is not nil.
func (pc *PlayerCreate) SetNillableVanityURL(s *string) *PlayerCreate { func (_c *PlayerCreate) SetNillableVanityURL(v *string) *PlayerCreate {
if s != nil { if v != nil {
pc.SetVanityURL(*s) _c.SetVanityURL(*v)
} }
return pc return _c
} }
// SetVanityURLReal sets the "vanity_url_real" field. // SetVanityURLReal sets the "vanity_url_real" field.
func (pc *PlayerCreate) SetVanityURLReal(s string) *PlayerCreate { func (_c *PlayerCreate) SetVanityURLReal(v string) *PlayerCreate {
pc.mutation.SetVanityURLReal(s) _c.mutation.SetVanityURLReal(v)
return pc return _c
} }
// SetNillableVanityURLReal sets the "vanity_url_real" field if the given value is not nil. // SetNillableVanityURLReal sets the "vanity_url_real" field if the given value is not nil.
func (pc *PlayerCreate) SetNillableVanityURLReal(s *string) *PlayerCreate { func (_c *PlayerCreate) SetNillableVanityURLReal(v *string) *PlayerCreate {
if s != nil { if v != nil {
pc.SetVanityURLReal(*s) _c.SetVanityURLReal(*v)
} }
return pc return _c
} }
// SetVacDate sets the "vac_date" field. // SetVacDate sets the "vac_date" field.
func (pc *PlayerCreate) SetVacDate(t time.Time) *PlayerCreate { func (_c *PlayerCreate) SetVacDate(v time.Time) *PlayerCreate {
pc.mutation.SetVacDate(t) _c.mutation.SetVacDate(v)
return pc return _c
} }
// SetNillableVacDate sets the "vac_date" field if the given value is not nil. // SetNillableVacDate sets the "vac_date" field if the given value is not nil.
func (pc *PlayerCreate) SetNillableVacDate(t *time.Time) *PlayerCreate { func (_c *PlayerCreate) SetNillableVacDate(v *time.Time) *PlayerCreate {
if t != nil { if v != nil {
pc.SetVacDate(*t) _c.SetVacDate(*v)
} }
return pc return _c
} }
// SetVacCount sets the "vac_count" field. // SetVacCount sets the "vac_count" field.
func (pc *PlayerCreate) SetVacCount(i int) *PlayerCreate { func (_c *PlayerCreate) SetVacCount(v int) *PlayerCreate {
pc.mutation.SetVacCount(i) _c.mutation.SetVacCount(v)
return pc return _c
} }
// SetNillableVacCount sets the "vac_count" field if the given value is not nil. // SetNillableVacCount sets the "vac_count" field if the given value is not nil.
func (pc *PlayerCreate) SetNillableVacCount(i *int) *PlayerCreate { func (_c *PlayerCreate) SetNillableVacCount(v *int) *PlayerCreate {
if i != nil { if v != nil {
pc.SetVacCount(*i) _c.SetVacCount(*v)
} }
return pc return _c
} }
// SetGameBanDate sets the "game_ban_date" field. // SetGameBanDate sets the "game_ban_date" field.
func (pc *PlayerCreate) SetGameBanDate(t time.Time) *PlayerCreate { func (_c *PlayerCreate) SetGameBanDate(v time.Time) *PlayerCreate {
pc.mutation.SetGameBanDate(t) _c.mutation.SetGameBanDate(v)
return pc return _c
} }
// SetNillableGameBanDate sets the "game_ban_date" field if the given value is not nil. // SetNillableGameBanDate sets the "game_ban_date" field if the given value is not nil.
func (pc *PlayerCreate) SetNillableGameBanDate(t *time.Time) *PlayerCreate { func (_c *PlayerCreate) SetNillableGameBanDate(v *time.Time) *PlayerCreate {
if t != nil { if v != nil {
pc.SetGameBanDate(*t) _c.SetGameBanDate(*v)
} }
return pc return _c
} }
// SetGameBanCount sets the "game_ban_count" field. // SetGameBanCount sets the "game_ban_count" field.
func (pc *PlayerCreate) SetGameBanCount(i int) *PlayerCreate { func (_c *PlayerCreate) SetGameBanCount(v int) *PlayerCreate {
pc.mutation.SetGameBanCount(i) _c.mutation.SetGameBanCount(v)
return pc return _c
} }
// SetNillableGameBanCount sets the "game_ban_count" field if the given value is not nil. // SetNillableGameBanCount sets the "game_ban_count" field if the given value is not nil.
func (pc *PlayerCreate) SetNillableGameBanCount(i *int) *PlayerCreate { func (_c *PlayerCreate) SetNillableGameBanCount(v *int) *PlayerCreate {
if i != nil { if v != nil {
pc.SetGameBanCount(*i) _c.SetGameBanCount(*v)
} }
return pc return _c
} }
// SetSteamUpdated sets the "steam_updated" field. // SetSteamUpdated sets the "steam_updated" field.
func (pc *PlayerCreate) SetSteamUpdated(t time.Time) *PlayerCreate { func (_c *PlayerCreate) SetSteamUpdated(v time.Time) *PlayerCreate {
pc.mutation.SetSteamUpdated(t) _c.mutation.SetSteamUpdated(v)
return pc return _c
} }
// SetNillableSteamUpdated sets the "steam_updated" field if the given value is not nil. // SetNillableSteamUpdated sets the "steam_updated" field if the given value is not nil.
func (pc *PlayerCreate) SetNillableSteamUpdated(t *time.Time) *PlayerCreate { func (_c *PlayerCreate) SetNillableSteamUpdated(v *time.Time) *PlayerCreate {
if t != nil { if v != nil {
pc.SetSteamUpdated(*t) _c.SetSteamUpdated(*v)
} }
return pc return _c
} }
// SetSharecodeUpdated sets the "sharecode_updated" field. // SetSharecodeUpdated sets the "sharecode_updated" field.
func (pc *PlayerCreate) SetSharecodeUpdated(t time.Time) *PlayerCreate { func (_c *PlayerCreate) SetSharecodeUpdated(v time.Time) *PlayerCreate {
pc.mutation.SetSharecodeUpdated(t) _c.mutation.SetSharecodeUpdated(v)
return pc return _c
} }
// SetNillableSharecodeUpdated sets the "sharecode_updated" field if the given value is not nil. // SetNillableSharecodeUpdated sets the "sharecode_updated" field if the given value is not nil.
func (pc *PlayerCreate) SetNillableSharecodeUpdated(t *time.Time) *PlayerCreate { func (_c *PlayerCreate) SetNillableSharecodeUpdated(v *time.Time) *PlayerCreate {
if t != nil { if v != nil {
pc.SetSharecodeUpdated(*t) _c.SetSharecodeUpdated(*v)
} }
return pc return _c
} }
// SetAuthCode sets the "auth_code" field. // SetAuthCode sets the "auth_code" field.
func (pc *PlayerCreate) SetAuthCode(s string) *PlayerCreate { func (_c *PlayerCreate) SetAuthCode(v string) *PlayerCreate {
pc.mutation.SetAuthCode(s) _c.mutation.SetAuthCode(v)
return pc return _c
} }
// SetNillableAuthCode sets the "auth_code" field if the given value is not nil. // SetNillableAuthCode sets the "auth_code" field if the given value is not nil.
func (pc *PlayerCreate) SetNillableAuthCode(s *string) *PlayerCreate { func (_c *PlayerCreate) SetNillableAuthCode(v *string) *PlayerCreate {
if s != nil { if v != nil {
pc.SetAuthCode(*s) _c.SetAuthCode(*v)
} }
return pc return _c
} }
// SetProfileCreated sets the "profile_created" field. // SetProfileCreated sets the "profile_created" field.
func (pc *PlayerCreate) SetProfileCreated(t time.Time) *PlayerCreate { func (_c *PlayerCreate) SetProfileCreated(v time.Time) *PlayerCreate {
pc.mutation.SetProfileCreated(t) _c.mutation.SetProfileCreated(v)
return pc return _c
} }
// SetNillableProfileCreated sets the "profile_created" field if the given value is not nil. // SetNillableProfileCreated sets the "profile_created" field if the given value is not nil.
func (pc *PlayerCreate) SetNillableProfileCreated(t *time.Time) *PlayerCreate { func (_c *PlayerCreate) SetNillableProfileCreated(v *time.Time) *PlayerCreate {
if t != nil { if v != nil {
pc.SetProfileCreated(*t) _c.SetProfileCreated(*v)
} }
return pc return _c
} }
// SetOldestSharecodeSeen sets the "oldest_sharecode_seen" field. // SetOldestSharecodeSeen sets the "oldest_sharecode_seen" field.
func (pc *PlayerCreate) SetOldestSharecodeSeen(s string) *PlayerCreate { func (_c *PlayerCreate) SetOldestSharecodeSeen(v string) *PlayerCreate {
pc.mutation.SetOldestSharecodeSeen(s) _c.mutation.SetOldestSharecodeSeen(v)
return pc return _c
} }
// SetNillableOldestSharecodeSeen sets the "oldest_sharecode_seen" field if the given value is not nil. // SetNillableOldestSharecodeSeen sets the "oldest_sharecode_seen" field if the given value is not nil.
func (pc *PlayerCreate) SetNillableOldestSharecodeSeen(s *string) *PlayerCreate { func (_c *PlayerCreate) SetNillableOldestSharecodeSeen(v *string) *PlayerCreate {
if s != nil { if v != nil {
pc.SetOldestSharecodeSeen(*s) _c.SetOldestSharecodeSeen(*v)
} }
return pc return _c
} }
// SetWins sets the "wins" field. // SetWins sets the "wins" field.
func (pc *PlayerCreate) SetWins(i int) *PlayerCreate { func (_c *PlayerCreate) SetWins(v int) *PlayerCreate {
pc.mutation.SetWins(i) _c.mutation.SetWins(v)
return pc return _c
} }
// SetNillableWins sets the "wins" field if the given value is not nil. // SetNillableWins sets the "wins" field if the given value is not nil.
func (pc *PlayerCreate) SetNillableWins(i *int) *PlayerCreate { func (_c *PlayerCreate) SetNillableWins(v *int) *PlayerCreate {
if i != nil { if v != nil {
pc.SetWins(*i) _c.SetWins(*v)
} }
return pc return _c
} }
// SetLooses sets the "looses" field. // SetLooses sets the "looses" field.
func (pc *PlayerCreate) SetLooses(i int) *PlayerCreate { func (_c *PlayerCreate) SetLooses(v int) *PlayerCreate {
pc.mutation.SetLooses(i) _c.mutation.SetLooses(v)
return pc return _c
} }
// SetNillableLooses sets the "looses" field if the given value is not nil. // SetNillableLooses sets the "looses" field if the given value is not nil.
func (pc *PlayerCreate) SetNillableLooses(i *int) *PlayerCreate { func (_c *PlayerCreate) SetNillableLooses(v *int) *PlayerCreate {
if i != nil { if v != nil {
pc.SetLooses(*i) _c.SetLooses(*v)
} }
return pc return _c
} }
// SetTies sets the "ties" field. // SetTies sets the "ties" field.
func (pc *PlayerCreate) SetTies(i int) *PlayerCreate { func (_c *PlayerCreate) SetTies(v int) *PlayerCreate {
pc.mutation.SetTies(i) _c.mutation.SetTies(v)
return pc return _c
} }
// SetNillableTies sets the "ties" field if the given value is not nil. // SetNillableTies sets the "ties" field if the given value is not nil.
func (pc *PlayerCreate) SetNillableTies(i *int) *PlayerCreate { func (_c *PlayerCreate) SetNillableTies(v *int) *PlayerCreate {
if i != nil { if v != nil {
pc.SetTies(*i) _c.SetTies(*v)
} }
return pc return _c
} }
// SetID sets the "id" field. // SetID sets the "id" field.
func (pc *PlayerCreate) SetID(u uint64) *PlayerCreate { func (_c *PlayerCreate) SetID(v uint64) *PlayerCreate {
pc.mutation.SetID(u) _c.mutation.SetID(v)
return pc return _c
} }
// AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs. // AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs.
func (pc *PlayerCreate) AddStatIDs(ids ...int) *PlayerCreate { func (_c *PlayerCreate) AddStatIDs(ids ...int) *PlayerCreate {
pc.mutation.AddStatIDs(ids...) _c.mutation.AddStatIDs(ids...)
return pc return _c
} }
// AddStats adds the "stats" edges to the MatchPlayer entity. // AddStats adds the "stats" edges to the MatchPlayer entity.
func (pc *PlayerCreate) AddStats(m ...*MatchPlayer) *PlayerCreate { func (_c *PlayerCreate) AddStats(v ...*MatchPlayer) *PlayerCreate {
ids := make([]int, len(m)) ids := make([]int, len(v))
for i := range m { for i := range v {
ids[i] = m[i].ID ids[i] = v[i].ID
} }
return pc.AddStatIDs(ids...) return _c.AddStatIDs(ids...)
} }
// AddMatchIDs adds the "matches" edge to the Match entity by IDs. // AddMatchIDs adds the "matches" edge to the Match entity by IDs.
func (pc *PlayerCreate) AddMatchIDs(ids ...uint64) *PlayerCreate { func (_c *PlayerCreate) AddMatchIDs(ids ...uint64) *PlayerCreate {
pc.mutation.AddMatchIDs(ids...) _c.mutation.AddMatchIDs(ids...)
return pc return _c
} }
// AddMatches adds the "matches" edges to the Match entity. // AddMatches adds the "matches" edges to the Match entity.
func (pc *PlayerCreate) AddMatches(m ...*Match) *PlayerCreate { func (_c *PlayerCreate) AddMatches(v ...*Match) *PlayerCreate {
ids := make([]uint64, len(m)) ids := make([]uint64, len(v))
for i := range m { for i := range v {
ids[i] = m[i].ID ids[i] = v[i].ID
} }
return pc.AddMatchIDs(ids...) return _c.AddMatchIDs(ids...)
} }
// Mutation returns the PlayerMutation object of the builder. // Mutation returns the PlayerMutation object of the builder.
func (pc *PlayerCreate) Mutation() *PlayerMutation { func (_c *PlayerCreate) Mutation() *PlayerMutation {
return pc.mutation return _c.mutation
} }
// Save creates the Player in the database. // Save creates the Player in the database.
func (pc *PlayerCreate) Save(ctx context.Context) (*Player, error) { func (_c *PlayerCreate) Save(ctx context.Context) (*Player, error) {
pc.defaults() _c.defaults()
return withHooks(ctx, pc.sqlSave, pc.mutation, pc.hooks) return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
} }
// SaveX calls Save and panics if Save returns an error. // SaveX calls Save and panics if Save returns an error.
func (pc *PlayerCreate) SaveX(ctx context.Context) *Player { func (_c *PlayerCreate) SaveX(ctx context.Context) *Player {
v, err := pc.Save(ctx) v, err := _c.Save(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -303,40 +303,40 @@ func (pc *PlayerCreate) SaveX(ctx context.Context) *Player {
} }
// Exec executes the query. // Exec executes the query.
func (pc *PlayerCreate) Exec(ctx context.Context) error { func (_c *PlayerCreate) Exec(ctx context.Context) error {
_, err := pc.Save(ctx) _, err := _c.Save(ctx)
return err return err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (pc *PlayerCreate) ExecX(ctx context.Context) { func (_c *PlayerCreate) ExecX(ctx context.Context) {
if err := pc.Exec(ctx); err != nil { if err := _c.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }
// defaults sets the default values of the builder before save. // defaults sets the default values of the builder before save.
func (pc *PlayerCreate) defaults() { func (_c *PlayerCreate) defaults() {
if _, ok := pc.mutation.SteamUpdated(); !ok { if _, ok := _c.mutation.SteamUpdated(); !ok {
v := player.DefaultSteamUpdated() v := player.DefaultSteamUpdated()
pc.mutation.SetSteamUpdated(v) _c.mutation.SetSteamUpdated(v)
} }
} }
// check runs all checks and user-defined validators on the builder. // check runs all checks and user-defined validators on the builder.
func (pc *PlayerCreate) check() error { func (_c *PlayerCreate) check() error {
if _, ok := pc.mutation.SteamUpdated(); !ok { if _, ok := _c.mutation.SteamUpdated(); !ok {
return &ValidationError{Name: "steam_updated", err: errors.New(`ent: missing required field "Player.steam_updated"`)} return &ValidationError{Name: "steam_updated", err: errors.New(`ent: missing required field "Player.steam_updated"`)}
} }
return nil return nil
} }
func (pc *PlayerCreate) sqlSave(ctx context.Context) (*Player, error) { func (_c *PlayerCreate) sqlSave(ctx context.Context) (*Player, error) {
if err := pc.check(); err != nil { if err := _c.check(); err != nil {
return nil, err return nil, err
} }
_node, _spec := pc.createSpec() _node, _spec := _c.createSpec()
if err := sqlgraph.CreateNode(ctx, pc.driver, _spec); err != nil { if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) { if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: 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) id := _spec.ID.Value.(int64)
_node.ID = uint64(id) _node.ID = uint64(id)
} }
pc.mutation.id = &_node.ID _c.mutation.id = &_node.ID
pc.mutation.done = true _c.mutation.done = true
return _node, nil return _node, nil
} }
func (pc *PlayerCreate) createSpec() (*Player, *sqlgraph.CreateSpec) { func (_c *PlayerCreate) createSpec() (*Player, *sqlgraph.CreateSpec) {
var ( var (
_node = &Player{config: pc.config} _node = &Player{config: _c.config}
_spec = sqlgraph.NewCreateSpec(player.Table, sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64)) _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 _node.ID = id
_spec.ID.Value = 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) _spec.SetField(player.FieldName, field.TypeString, value)
_node.Name = 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) _spec.SetField(player.FieldAvatar, field.TypeString, value)
_node.Avatar = 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) _spec.SetField(player.FieldVanityURL, field.TypeString, value)
_node.VanityURL = 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) _spec.SetField(player.FieldVanityURLReal, field.TypeString, value)
_node.VanityURLReal = 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) _spec.SetField(player.FieldVacDate, field.TypeTime, value)
_node.VacDate = 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) _spec.SetField(player.FieldVacCount, field.TypeInt, value)
_node.VacCount = 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) _spec.SetField(player.FieldGameBanDate, field.TypeTime, value)
_node.GameBanDate = 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) _spec.SetField(player.FieldGameBanCount, field.TypeInt, value)
_node.GameBanCount = 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) _spec.SetField(player.FieldSteamUpdated, field.TypeTime, value)
_node.SteamUpdated = 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) _spec.SetField(player.FieldSharecodeUpdated, field.TypeTime, value)
_node.SharecodeUpdated = 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) _spec.SetField(player.FieldAuthCode, field.TypeString, value)
_node.AuthCode = 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) _spec.SetField(player.FieldProfileCreated, field.TypeTime, value)
_node.ProfileCreated = 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) _spec.SetField(player.FieldOldestSharecodeSeen, field.TypeString, value)
_node.OldestSharecodeSeen = 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) _spec.SetField(player.FieldWins, field.TypeInt, value)
_node.Wins = 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) _spec.SetField(player.FieldLooses, field.TypeInt, value)
_node.Looses = 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) _spec.SetField(player.FieldTies, field.TypeInt, value)
_node.Ties = value _node.Ties = value
} }
if nodes := pc.mutation.StatsIDs(); len(nodes) > 0 { if nodes := _c.mutation.StatsIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{ edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.O2M, Rel: sqlgraph.O2M,
Inverse: false, Inverse: false,
@@ -440,7 +440,7 @@ func (pc *PlayerCreate) createSpec() (*Player, *sqlgraph.CreateSpec) {
} }
_spec.Edges = append(_spec.Edges, edge) _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{ edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2M, Rel: sqlgraph.M2M,
Inverse: false, Inverse: false,
@@ -462,17 +462,21 @@ func (pc *PlayerCreate) createSpec() (*Player, *sqlgraph.CreateSpec) {
// PlayerCreateBulk is the builder for creating many Player entities in bulk. // PlayerCreateBulk is the builder for creating many Player entities in bulk.
type PlayerCreateBulk struct { type PlayerCreateBulk struct {
config config
err error
builders []*PlayerCreate builders []*PlayerCreate
} }
// Save creates the Player entities in the database. // Save creates the Player entities in the database.
func (pcb *PlayerCreateBulk) Save(ctx context.Context) ([]*Player, error) { func (_c *PlayerCreateBulk) Save(ctx context.Context) ([]*Player, error) {
specs := make([]*sqlgraph.CreateSpec, len(pcb.builders)) if _c.err != nil {
nodes := make([]*Player, len(pcb.builders)) return nil, _c.err
mutators := make([]Mutator, len(pcb.builders)) }
for i := range pcb.builders { 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) { func(i int, root context.Context) {
builder := pcb.builders[i] builder := _c.builders[i]
builder.defaults() builder.defaults()
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*PlayerMutation) mutation, ok := m.(*PlayerMutation)
@@ -486,11 +490,11 @@ func (pcb *PlayerCreateBulk) Save(ctx context.Context) ([]*Player, error) {
var err error var err error
nodes[i], specs[i] = builder.createSpec() nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 { 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 { } else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs} spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain. // 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) { if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
@@ -514,7 +518,7 @@ func (pcb *PlayerCreateBulk) Save(ctx context.Context) ([]*Player, error) {
}(i, ctx) }(i, ctx)
} }
if len(mutators) > 0 { 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 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. // SaveX is like Save, but panics if an error occurs.
func (pcb *PlayerCreateBulk) SaveX(ctx context.Context) []*Player { func (_c *PlayerCreateBulk) SaveX(ctx context.Context) []*Player {
v, err := pcb.Save(ctx) v, err := _c.Save(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -531,14 +535,14 @@ func (pcb *PlayerCreateBulk) SaveX(ctx context.Context) []*Player {
} }
// Exec executes the query. // Exec executes the query.
func (pcb *PlayerCreateBulk) Exec(ctx context.Context) error { func (_c *PlayerCreateBulk) Exec(ctx context.Context) error {
_, err := pcb.Save(ctx) _, err := _c.Save(ctx)
return err return err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (pcb *PlayerCreateBulk) ExecX(ctx context.Context) { func (_c *PlayerCreateBulk) ExecX(ctx context.Context) {
if err := pcb.Exec(ctx); err != nil { if err := _c.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }

View File

@@ -20,56 +20,56 @@ type PlayerDelete struct {
} }
// Where appends a list predicates to the PlayerDelete builder. // Where appends a list predicates to the PlayerDelete builder.
func (pd *PlayerDelete) Where(ps ...predicate.Player) *PlayerDelete { func (_d *PlayerDelete) Where(ps ...predicate.Player) *PlayerDelete {
pd.mutation.Where(ps...) _d.mutation.Where(ps...)
return pd return _d
} }
// Exec executes the deletion query and returns how many vertices were deleted. // Exec executes the deletion query and returns how many vertices were deleted.
func (pd *PlayerDelete) Exec(ctx context.Context) (int, error) { func (_d *PlayerDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, pd.sqlExec, pd.mutation, pd.hooks) return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (pd *PlayerDelete) ExecX(ctx context.Context) int { func (_d *PlayerDelete) ExecX(ctx context.Context) int {
n, err := pd.Exec(ctx) n, err := _d.Exec(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
return n 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)) _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) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) 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) { if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
pd.mutation.done = true _d.mutation.done = true
return affected, err return affected, err
} }
// PlayerDeleteOne is the builder for deleting a single Player entity. // PlayerDeleteOne is the builder for deleting a single Player entity.
type PlayerDeleteOne struct { type PlayerDeleteOne struct {
pd *PlayerDelete _d *PlayerDelete
} }
// Where appends a list predicates to the PlayerDelete builder. // Where appends a list predicates to the PlayerDelete builder.
func (pdo *PlayerDeleteOne) Where(ps ...predicate.Player) *PlayerDeleteOne { func (_d *PlayerDeleteOne) Where(ps ...predicate.Player) *PlayerDeleteOne {
pdo.pd.mutation.Where(ps...) _d._d.mutation.Where(ps...)
return pdo return _d
} }
// Exec executes the deletion query. // Exec executes the deletion query.
func (pdo *PlayerDeleteOne) Exec(ctx context.Context) error { func (_d *PlayerDeleteOne) Exec(ctx context.Context) error {
n, err := pdo.pd.Exec(ctx) n, err := _d._d.Exec(ctx)
switch { switch {
case err != nil: case err != nil:
return err return err
@@ -81,8 +81,8 @@ func (pdo *PlayerDeleteOne) Exec(ctx context.Context) error {
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (pdo *PlayerDeleteOne) ExecX(ctx context.Context) { func (_d *PlayerDeleteOne) ExecX(ctx context.Context) {
if err := pdo.Exec(ctx); err != nil { if err := _d.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }

View File

@@ -8,6 +8,7 @@ import (
"fmt" "fmt"
"math" "math"
"entgo.io/ent"
"entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field" "entgo.io/ent/schema/field"
@@ -33,44 +34,44 @@ type PlayerQuery struct {
} }
// Where adds a new predicate for the PlayerQuery builder. // Where adds a new predicate for the PlayerQuery builder.
func (pq *PlayerQuery) Where(ps ...predicate.Player) *PlayerQuery { func (_q *PlayerQuery) Where(ps ...predicate.Player) *PlayerQuery {
pq.predicates = append(pq.predicates, ps...) _q.predicates = append(_q.predicates, ps...)
return pq return _q
} }
// Limit the number of records to be returned by this query. // Limit the number of records to be returned by this query.
func (pq *PlayerQuery) Limit(limit int) *PlayerQuery { func (_q *PlayerQuery) Limit(limit int) *PlayerQuery {
pq.ctx.Limit = &limit _q.ctx.Limit = &limit
return pq return _q
} }
// Offset to start from. // Offset to start from.
func (pq *PlayerQuery) Offset(offset int) *PlayerQuery { func (_q *PlayerQuery) Offset(offset int) *PlayerQuery {
pq.ctx.Offset = &offset _q.ctx.Offset = &offset
return pq return _q
} }
// Unique configures the query builder to filter duplicate records on query. // 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. // By default, unique is set to true, and can be disabled using this method.
func (pq *PlayerQuery) Unique(unique bool) *PlayerQuery { func (_q *PlayerQuery) Unique(unique bool) *PlayerQuery {
pq.ctx.Unique = &unique _q.ctx.Unique = &unique
return pq return _q
} }
// Order specifies how the records should be ordered. // Order specifies how the records should be ordered.
func (pq *PlayerQuery) Order(o ...player.OrderOption) *PlayerQuery { func (_q *PlayerQuery) Order(o ...player.OrderOption) *PlayerQuery {
pq.order = append(pq.order, o...) _q.order = append(_q.order, o...)
return pq return _q
} }
// QueryStats chains the current query on the "stats" edge. // QueryStats chains the current query on the "stats" edge.
func (pq *PlayerQuery) QueryStats() *MatchPlayerQuery { func (_q *PlayerQuery) QueryStats() *MatchPlayerQuery {
query := (&MatchPlayerClient{config: pq.config}).Query() query := (&MatchPlayerClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { 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 return nil, err
} }
selector := pq.sqlQuery(ctx) selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return nil, err return nil, err
} }
@@ -79,20 +80,20 @@ func (pq *PlayerQuery) QueryStats() *MatchPlayerQuery {
sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
sqlgraph.Edge(sqlgraph.O2M, false, player.StatsTable, player.StatsColumn), 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 fromU, nil
} }
return query return query
} }
// QueryMatches chains the current query on the "matches" edge. // QueryMatches chains the current query on the "matches" edge.
func (pq *PlayerQuery) QueryMatches() *MatchQuery { func (_q *PlayerQuery) QueryMatches() *MatchQuery {
query := (&MatchClient{config: pq.config}).Query() query := (&MatchClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { 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 return nil, err
} }
selector := pq.sqlQuery(ctx) selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return nil, err return nil, err
} }
@@ -101,7 +102,7 @@ func (pq *PlayerQuery) QueryMatches() *MatchQuery {
sqlgraph.To(match.Table, match.FieldID), sqlgraph.To(match.Table, match.FieldID),
sqlgraph.Edge(sqlgraph.M2M, false, player.MatchesTable, player.MatchesPrimaryKey...), 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 fromU, nil
} }
return query return query
@@ -109,8 +110,8 @@ func (pq *PlayerQuery) QueryMatches() *MatchQuery {
// First returns the first Player entity from the query. // First returns the first Player entity from the query.
// Returns a *NotFoundError when no Player was found. // Returns a *NotFoundError when no Player was found.
func (pq *PlayerQuery) First(ctx context.Context) (*Player, error) { func (_q *PlayerQuery) First(ctx context.Context) (*Player, error) {
nodes, err := pq.Limit(1).All(setContextOp(ctx, pq.ctx, "First")) nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
if err != nil { if err != nil {
return nil, err 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. // FirstX is like First, but panics if an error occurs.
func (pq *PlayerQuery) FirstX(ctx context.Context) *Player { func (_q *PlayerQuery) FirstX(ctx context.Context) *Player {
node, err := pq.First(ctx) node, err := _q.First(ctx)
if err != nil && !IsNotFound(err) { if err != nil && !IsNotFound(err) {
panic(err) panic(err)
} }
@@ -131,9 +132,9 @@ func (pq *PlayerQuery) FirstX(ctx context.Context) *Player {
// FirstID returns the first Player ID from the query. // FirstID returns the first Player ID from the query.
// Returns a *NotFoundError when no Player ID was found. // 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 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 return
} }
if len(ids) == 0 { 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. // FirstIDX is like FirstID, but panics if an error occurs.
func (pq *PlayerQuery) FirstIDX(ctx context.Context) uint64 { func (_q *PlayerQuery) FirstIDX(ctx context.Context) uint64 {
id, err := pq.FirstID(ctx) id, err := _q.FirstID(ctx)
if err != nil && !IsNotFound(err) { if err != nil && !IsNotFound(err) {
panic(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. // 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 *NotSingularError when more than one Player entity is found.
// Returns a *NotFoundError when no Player entities are found. // Returns a *NotFoundError when no Player entities are found.
func (pq *PlayerQuery) Only(ctx context.Context) (*Player, error) { func (_q *PlayerQuery) Only(ctx context.Context) (*Player, error) {
nodes, err := pq.Limit(2).All(setContextOp(ctx, pq.ctx, "Only")) nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
if err != nil { if err != nil {
return nil, err 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. // OnlyX is like Only, but panics if an error occurs.
func (pq *PlayerQuery) OnlyX(ctx context.Context) *Player { func (_q *PlayerQuery) OnlyX(ctx context.Context) *Player {
node, err := pq.Only(ctx) node, err := _q.Only(ctx)
if err != nil { if err != nil {
panic(err) 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. // 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 *NotSingularError when more than one Player ID is found.
// Returns a *NotFoundError when no entities are 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 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 return
} }
switch len(ids) { 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. // OnlyIDX is like OnlyID, but panics if an error occurs.
func (pq *PlayerQuery) OnlyIDX(ctx context.Context) uint64 { func (_q *PlayerQuery) OnlyIDX(ctx context.Context) uint64 {
id, err := pq.OnlyID(ctx) id, err := _q.OnlyID(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -208,18 +209,18 @@ func (pq *PlayerQuery) OnlyIDX(ctx context.Context) uint64 {
} }
// All executes the query and returns a list of Players. // All executes the query and returns a list of Players.
func (pq *PlayerQuery) All(ctx context.Context) ([]*Player, error) { func (_q *PlayerQuery) All(ctx context.Context) ([]*Player, error) {
ctx = setContextOp(ctx, pq.ctx, "All") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
if err := pq.prepareQuery(ctx); err != nil { if err := _q.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
qr := querierAll[[]*Player, *PlayerQuery]() 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. // AllX is like All, but panics if an error occurs.
func (pq *PlayerQuery) AllX(ctx context.Context) []*Player { func (_q *PlayerQuery) AllX(ctx context.Context) []*Player {
nodes, err := pq.All(ctx) nodes, err := _q.All(ctx)
if err != nil { if err != nil {
panic(err) 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. // IDs executes the query and returns a list of Player IDs.
func (pq *PlayerQuery) IDs(ctx context.Context) (ids []uint64, err error) { func (_q *PlayerQuery) IDs(ctx context.Context) (ids []uint64, err error) {
if pq.ctx.Unique == nil && pq.path != nil { if _q.ctx.Unique == nil && _q.path != nil {
pq.Unique(true) _q.Unique(true)
} }
ctx = setContextOp(ctx, pq.ctx, "IDs") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
if err = pq.Select(player.FieldID).Scan(ctx, &ids); err != nil { if err = _q.Select(player.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
return ids, nil return ids, nil
} }
// IDsX is like IDs, but panics if an error occurs. // IDsX is like IDs, but panics if an error occurs.
func (pq *PlayerQuery) IDsX(ctx context.Context) []uint64 { func (_q *PlayerQuery) IDsX(ctx context.Context) []uint64 {
ids, err := pq.IDs(ctx) ids, err := _q.IDs(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -248,17 +249,17 @@ func (pq *PlayerQuery) IDsX(ctx context.Context) []uint64 {
} }
// Count returns the count of the given query. // Count returns the count of the given query.
func (pq *PlayerQuery) Count(ctx context.Context) (int, error) { func (_q *PlayerQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, pq.ctx, "Count") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
if err := pq.prepareQuery(ctx); err != nil { if err := _q.prepareQuery(ctx); err != nil {
return 0, err 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. // CountX is like Count, but panics if an error occurs.
func (pq *PlayerQuery) CountX(ctx context.Context) int { func (_q *PlayerQuery) CountX(ctx context.Context) int {
count, err := pq.Count(ctx) count, err := _q.Count(ctx)
if err != nil { if err != nil {
panic(err) 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. // Exist returns true if the query has elements in the graph.
func (pq *PlayerQuery) Exist(ctx context.Context) (bool, error) { func (_q *PlayerQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, pq.ctx, "Exist") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
switch _, err := pq.FirstID(ctx); { switch _, err := _q.FirstID(ctx); {
case IsNotFound(err): case IsNotFound(err):
return false, nil return false, nil
case err != 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. // ExistX is like Exist, but panics if an error occurs.
func (pq *PlayerQuery) ExistX(ctx context.Context) bool { func (_q *PlayerQuery) ExistX(ctx context.Context) bool {
exist, err := pq.Exist(ctx) exist, err := _q.Exist(ctx)
if err != nil { if err != nil {
panic(err) 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 // 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. // used to prepare common query builders and use them differently after the clone is made.
func (pq *PlayerQuery) Clone() *PlayerQuery { func (_q *PlayerQuery) Clone() *PlayerQuery {
if pq == nil { if _q == nil {
return nil return nil
} }
return &PlayerQuery{ return &PlayerQuery{
config: pq.config, config: _q.config,
ctx: pq.ctx.Clone(), ctx: _q.ctx.Clone(),
order: append([]player.OrderOption{}, pq.order...), order: append([]player.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, pq.inters...), inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.Player{}, pq.predicates...), predicates: append([]predicate.Player{}, _q.predicates...),
withStats: pq.withStats.Clone(), withStats: _q.withStats.Clone(),
withMatches: pq.withMatches.Clone(), withMatches: _q.withMatches.Clone(),
// clone intermediate query. // clone intermediate query.
sql: pq.sql.Clone(), sql: _q.sql.Clone(),
path: pq.path, path: _q.path,
modifiers: append([]func(*sql.Selector){}, _q.modifiers...),
} }
} }
// WithStats tells the query-builder to eager-load the nodes that are connected to // 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. // the "stats" edge. The optional arguments are used to configure the query builder of the edge.
func (pq *PlayerQuery) WithStats(opts ...func(*MatchPlayerQuery)) *PlayerQuery { func (_q *PlayerQuery) WithStats(opts ...func(*MatchPlayerQuery)) *PlayerQuery {
query := (&MatchPlayerClient{config: pq.config}).Query() query := (&MatchPlayerClient{config: _q.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
pq.withStats = query _q.withStats = query
return pq return _q
} }
// WithMatches tells the query-builder to eager-load the nodes that are connected to // 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. // the "matches" edge. The optional arguments are used to configure the query builder of the edge.
func (pq *PlayerQuery) WithMatches(opts ...func(*MatchQuery)) *PlayerQuery { func (_q *PlayerQuery) WithMatches(opts ...func(*MatchQuery)) *PlayerQuery {
query := (&MatchClient{config: pq.config}).Query() query := (&MatchClient{config: _q.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
pq.withMatches = query _q.withMatches = query
return pq return _q
} }
// GroupBy is used to group vertices by one or more fields/columns. // 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). // GroupBy(player.FieldName).
// Aggregate(ent.Count()). // Aggregate(ent.Count()).
// Scan(ctx, &v) // Scan(ctx, &v)
func (pq *PlayerQuery) GroupBy(field string, fields ...string) *PlayerGroupBy { func (_q *PlayerQuery) GroupBy(field string, fields ...string) *PlayerGroupBy {
pq.ctx.Fields = append([]string{field}, fields...) _q.ctx.Fields = append([]string{field}, fields...)
grbuild := &PlayerGroupBy{build: pq} grbuild := &PlayerGroupBy{build: _q}
grbuild.flds = &pq.ctx.Fields grbuild.flds = &_q.ctx.Fields
grbuild.label = player.Label grbuild.label = player.Label
grbuild.scan = grbuild.Scan grbuild.scan = grbuild.Scan
return grbuild return grbuild
@@ -364,84 +366,84 @@ func (pq *PlayerQuery) GroupBy(field string, fields ...string) *PlayerGroupBy {
// client.Player.Query(). // client.Player.Query().
// Select(player.FieldName). // Select(player.FieldName).
// Scan(ctx, &v) // Scan(ctx, &v)
func (pq *PlayerQuery) Select(fields ...string) *PlayerSelect { func (_q *PlayerQuery) Select(fields ...string) *PlayerSelect {
pq.ctx.Fields = append(pq.ctx.Fields, fields...) _q.ctx.Fields = append(_q.ctx.Fields, fields...)
sbuild := &PlayerSelect{PlayerQuery: pq} sbuild := &PlayerSelect{PlayerQuery: _q}
sbuild.label = player.Label sbuild.label = player.Label
sbuild.flds, sbuild.scan = &pq.ctx.Fields, sbuild.Scan sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
return sbuild return sbuild
} }
// Aggregate returns a PlayerSelect configured with the given aggregations. // Aggregate returns a PlayerSelect configured with the given aggregations.
func (pq *PlayerQuery) Aggregate(fns ...AggregateFunc) *PlayerSelect { func (_q *PlayerQuery) Aggregate(fns ...AggregateFunc) *PlayerSelect {
return pq.Select().Aggregate(fns...) return _q.Select().Aggregate(fns...)
} }
func (pq *PlayerQuery) prepareQuery(ctx context.Context) error { func (_q *PlayerQuery) prepareQuery(ctx context.Context) error {
for _, inter := range pq.inters { for _, inter := range _q.inters {
if inter == nil { if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
} }
if trv, ok := inter.(Traverser); ok { if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, pq); err != nil { if err := trv.Traverse(ctx, _q); err != nil {
return err return err
} }
} }
} }
for _, f := range pq.ctx.Fields { for _, f := range _q.ctx.Fields {
if !player.ValidColumn(f) { if !player.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
} }
} }
if pq.path != nil { if _q.path != nil {
prev, err := pq.path(ctx) prev, err := _q.path(ctx)
if err != nil { if err != nil {
return err return err
} }
pq.sql = prev _q.sql = prev
} }
return nil 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 ( var (
nodes = []*Player{} nodes = []*Player{}
_spec = pq.querySpec() _spec = _q.querySpec()
loadedTypes = [2]bool{ loadedTypes = [2]bool{
pq.withStats != nil, _q.withStats != nil,
pq.withMatches != nil, _q.withMatches != nil,
} }
) )
_spec.ScanValues = func(columns []string) ([]any, error) { _spec.ScanValues = func(columns []string) ([]any, error) {
return (*Player).scanValues(nil, columns) return (*Player).scanValues(nil, columns)
} }
_spec.Assign = func(columns []string, values []any) error { _spec.Assign = func(columns []string, values []any) error {
node := &Player{config: pq.config} node := &Player{config: _q.config}
nodes = append(nodes, node) nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values) return node.assignValues(columns, values)
} }
if len(pq.modifiers) > 0 { if len(_q.modifiers) > 0 {
_spec.Modifiers = pq.modifiers _spec.Modifiers = _q.modifiers
} }
for i := range hooks { for i := range hooks {
hooks[i](ctx, _spec) 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 return nil, err
} }
if len(nodes) == 0 { if len(nodes) == 0 {
return nodes, nil return nodes, nil
} }
if query := pq.withStats; query != nil { if query := _q.withStats; query != nil {
if err := pq.loadStats(ctx, query, nodes, if err := _q.loadStats(ctx, query, nodes,
func(n *Player) { n.Edges.Stats = []*MatchPlayer{} }, func(n *Player) { n.Edges.Stats = []*MatchPlayer{} },
func(n *Player, e *MatchPlayer) { n.Edges.Stats = append(n.Edges.Stats, e) }); err != nil { func(n *Player, e *MatchPlayer) { n.Edges.Stats = append(n.Edges.Stats, e) }); err != nil {
return nil, err return nil, err
} }
} }
if query := pq.withMatches; query != nil { if query := _q.withMatches; query != nil {
if err := pq.loadMatches(ctx, query, nodes, if err := _q.loadMatches(ctx, query, nodes,
func(n *Player) { n.Edges.Matches = []*Match{} }, func(n *Player) { n.Edges.Matches = []*Match{} },
func(n *Player, e *Match) { n.Edges.Matches = append(n.Edges.Matches, e) }); err != nil { func(n *Player, e *Match) { n.Edges.Matches = append(n.Edges.Matches, e) }); err != nil {
return nil, err return nil, err
@@ -450,7 +452,7 @@ func (pq *PlayerQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Playe
return nodes, nil 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)) fks := make([]driver.Value, 0, len(nodes))
nodeids := make(map[uint64]*Player) nodeids := make(map[uint64]*Player)
for i := range nodes { for i := range nodes {
@@ -480,7 +482,7 @@ func (pq *PlayerQuery) loadStats(ctx context.Context, query *MatchPlayerQuery, n
} }
return nil 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)) edgeIDs := make([]driver.Value, len(nodes))
byID := make(map[uint64]*Player) byID := make(map[uint64]*Player)
nids := make(map[uint64]map[*Player]struct{}) nids := make(map[uint64]map[*Player]struct{})
@@ -542,27 +544,27 @@ func (pq *PlayerQuery) loadMatches(ctx context.Context, query *MatchQuery, nodes
return nil return nil
} }
func (pq *PlayerQuery) sqlCount(ctx context.Context) (int, error) { func (_q *PlayerQuery) sqlCount(ctx context.Context) (int, error) {
_spec := pq.querySpec() _spec := _q.querySpec()
if len(pq.modifiers) > 0 { if len(_q.modifiers) > 0 {
_spec.Modifiers = pq.modifiers _spec.Modifiers = _q.modifiers
} }
_spec.Node.Columns = pq.ctx.Fields _spec.Node.Columns = _q.ctx.Fields
if len(pq.ctx.Fields) > 0 { if len(_q.ctx.Fields) > 0 {
_spec.Unique = pq.ctx.Unique != nil && *pq.ctx.Unique _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 := sqlgraph.NewQuerySpec(player.Table, player.Columns, sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64))
_spec.From = pq.sql _spec.From = _q.sql
if unique := pq.ctx.Unique; unique != nil { if unique := _q.ctx.Unique; unique != nil {
_spec.Unique = *unique _spec.Unique = *unique
} else if pq.path != nil { } else if _q.path != nil {
_spec.Unique = true _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 = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, player.FieldID) _spec.Node.Columns = append(_spec.Node.Columns, player.FieldID)
for i := range fields { 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) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) ps[i](selector)
} }
} }
} }
if limit := pq.ctx.Limit; limit != nil { if limit := _q.ctx.Limit; limit != nil {
_spec.Limit = *limit _spec.Limit = *limit
} }
if offset := pq.ctx.Offset; offset != nil { if offset := _q.ctx.Offset; offset != nil {
_spec.Offset = *offset _spec.Offset = *offset
} }
if ps := pq.order; len(ps) > 0 { if ps := _q.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) { _spec.Order = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) ps[i](selector)
@@ -594,45 +596,45 @@ func (pq *PlayerQuery) querySpec() *sqlgraph.QuerySpec {
return _spec return _spec
} }
func (pq *PlayerQuery) sqlQuery(ctx context.Context) *sql.Selector { func (_q *PlayerQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(pq.driver.Dialect()) builder := sql.Dialect(_q.driver.Dialect())
t1 := builder.Table(player.Table) t1 := builder.Table(player.Table)
columns := pq.ctx.Fields columns := _q.ctx.Fields
if len(columns) == 0 { if len(columns) == 0 {
columns = player.Columns columns = player.Columns
} }
selector := builder.Select(t1.Columns(columns...)...).From(t1) selector := builder.Select(t1.Columns(columns...)...).From(t1)
if pq.sql != nil { if _q.sql != nil {
selector = pq.sql selector = _q.sql
selector.Select(selector.Columns(columns...)...) selector.Select(selector.Columns(columns...)...)
} }
if pq.ctx.Unique != nil && *pq.ctx.Unique { if _q.ctx.Unique != nil && *_q.ctx.Unique {
selector.Distinct() selector.Distinct()
} }
for _, m := range pq.modifiers { for _, m := range _q.modifiers {
m(selector) m(selector)
} }
for _, p := range pq.predicates { for _, p := range _q.predicates {
p(selector) p(selector)
} }
for _, p := range pq.order { for _, p := range _q.order {
p(selector) p(selector)
} }
if offset := pq.ctx.Offset; offset != nil { if offset := _q.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start // limit is mandatory for offset clause. We start
// with default value, and override it below if needed. // with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32) selector.Offset(*offset).Limit(math.MaxInt32)
} }
if limit := pq.ctx.Limit; limit != nil { if limit := _q.ctx.Limit; limit != nil {
selector.Limit(*limit) selector.Limit(*limit)
} }
return selector return selector
} }
// Modify adds a query modifier for attaching custom logic to queries. // Modify adds a query modifier for attaching custom logic to queries.
func (pq *PlayerQuery) Modify(modifiers ...func(s *sql.Selector)) *PlayerSelect { func (_q *PlayerQuery) Modify(modifiers ...func(s *sql.Selector)) *PlayerSelect {
pq.modifiers = append(pq.modifiers, modifiers...) _q.modifiers = append(_q.modifiers, modifiers...)
return pq.Select() return _q.Select()
} }
// PlayerGroupBy is the group-by builder for Player entities. // 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. // Aggregate adds the given aggregation functions to the group-by query.
func (pgb *PlayerGroupBy) Aggregate(fns ...AggregateFunc) *PlayerGroupBy { func (_g *PlayerGroupBy) Aggregate(fns ...AggregateFunc) *PlayerGroupBy {
pgb.fns = append(pgb.fns, fns...) _g.fns = append(_g.fns, fns...)
return pgb return _g
} }
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (pgb *PlayerGroupBy) Scan(ctx context.Context, v any) error { func (_g *PlayerGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, pgb.build.ctx, "GroupBy") ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
if err := pgb.build.prepareQuery(ctx); err != nil { if err := _g.build.prepareQuery(ctx); err != nil {
return err 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() selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(pgb.fns)) aggregation := make([]string, 0, len(_g.fns))
for _, fn := range pgb.fns { for _, fn := range _g.fns {
aggregation = append(aggregation, fn(selector)) aggregation = append(aggregation, fn(selector))
} }
if len(selector.SelectedColumns()) == 0 { if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*pgb.flds)+len(pgb.fns)) columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
for _, f := range *pgb.flds { for _, f := range *_g.flds {
columns = append(columns, selector.C(f)) columns = append(columns, selector.C(f))
} }
columns = append(columns, aggregation...) columns = append(columns, aggregation...)
selector.Select(columns...) selector.Select(columns...)
} }
selector.GroupBy(selector.Columns(*pgb.flds...)...) selector.GroupBy(selector.Columns(*_g.flds...)...)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return err return err
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := selector.Query() 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 return err
} }
defer rows.Close() defer rows.Close()
@@ -690,27 +692,27 @@ type PlayerSelect struct {
} }
// Aggregate adds the given aggregation functions to the selector query. // Aggregate adds the given aggregation functions to the selector query.
func (ps *PlayerSelect) Aggregate(fns ...AggregateFunc) *PlayerSelect { func (_s *PlayerSelect) Aggregate(fns ...AggregateFunc) *PlayerSelect {
ps.fns = append(ps.fns, fns...) _s.fns = append(_s.fns, fns...)
return ps return _s
} }
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (ps *PlayerSelect) Scan(ctx context.Context, v any) error { func (_s *PlayerSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, ps.ctx, "Select") ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
if err := ps.prepareQuery(ctx); err != nil { if err := _s.prepareQuery(ctx); err != nil {
return err 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) selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(ps.fns)) aggregation := make([]string, 0, len(_s.fns))
for _, fn := range ps.fns { for _, fn := range _s.fns {
aggregation = append(aggregation, fn(selector)) aggregation = append(aggregation, fn(selector))
} }
switch n := len(*ps.selector.flds); { switch n := len(*_s.selector.flds); {
case n == 0 && len(aggregation) > 0: case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...) selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0: 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{} rows := &sql.Rows{}
query, args := selector.Query() 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 return err
} }
defer rows.Close() 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. // Modify adds a query modifier for attaching custom logic to queries.
func (ps *PlayerSelect) Modify(modifiers ...func(s *sql.Selector)) *PlayerSelect { func (_s *PlayerSelect) Modify(modifiers ...func(s *sql.Selector)) *PlayerSelect {
ps.modifiers = append(ps.modifiers, modifiers...) _s.modifiers = append(_s.modifiers, modifiers...)
return ps return _s
} }

File diff suppressed because it is too large Load Diff

View File

@@ -44,12 +44,10 @@ type RoundStatsEdges struct {
// MatchPlayerOrErr returns the MatchPlayer value or an error if the edge // MatchPlayerOrErr returns the MatchPlayer value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found. // was not loaded in eager-loading, or loaded but was not found.
func (e RoundStatsEdges) MatchPlayerOrErr() (*MatchPlayer, error) { func (e RoundStatsEdges) MatchPlayerOrErr() (*MatchPlayer, error) {
if e.loadedTypes[0] { if e.MatchPlayer != nil {
if e.MatchPlayer == nil {
// Edge was loaded but was not found.
return nil, &NotFoundError{label: matchplayer.Label}
}
return e.MatchPlayer, nil return e.MatchPlayer, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: matchplayer.Label}
} }
return nil, &NotLoadedError{edge: "match_player"} 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) // assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the RoundStats fields. // 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 { if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", 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 { if !ok {
return fmt.Errorf("unexpected type %T for field id", value) return fmt.Errorf("unexpected type %T for field id", value)
} }
rs.ID = int(value.Int64) _m.ID = int(value.Int64)
case roundstats.FieldRound: case roundstats.FieldRound:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field round", values[i]) return fmt.Errorf("unexpected type %T for field round", values[i])
} else if value.Valid { } else if value.Valid {
rs.Round = uint(value.Int64) _m.Round = uint(value.Int64)
} }
case roundstats.FieldBank: case roundstats.FieldBank:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field bank", values[i]) return fmt.Errorf("unexpected type %T for field bank", values[i])
} else if value.Valid { } else if value.Valid {
rs.Bank = uint(value.Int64) _m.Bank = uint(value.Int64)
} }
case roundstats.FieldEquipment: case roundstats.FieldEquipment:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field equipment", values[i]) return fmt.Errorf("unexpected type %T for field equipment", values[i])
} else if value.Valid { } else if value.Valid {
rs.Equipment = uint(value.Int64) _m.Equipment = uint(value.Int64)
} }
case roundstats.FieldSpent: case roundstats.FieldSpent:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field spent", values[i]) return fmt.Errorf("unexpected type %T for field spent", values[i])
} else if value.Valid { } else if value.Valid {
rs.Spent = uint(value.Int64) _m.Spent = uint(value.Int64)
} }
case roundstats.ForeignKeys[0]: case roundstats.ForeignKeys[0]:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for edge-field match_player_round_stats", value) return fmt.Errorf("unexpected type %T for edge-field match_player_round_stats", value)
} else if value.Valid { } else if value.Valid {
rs.match_player_round_stats = new(int) _m.match_player_round_stats = new(int)
*rs.match_player_round_stats = int(value.Int64) *_m.match_player_round_stats = int(value.Int64)
} }
default: default:
rs.selectValues.Set(columns[i], values[i]) _m.selectValues.Set(columns[i], values[i])
} }
} }
return nil 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. // Value returns the ent.Value that was dynamically selected and assigned to the RoundStats.
// This includes values selected through modifiers, order, etc. // This includes values selected through modifiers, order, etc.
func (rs *RoundStats) Value(name string) (ent.Value, error) { func (_m *RoundStats) Value(name string) (ent.Value, error) {
return rs.selectValues.Get(name) return _m.selectValues.Get(name)
} }
// QueryMatchPlayer queries the "match_player" edge of the RoundStats entity. // QueryMatchPlayer queries the "match_player" edge of the RoundStats entity.
func (rs *RoundStats) QueryMatchPlayer() *MatchPlayerQuery { func (_m *RoundStats) QueryMatchPlayer() *MatchPlayerQuery {
return NewRoundStatsClient(rs.config).QueryMatchPlayer(rs) return NewRoundStatsClient(_m.config).QueryMatchPlayer(_m)
} }
// Update returns a builder for updating this RoundStats. // Update returns a builder for updating this RoundStats.
// Note that you need to call RoundStats.Unwrap() before calling this method if 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. // was returned from a transaction, and the transaction was committed or rolled back.
func (rs *RoundStats) Update() *RoundStatsUpdateOne { func (_m *RoundStats) Update() *RoundStatsUpdateOne {
return NewRoundStatsClient(rs.config).UpdateOne(rs) return NewRoundStatsClient(_m.config).UpdateOne(_m)
} }
// Unwrap unwraps the RoundStats entity that was returned from a transaction after it was closed, // 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. // so that all future queries will be executed through the driver which created the transaction.
func (rs *RoundStats) Unwrap() *RoundStats { func (_m *RoundStats) Unwrap() *RoundStats {
_tx, ok := rs.config.driver.(*txDriver) _tx, ok := _m.config.driver.(*txDriver)
if !ok { if !ok {
panic("ent: RoundStats is not a transactional entity") panic("ent: RoundStats is not a transactional entity")
} }
rs.config.driver = _tx.drv _m.config.driver = _tx.drv
return rs return _m
} }
// String implements the fmt.Stringer. // String implements the fmt.Stringer.
func (rs *RoundStats) String() string { func (_m *RoundStats) String() string {
var builder strings.Builder var builder strings.Builder
builder.WriteString("RoundStats(") builder.WriteString("RoundStats(")
builder.WriteString(fmt.Sprintf("id=%v, ", rs.ID)) builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("round=") builder.WriteString("round=")
builder.WriteString(fmt.Sprintf("%v", rs.Round)) builder.WriteString(fmt.Sprintf("%v", _m.Round))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("bank=") builder.WriteString("bank=")
builder.WriteString(fmt.Sprintf("%v", rs.Bank)) builder.WriteString(fmt.Sprintf("%v", _m.Bank))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("equipment=") builder.WriteString("equipment=")
builder.WriteString(fmt.Sprintf("%v", rs.Equipment)) builder.WriteString(fmt.Sprintf("%v", _m.Equipment))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("spent=") builder.WriteString("spent=")
builder.WriteString(fmt.Sprintf("%v", rs.Spent)) builder.WriteString(fmt.Sprintf("%v", _m.Spent))
builder.WriteByte(')') builder.WriteByte(')')
return builder.String() return builder.String()
} }

View File

@@ -258,32 +258,15 @@ func HasMatchPlayerWith(preds ...predicate.MatchPlayer) predicate.RoundStats {
// And groups predicates with the AND operator between them. // And groups predicates with the AND operator between them.
func And(predicates ...predicate.RoundStats) predicate.RoundStats { func And(predicates ...predicate.RoundStats) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) { return predicate.RoundStats(sql.AndPredicates(predicates...))
s1 := s.Clone().SetP(nil)
for _, p := range predicates {
p(s1)
}
s.Where(s1.P())
})
} }
// Or groups predicates with the OR operator between them. // Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.RoundStats) predicate.RoundStats { func Or(predicates ...predicate.RoundStats) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) { return predicate.RoundStats(sql.OrPredicates(predicates...))
s1 := s.Clone().SetP(nil)
for i, p := range predicates {
if i > 0 {
s1.Or()
}
p(s1)
}
s.Where(s1.P())
})
} }
// Not applies the not operator on the given predicate. // Not applies the not operator on the given predicate.
func Not(p predicate.RoundStats) predicate.RoundStats { func Not(p predicate.RoundStats) predicate.RoundStats {
return predicate.RoundStats(func(s *sql.Selector) { return predicate.RoundStats(sql.NotPredicates(p))
p(s.Not())
})
} }

View File

@@ -21,61 +21,61 @@ type RoundStatsCreate struct {
} }
// SetRound sets the "round" field. // SetRound sets the "round" field.
func (rsc *RoundStatsCreate) SetRound(u uint) *RoundStatsCreate { func (_c *RoundStatsCreate) SetRound(v uint) *RoundStatsCreate {
rsc.mutation.SetRound(u) _c.mutation.SetRound(v)
return rsc return _c
} }
// SetBank sets the "bank" field. // SetBank sets the "bank" field.
func (rsc *RoundStatsCreate) SetBank(u uint) *RoundStatsCreate { func (_c *RoundStatsCreate) SetBank(v uint) *RoundStatsCreate {
rsc.mutation.SetBank(u) _c.mutation.SetBank(v)
return rsc return _c
} }
// SetEquipment sets the "equipment" field. // SetEquipment sets the "equipment" field.
func (rsc *RoundStatsCreate) SetEquipment(u uint) *RoundStatsCreate { func (_c *RoundStatsCreate) SetEquipment(v uint) *RoundStatsCreate {
rsc.mutation.SetEquipment(u) _c.mutation.SetEquipment(v)
return rsc return _c
} }
// SetSpent sets the "spent" field. // SetSpent sets the "spent" field.
func (rsc *RoundStatsCreate) SetSpent(u uint) *RoundStatsCreate { func (_c *RoundStatsCreate) SetSpent(v uint) *RoundStatsCreate {
rsc.mutation.SetSpent(u) _c.mutation.SetSpent(v)
return rsc return _c
} }
// SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID. // SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID.
func (rsc *RoundStatsCreate) SetMatchPlayerID(id int) *RoundStatsCreate { func (_c *RoundStatsCreate) SetMatchPlayerID(id int) *RoundStatsCreate {
rsc.mutation.SetMatchPlayerID(id) _c.mutation.SetMatchPlayerID(id)
return rsc return _c
} }
// SetNillableMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID if the given value is not nil. // 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 { 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. // SetMatchPlayer sets the "match_player" edge to the MatchPlayer entity.
func (rsc *RoundStatsCreate) SetMatchPlayer(m *MatchPlayer) *RoundStatsCreate { func (_c *RoundStatsCreate) SetMatchPlayer(v *MatchPlayer) *RoundStatsCreate {
return rsc.SetMatchPlayerID(m.ID) return _c.SetMatchPlayerID(v.ID)
} }
// Mutation returns the RoundStatsMutation object of the builder. // Mutation returns the RoundStatsMutation object of the builder.
func (rsc *RoundStatsCreate) Mutation() *RoundStatsMutation { func (_c *RoundStatsCreate) Mutation() *RoundStatsMutation {
return rsc.mutation return _c.mutation
} }
// Save creates the RoundStats in the database. // Save creates the RoundStats in the database.
func (rsc *RoundStatsCreate) Save(ctx context.Context) (*RoundStats, error) { func (_c *RoundStatsCreate) Save(ctx context.Context) (*RoundStats, error) {
return withHooks(ctx, rsc.sqlSave, rsc.mutation, rsc.hooks) return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
} }
// SaveX calls Save and panics if Save returns an error. // SaveX calls Save and panics if Save returns an error.
func (rsc *RoundStatsCreate) SaveX(ctx context.Context) *RoundStats { func (_c *RoundStatsCreate) SaveX(ctx context.Context) *RoundStats {
v, err := rsc.Save(ctx) v, err := _c.Save(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -83,41 +83,41 @@ func (rsc *RoundStatsCreate) SaveX(ctx context.Context) *RoundStats {
} }
// Exec executes the query. // Exec executes the query.
func (rsc *RoundStatsCreate) Exec(ctx context.Context) error { func (_c *RoundStatsCreate) Exec(ctx context.Context) error {
_, err := rsc.Save(ctx) _, err := _c.Save(ctx)
return err return err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (rsc *RoundStatsCreate) ExecX(ctx context.Context) { func (_c *RoundStatsCreate) ExecX(ctx context.Context) {
if err := rsc.Exec(ctx); err != nil { if err := _c.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }
// check runs all checks and user-defined validators on the builder. // check runs all checks and user-defined validators on the builder.
func (rsc *RoundStatsCreate) check() error { func (_c *RoundStatsCreate) check() error {
if _, ok := rsc.mutation.Round(); !ok { if _, ok := _c.mutation.Round(); !ok {
return &ValidationError{Name: "round", err: errors.New(`ent: missing required field "RoundStats.round"`)} 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"`)} 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"`)} 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 &ValidationError{Name: "spent", err: errors.New(`ent: missing required field "RoundStats.spent"`)}
} }
return nil return nil
} }
func (rsc *RoundStatsCreate) sqlSave(ctx context.Context) (*RoundStats, error) { func (_c *RoundStatsCreate) sqlSave(ctx context.Context) (*RoundStats, error) {
if err := rsc.check(); err != nil { if err := _c.check(); err != nil {
return nil, err return nil, err
} }
_node, _spec := rsc.createSpec() _node, _spec := _c.createSpec()
if err := sqlgraph.CreateNode(ctx, rsc.driver, _spec); err != nil { if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) { if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: 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) id := _spec.ID.Value.(int64)
_node.ID = int(id) _node.ID = int(id)
rsc.mutation.id = &_node.ID _c.mutation.id = &_node.ID
rsc.mutation.done = true _c.mutation.done = true
return _node, nil return _node, nil
} }
func (rsc *RoundStatsCreate) createSpec() (*RoundStats, *sqlgraph.CreateSpec) { func (_c *RoundStatsCreate) createSpec() (*RoundStats, *sqlgraph.CreateSpec) {
var ( var (
_node = &RoundStats{config: rsc.config} _node = &RoundStats{config: _c.config}
_spec = sqlgraph.NewCreateSpec(roundstats.Table, sqlgraph.NewFieldSpec(roundstats.FieldID, field.TypeInt)) _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) _spec.SetField(roundstats.FieldRound, field.TypeUint, value)
_node.Round = 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) _spec.SetField(roundstats.FieldBank, field.TypeUint, value)
_node.Bank = 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) _spec.SetField(roundstats.FieldEquipment, field.TypeUint, value)
_node.Equipment = 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) _spec.SetField(roundstats.FieldSpent, field.TypeUint, value)
_node.Spent = value _node.Spent = value
} }
if nodes := rsc.mutation.MatchPlayerIDs(); len(nodes) > 0 { if nodes := _c.mutation.MatchPlayerIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{ edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O, Rel: sqlgraph.M2O,
Inverse: true, Inverse: true,
@@ -174,17 +174,21 @@ func (rsc *RoundStatsCreate) createSpec() (*RoundStats, *sqlgraph.CreateSpec) {
// RoundStatsCreateBulk is the builder for creating many RoundStats entities in bulk. // RoundStatsCreateBulk is the builder for creating many RoundStats entities in bulk.
type RoundStatsCreateBulk struct { type RoundStatsCreateBulk struct {
config config
err error
builders []*RoundStatsCreate builders []*RoundStatsCreate
} }
// Save creates the RoundStats entities in the database. // Save creates the RoundStats entities in the database.
func (rscb *RoundStatsCreateBulk) Save(ctx context.Context) ([]*RoundStats, error) { func (_c *RoundStatsCreateBulk) Save(ctx context.Context) ([]*RoundStats, error) {
specs := make([]*sqlgraph.CreateSpec, len(rscb.builders)) if _c.err != nil {
nodes := make([]*RoundStats, len(rscb.builders)) return nil, _c.err
mutators := make([]Mutator, len(rscb.builders)) }
for i := range rscb.builders { 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) { 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) { var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*RoundStatsMutation) mutation, ok := m.(*RoundStatsMutation)
if !ok { if !ok {
@@ -197,11 +201,11 @@ func (rscb *RoundStatsCreateBulk) Save(ctx context.Context) ([]*RoundStats, erro
var err error var err error
nodes[i], specs[i] = builder.createSpec() nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 { 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 { } else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs} spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain. // 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) { if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
@@ -225,7 +229,7 @@ func (rscb *RoundStatsCreateBulk) Save(ctx context.Context) ([]*RoundStats, erro
}(i, ctx) }(i, ctx)
} }
if len(mutators) > 0 { 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 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. // SaveX is like Save, but panics if an error occurs.
func (rscb *RoundStatsCreateBulk) SaveX(ctx context.Context) []*RoundStats { func (_c *RoundStatsCreateBulk) SaveX(ctx context.Context) []*RoundStats {
v, err := rscb.Save(ctx) v, err := _c.Save(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -242,14 +246,14 @@ func (rscb *RoundStatsCreateBulk) SaveX(ctx context.Context) []*RoundStats {
} }
// Exec executes the query. // Exec executes the query.
func (rscb *RoundStatsCreateBulk) Exec(ctx context.Context) error { func (_c *RoundStatsCreateBulk) Exec(ctx context.Context) error {
_, err := rscb.Save(ctx) _, err := _c.Save(ctx)
return err return err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (rscb *RoundStatsCreateBulk) ExecX(ctx context.Context) { func (_c *RoundStatsCreateBulk) ExecX(ctx context.Context) {
if err := rscb.Exec(ctx); err != nil { if err := _c.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }

View File

@@ -20,56 +20,56 @@ type RoundStatsDelete struct {
} }
// Where appends a list predicates to the RoundStatsDelete builder. // Where appends a list predicates to the RoundStatsDelete builder.
func (rsd *RoundStatsDelete) Where(ps ...predicate.RoundStats) *RoundStatsDelete { func (_d *RoundStatsDelete) Where(ps ...predicate.RoundStats) *RoundStatsDelete {
rsd.mutation.Where(ps...) _d.mutation.Where(ps...)
return rsd return _d
} }
// Exec executes the deletion query and returns how many vertices were deleted. // Exec executes the deletion query and returns how many vertices were deleted.
func (rsd *RoundStatsDelete) Exec(ctx context.Context) (int, error) { func (_d *RoundStatsDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, rsd.sqlExec, rsd.mutation, rsd.hooks) return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (rsd *RoundStatsDelete) ExecX(ctx context.Context) int { func (_d *RoundStatsDelete) ExecX(ctx context.Context) int {
n, err := rsd.Exec(ctx) n, err := _d.Exec(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
return n 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)) _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) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) 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) { if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
rsd.mutation.done = true _d.mutation.done = true
return affected, err return affected, err
} }
// RoundStatsDeleteOne is the builder for deleting a single RoundStats entity. // RoundStatsDeleteOne is the builder for deleting a single RoundStats entity.
type RoundStatsDeleteOne struct { type RoundStatsDeleteOne struct {
rsd *RoundStatsDelete _d *RoundStatsDelete
} }
// Where appends a list predicates to the RoundStatsDelete builder. // Where appends a list predicates to the RoundStatsDelete builder.
func (rsdo *RoundStatsDeleteOne) Where(ps ...predicate.RoundStats) *RoundStatsDeleteOne { func (_d *RoundStatsDeleteOne) Where(ps ...predicate.RoundStats) *RoundStatsDeleteOne {
rsdo.rsd.mutation.Where(ps...) _d._d.mutation.Where(ps...)
return rsdo return _d
} }
// Exec executes the deletion query. // Exec executes the deletion query.
func (rsdo *RoundStatsDeleteOne) Exec(ctx context.Context) error { func (_d *RoundStatsDeleteOne) Exec(ctx context.Context) error {
n, err := rsdo.rsd.Exec(ctx) n, err := _d._d.Exec(ctx)
switch { switch {
case err != nil: case err != nil:
return err return err
@@ -81,8 +81,8 @@ func (rsdo *RoundStatsDeleteOne) Exec(ctx context.Context) error {
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (rsdo *RoundStatsDeleteOne) ExecX(ctx context.Context) { func (_d *RoundStatsDeleteOne) ExecX(ctx context.Context) {
if err := rsdo.Exec(ctx); err != nil { if err := _d.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }

View File

@@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"math" "math"
"entgo.io/ent"
"entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field" "entgo.io/ent/schema/field"
@@ -31,44 +32,44 @@ type RoundStatsQuery struct {
} }
// Where adds a new predicate for the RoundStatsQuery builder. // Where adds a new predicate for the RoundStatsQuery builder.
func (rsq *RoundStatsQuery) Where(ps ...predicate.RoundStats) *RoundStatsQuery { func (_q *RoundStatsQuery) Where(ps ...predicate.RoundStats) *RoundStatsQuery {
rsq.predicates = append(rsq.predicates, ps...) _q.predicates = append(_q.predicates, ps...)
return rsq return _q
} }
// Limit the number of records to be returned by this query. // Limit the number of records to be returned by this query.
func (rsq *RoundStatsQuery) Limit(limit int) *RoundStatsQuery { func (_q *RoundStatsQuery) Limit(limit int) *RoundStatsQuery {
rsq.ctx.Limit = &limit _q.ctx.Limit = &limit
return rsq return _q
} }
// Offset to start from. // Offset to start from.
func (rsq *RoundStatsQuery) Offset(offset int) *RoundStatsQuery { func (_q *RoundStatsQuery) Offset(offset int) *RoundStatsQuery {
rsq.ctx.Offset = &offset _q.ctx.Offset = &offset
return rsq return _q
} }
// Unique configures the query builder to filter duplicate records on query. // 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. // By default, unique is set to true, and can be disabled using this method.
func (rsq *RoundStatsQuery) Unique(unique bool) *RoundStatsQuery { func (_q *RoundStatsQuery) Unique(unique bool) *RoundStatsQuery {
rsq.ctx.Unique = &unique _q.ctx.Unique = &unique
return rsq return _q
} }
// Order specifies how the records should be ordered. // Order specifies how the records should be ordered.
func (rsq *RoundStatsQuery) Order(o ...roundstats.OrderOption) *RoundStatsQuery { func (_q *RoundStatsQuery) Order(o ...roundstats.OrderOption) *RoundStatsQuery {
rsq.order = append(rsq.order, o...) _q.order = append(_q.order, o...)
return rsq return _q
} }
// QueryMatchPlayer chains the current query on the "match_player" edge. // QueryMatchPlayer chains the current query on the "match_player" edge.
func (rsq *RoundStatsQuery) QueryMatchPlayer() *MatchPlayerQuery { func (_q *RoundStatsQuery) QueryMatchPlayer() *MatchPlayerQuery {
query := (&MatchPlayerClient{config: rsq.config}).Query() query := (&MatchPlayerClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { 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 return nil, err
} }
selector := rsq.sqlQuery(ctx) selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return nil, err return nil, err
} }
@@ -77,7 +78,7 @@ func (rsq *RoundStatsQuery) QueryMatchPlayer() *MatchPlayerQuery {
sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, roundstats.MatchPlayerTable, roundstats.MatchPlayerColumn), 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 fromU, nil
} }
return query return query
@@ -85,8 +86,8 @@ func (rsq *RoundStatsQuery) QueryMatchPlayer() *MatchPlayerQuery {
// First returns the first RoundStats entity from the query. // First returns the first RoundStats entity from the query.
// Returns a *NotFoundError when no RoundStats was found. // Returns a *NotFoundError when no RoundStats was found.
func (rsq *RoundStatsQuery) First(ctx context.Context) (*RoundStats, error) { func (_q *RoundStatsQuery) First(ctx context.Context) (*RoundStats, error) {
nodes, err := rsq.Limit(1).All(setContextOp(ctx, rsq.ctx, "First")) nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
if err != nil { if err != nil {
return nil, err 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. // FirstX is like First, but panics if an error occurs.
func (rsq *RoundStatsQuery) FirstX(ctx context.Context) *RoundStats { func (_q *RoundStatsQuery) FirstX(ctx context.Context) *RoundStats {
node, err := rsq.First(ctx) node, err := _q.First(ctx)
if err != nil && !IsNotFound(err) { if err != nil && !IsNotFound(err) {
panic(err) panic(err)
} }
@@ -107,9 +108,9 @@ func (rsq *RoundStatsQuery) FirstX(ctx context.Context) *RoundStats {
// FirstID returns the first RoundStats ID from the query. // FirstID returns the first RoundStats ID from the query.
// Returns a *NotFoundError when no RoundStats ID was found. // 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 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 return
} }
if len(ids) == 0 { 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. // FirstIDX is like FirstID, but panics if an error occurs.
func (rsq *RoundStatsQuery) FirstIDX(ctx context.Context) int { func (_q *RoundStatsQuery) FirstIDX(ctx context.Context) int {
id, err := rsq.FirstID(ctx) id, err := _q.FirstID(ctx)
if err != nil && !IsNotFound(err) { if err != nil && !IsNotFound(err) {
panic(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. // 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 *NotSingularError when more than one RoundStats entity is found.
// Returns a *NotFoundError when no RoundStats entities are found. // Returns a *NotFoundError when no RoundStats entities are found.
func (rsq *RoundStatsQuery) Only(ctx context.Context) (*RoundStats, error) { func (_q *RoundStatsQuery) Only(ctx context.Context) (*RoundStats, error) {
nodes, err := rsq.Limit(2).All(setContextOp(ctx, rsq.ctx, "Only")) nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
if err != nil { if err != nil {
return nil, err 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. // OnlyX is like Only, but panics if an error occurs.
func (rsq *RoundStatsQuery) OnlyX(ctx context.Context) *RoundStats { func (_q *RoundStatsQuery) OnlyX(ctx context.Context) *RoundStats {
node, err := rsq.Only(ctx) node, err := _q.Only(ctx)
if err != nil { if err != nil {
panic(err) 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. // 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 *NotSingularError when more than one RoundStats ID is found.
// Returns a *NotFoundError when no entities are 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 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 return
} }
switch len(ids) { 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. // OnlyIDX is like OnlyID, but panics if an error occurs.
func (rsq *RoundStatsQuery) OnlyIDX(ctx context.Context) int { func (_q *RoundStatsQuery) OnlyIDX(ctx context.Context) int {
id, err := rsq.OnlyID(ctx) id, err := _q.OnlyID(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -184,18 +185,18 @@ func (rsq *RoundStatsQuery) OnlyIDX(ctx context.Context) int {
} }
// All executes the query and returns a list of RoundStatsSlice. // All executes the query and returns a list of RoundStatsSlice.
func (rsq *RoundStatsQuery) All(ctx context.Context) ([]*RoundStats, error) { func (_q *RoundStatsQuery) All(ctx context.Context) ([]*RoundStats, error) {
ctx = setContextOp(ctx, rsq.ctx, "All") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
if err := rsq.prepareQuery(ctx); err != nil { if err := _q.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
qr := querierAll[[]*RoundStats, *RoundStatsQuery]() 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. // AllX is like All, but panics if an error occurs.
func (rsq *RoundStatsQuery) AllX(ctx context.Context) []*RoundStats { func (_q *RoundStatsQuery) AllX(ctx context.Context) []*RoundStats {
nodes, err := rsq.All(ctx) nodes, err := _q.All(ctx)
if err != nil { if err != nil {
panic(err) 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. // IDs executes the query and returns a list of RoundStats IDs.
func (rsq *RoundStatsQuery) IDs(ctx context.Context) (ids []int, err error) { func (_q *RoundStatsQuery) IDs(ctx context.Context) (ids []int, err error) {
if rsq.ctx.Unique == nil && rsq.path != nil { if _q.ctx.Unique == nil && _q.path != nil {
rsq.Unique(true) _q.Unique(true)
} }
ctx = setContextOp(ctx, rsq.ctx, "IDs") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
if err = rsq.Select(roundstats.FieldID).Scan(ctx, &ids); err != nil { if err = _q.Select(roundstats.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
return ids, nil return ids, nil
} }
// IDsX is like IDs, but panics if an error occurs. // IDsX is like IDs, but panics if an error occurs.
func (rsq *RoundStatsQuery) IDsX(ctx context.Context) []int { func (_q *RoundStatsQuery) IDsX(ctx context.Context) []int {
ids, err := rsq.IDs(ctx) ids, err := _q.IDs(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -224,17 +225,17 @@ func (rsq *RoundStatsQuery) IDsX(ctx context.Context) []int {
} }
// Count returns the count of the given query. // Count returns the count of the given query.
func (rsq *RoundStatsQuery) Count(ctx context.Context) (int, error) { func (_q *RoundStatsQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, rsq.ctx, "Count") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
if err := rsq.prepareQuery(ctx); err != nil { if err := _q.prepareQuery(ctx); err != nil {
return 0, err 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. // CountX is like Count, but panics if an error occurs.
func (rsq *RoundStatsQuery) CountX(ctx context.Context) int { func (_q *RoundStatsQuery) CountX(ctx context.Context) int {
count, err := rsq.Count(ctx) count, err := _q.Count(ctx)
if err != nil { if err != nil {
panic(err) 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. // Exist returns true if the query has elements in the graph.
func (rsq *RoundStatsQuery) Exist(ctx context.Context) (bool, error) { func (_q *RoundStatsQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, rsq.ctx, "Exist") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
switch _, err := rsq.FirstID(ctx); { switch _, err := _q.FirstID(ctx); {
case IsNotFound(err): case IsNotFound(err):
return false, nil return false, nil
case err != 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. // ExistX is like Exist, but panics if an error occurs.
func (rsq *RoundStatsQuery) ExistX(ctx context.Context) bool { func (_q *RoundStatsQuery) ExistX(ctx context.Context) bool {
exist, err := rsq.Exist(ctx) exist, err := _q.Exist(ctx)
if err != nil { if err != nil {
panic(err) 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 // 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. // used to prepare common query builders and use them differently after the clone is made.
func (rsq *RoundStatsQuery) Clone() *RoundStatsQuery { func (_q *RoundStatsQuery) Clone() *RoundStatsQuery {
if rsq == nil { if _q == nil {
return nil return nil
} }
return &RoundStatsQuery{ return &RoundStatsQuery{
config: rsq.config, config: _q.config,
ctx: rsq.ctx.Clone(), ctx: _q.ctx.Clone(),
order: append([]roundstats.OrderOption{}, rsq.order...), order: append([]roundstats.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, rsq.inters...), inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.RoundStats{}, rsq.predicates...), predicates: append([]predicate.RoundStats{}, _q.predicates...),
withMatchPlayer: rsq.withMatchPlayer.Clone(), withMatchPlayer: _q.withMatchPlayer.Clone(),
// clone intermediate query. // clone intermediate query.
sql: rsq.sql.Clone(), sql: _q.sql.Clone(),
path: rsq.path, path: _q.path,
modifiers: append([]func(*sql.Selector){}, _q.modifiers...),
} }
} }
// WithMatchPlayer tells the query-builder to eager-load the nodes that are connected to // 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. // 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 { func (_q *RoundStatsQuery) WithMatchPlayer(opts ...func(*MatchPlayerQuery)) *RoundStatsQuery {
query := (&MatchPlayerClient{config: rsq.config}).Query() query := (&MatchPlayerClient{config: _q.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
rsq.withMatchPlayer = query _q.withMatchPlayer = query
return rsq return _q
} }
// GroupBy is used to group vertices by one or more fields/columns. // 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). // GroupBy(roundstats.FieldRound).
// Aggregate(ent.Count()). // Aggregate(ent.Count()).
// Scan(ctx, &v) // Scan(ctx, &v)
func (rsq *RoundStatsQuery) GroupBy(field string, fields ...string) *RoundStatsGroupBy { func (_q *RoundStatsQuery) GroupBy(field string, fields ...string) *RoundStatsGroupBy {
rsq.ctx.Fields = append([]string{field}, fields...) _q.ctx.Fields = append([]string{field}, fields...)
grbuild := &RoundStatsGroupBy{build: rsq} grbuild := &RoundStatsGroupBy{build: _q}
grbuild.flds = &rsq.ctx.Fields grbuild.flds = &_q.ctx.Fields
grbuild.label = roundstats.Label grbuild.label = roundstats.Label
grbuild.scan = grbuild.Scan grbuild.scan = grbuild.Scan
return grbuild return grbuild
@@ -328,55 +330,55 @@ func (rsq *RoundStatsQuery) GroupBy(field string, fields ...string) *RoundStatsG
// client.RoundStats.Query(). // client.RoundStats.Query().
// Select(roundstats.FieldRound). // Select(roundstats.FieldRound).
// Scan(ctx, &v) // Scan(ctx, &v)
func (rsq *RoundStatsQuery) Select(fields ...string) *RoundStatsSelect { func (_q *RoundStatsQuery) Select(fields ...string) *RoundStatsSelect {
rsq.ctx.Fields = append(rsq.ctx.Fields, fields...) _q.ctx.Fields = append(_q.ctx.Fields, fields...)
sbuild := &RoundStatsSelect{RoundStatsQuery: rsq} sbuild := &RoundStatsSelect{RoundStatsQuery: _q}
sbuild.label = roundstats.Label sbuild.label = roundstats.Label
sbuild.flds, sbuild.scan = &rsq.ctx.Fields, sbuild.Scan sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
return sbuild return sbuild
} }
// Aggregate returns a RoundStatsSelect configured with the given aggregations. // Aggregate returns a RoundStatsSelect configured with the given aggregations.
func (rsq *RoundStatsQuery) Aggregate(fns ...AggregateFunc) *RoundStatsSelect { func (_q *RoundStatsQuery) Aggregate(fns ...AggregateFunc) *RoundStatsSelect {
return rsq.Select().Aggregate(fns...) return _q.Select().Aggregate(fns...)
} }
func (rsq *RoundStatsQuery) prepareQuery(ctx context.Context) error { func (_q *RoundStatsQuery) prepareQuery(ctx context.Context) error {
for _, inter := range rsq.inters { for _, inter := range _q.inters {
if inter == nil { if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
} }
if trv, ok := inter.(Traverser); ok { if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, rsq); err != nil { if err := trv.Traverse(ctx, _q); err != nil {
return err return err
} }
} }
} }
for _, f := range rsq.ctx.Fields { for _, f := range _q.ctx.Fields {
if !roundstats.ValidColumn(f) { if !roundstats.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
} }
} }
if rsq.path != nil { if _q.path != nil {
prev, err := rsq.path(ctx) prev, err := _q.path(ctx)
if err != nil { if err != nil {
return err return err
} }
rsq.sql = prev _q.sql = prev
} }
return nil 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 ( var (
nodes = []*RoundStats{} nodes = []*RoundStats{}
withFKs = rsq.withFKs withFKs = _q.withFKs
_spec = rsq.querySpec() _spec = _q.querySpec()
loadedTypes = [1]bool{ loadedTypes = [1]bool{
rsq.withMatchPlayer != nil, _q.withMatchPlayer != nil,
} }
) )
if rsq.withMatchPlayer != nil { if _q.withMatchPlayer != nil {
withFKs = true withFKs = true
} }
if withFKs { if withFKs {
@@ -386,25 +388,25 @@ func (rsq *RoundStatsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*
return (*RoundStats).scanValues(nil, columns) return (*RoundStats).scanValues(nil, columns)
} }
_spec.Assign = func(columns []string, values []any) error { _spec.Assign = func(columns []string, values []any) error {
node := &RoundStats{config: rsq.config} node := &RoundStats{config: _q.config}
nodes = append(nodes, node) nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values) return node.assignValues(columns, values)
} }
if len(rsq.modifiers) > 0 { if len(_q.modifiers) > 0 {
_spec.Modifiers = rsq.modifiers _spec.Modifiers = _q.modifiers
} }
for i := range hooks { for i := range hooks {
hooks[i](ctx, _spec) 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 return nil, err
} }
if len(nodes) == 0 { if len(nodes) == 0 {
return nodes, nil return nodes, nil
} }
if query := rsq.withMatchPlayer; query != nil { if query := _q.withMatchPlayer; query != nil {
if err := rsq.loadMatchPlayer(ctx, query, nodes, nil, if err := _q.loadMatchPlayer(ctx, query, nodes, nil,
func(n *RoundStats, e *MatchPlayer) { n.Edges.MatchPlayer = e }); err != nil { func(n *RoundStats, e *MatchPlayer) { n.Edges.MatchPlayer = e }); err != nil {
return nil, err return nil, err
} }
@@ -412,7 +414,7 @@ func (rsq *RoundStatsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*
return nodes, nil 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)) ids := make([]int, 0, len(nodes))
nodeids := make(map[int][]*RoundStats) nodeids := make(map[int][]*RoundStats)
for i := range nodes { for i := range nodes {
@@ -445,27 +447,27 @@ func (rsq *RoundStatsQuery) loadMatchPlayer(ctx context.Context, query *MatchPla
return nil return nil
} }
func (rsq *RoundStatsQuery) sqlCount(ctx context.Context) (int, error) { func (_q *RoundStatsQuery) sqlCount(ctx context.Context) (int, error) {
_spec := rsq.querySpec() _spec := _q.querySpec()
if len(rsq.modifiers) > 0 { if len(_q.modifiers) > 0 {
_spec.Modifiers = rsq.modifiers _spec.Modifiers = _q.modifiers
} }
_spec.Node.Columns = rsq.ctx.Fields _spec.Node.Columns = _q.ctx.Fields
if len(rsq.ctx.Fields) > 0 { if len(_q.ctx.Fields) > 0 {
_spec.Unique = rsq.ctx.Unique != nil && *rsq.ctx.Unique _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 := sqlgraph.NewQuerySpec(roundstats.Table, roundstats.Columns, sqlgraph.NewFieldSpec(roundstats.FieldID, field.TypeInt))
_spec.From = rsq.sql _spec.From = _q.sql
if unique := rsq.ctx.Unique; unique != nil { if unique := _q.ctx.Unique; unique != nil {
_spec.Unique = *unique _spec.Unique = *unique
} else if rsq.path != nil { } else if _q.path != nil {
_spec.Unique = true _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 = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, roundstats.FieldID) _spec.Node.Columns = append(_spec.Node.Columns, roundstats.FieldID)
for i := range fields { 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) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) ps[i](selector)
} }
} }
} }
if limit := rsq.ctx.Limit; limit != nil { if limit := _q.ctx.Limit; limit != nil {
_spec.Limit = *limit _spec.Limit = *limit
} }
if offset := rsq.ctx.Offset; offset != nil { if offset := _q.ctx.Offset; offset != nil {
_spec.Offset = *offset _spec.Offset = *offset
} }
if ps := rsq.order; len(ps) > 0 { if ps := _q.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) { _spec.Order = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) ps[i](selector)
@@ -497,45 +499,45 @@ func (rsq *RoundStatsQuery) querySpec() *sqlgraph.QuerySpec {
return _spec return _spec
} }
func (rsq *RoundStatsQuery) sqlQuery(ctx context.Context) *sql.Selector { func (_q *RoundStatsQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(rsq.driver.Dialect()) builder := sql.Dialect(_q.driver.Dialect())
t1 := builder.Table(roundstats.Table) t1 := builder.Table(roundstats.Table)
columns := rsq.ctx.Fields columns := _q.ctx.Fields
if len(columns) == 0 { if len(columns) == 0 {
columns = roundstats.Columns columns = roundstats.Columns
} }
selector := builder.Select(t1.Columns(columns...)...).From(t1) selector := builder.Select(t1.Columns(columns...)...).From(t1)
if rsq.sql != nil { if _q.sql != nil {
selector = rsq.sql selector = _q.sql
selector.Select(selector.Columns(columns...)...) selector.Select(selector.Columns(columns...)...)
} }
if rsq.ctx.Unique != nil && *rsq.ctx.Unique { if _q.ctx.Unique != nil && *_q.ctx.Unique {
selector.Distinct() selector.Distinct()
} }
for _, m := range rsq.modifiers { for _, m := range _q.modifiers {
m(selector) m(selector)
} }
for _, p := range rsq.predicates { for _, p := range _q.predicates {
p(selector) p(selector)
} }
for _, p := range rsq.order { for _, p := range _q.order {
p(selector) p(selector)
} }
if offset := rsq.ctx.Offset; offset != nil { if offset := _q.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start // limit is mandatory for offset clause. We start
// with default value, and override it below if needed. // with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32) selector.Offset(*offset).Limit(math.MaxInt32)
} }
if limit := rsq.ctx.Limit; limit != nil { if limit := _q.ctx.Limit; limit != nil {
selector.Limit(*limit) selector.Limit(*limit)
} }
return selector return selector
} }
// Modify adds a query modifier for attaching custom logic to queries. // Modify adds a query modifier for attaching custom logic to queries.
func (rsq *RoundStatsQuery) Modify(modifiers ...func(s *sql.Selector)) *RoundStatsSelect { func (_q *RoundStatsQuery) Modify(modifiers ...func(s *sql.Selector)) *RoundStatsSelect {
rsq.modifiers = append(rsq.modifiers, modifiers...) _q.modifiers = append(_q.modifiers, modifiers...)
return rsq.Select() return _q.Select()
} }
// RoundStatsGroupBy is the group-by builder for RoundStats entities. // 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. // Aggregate adds the given aggregation functions to the group-by query.
func (rsgb *RoundStatsGroupBy) Aggregate(fns ...AggregateFunc) *RoundStatsGroupBy { func (_g *RoundStatsGroupBy) Aggregate(fns ...AggregateFunc) *RoundStatsGroupBy {
rsgb.fns = append(rsgb.fns, fns...) _g.fns = append(_g.fns, fns...)
return rsgb return _g
} }
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (rsgb *RoundStatsGroupBy) Scan(ctx context.Context, v any) error { func (_g *RoundStatsGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, rsgb.build.ctx, "GroupBy") ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
if err := rsgb.build.prepareQuery(ctx); err != nil { if err := _g.build.prepareQuery(ctx); err != nil {
return err 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() selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(rsgb.fns)) aggregation := make([]string, 0, len(_g.fns))
for _, fn := range rsgb.fns { for _, fn := range _g.fns {
aggregation = append(aggregation, fn(selector)) aggregation = append(aggregation, fn(selector))
} }
if len(selector.SelectedColumns()) == 0 { if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*rsgb.flds)+len(rsgb.fns)) columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
for _, f := range *rsgb.flds { for _, f := range *_g.flds {
columns = append(columns, selector.C(f)) columns = append(columns, selector.C(f))
} }
columns = append(columns, aggregation...) columns = append(columns, aggregation...)
selector.Select(columns...) selector.Select(columns...)
} }
selector.GroupBy(selector.Columns(*rsgb.flds...)...) selector.GroupBy(selector.Columns(*_g.flds...)...)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return err return err
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := selector.Query() 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 return err
} }
defer rows.Close() defer rows.Close()
@@ -593,27 +595,27 @@ type RoundStatsSelect struct {
} }
// Aggregate adds the given aggregation functions to the selector query. // Aggregate adds the given aggregation functions to the selector query.
func (rss *RoundStatsSelect) Aggregate(fns ...AggregateFunc) *RoundStatsSelect { func (_s *RoundStatsSelect) Aggregate(fns ...AggregateFunc) *RoundStatsSelect {
rss.fns = append(rss.fns, fns...) _s.fns = append(_s.fns, fns...)
return rss return _s
} }
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (rss *RoundStatsSelect) Scan(ctx context.Context, v any) error { func (_s *RoundStatsSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, rss.ctx, "Select") ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
if err := rss.prepareQuery(ctx); err != nil { if err := _s.prepareQuery(ctx); err != nil {
return err 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) selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(rss.fns)) aggregation := make([]string, 0, len(_s.fns))
for _, fn := range rss.fns { for _, fn := range _s.fns {
aggregation = append(aggregation, fn(selector)) aggregation = append(aggregation, fn(selector))
} }
switch n := len(*rss.selector.flds); { switch n := len(*_s.selector.flds); {
case n == 0 && len(aggregation) > 0: case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...) selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0: case n != 0 && len(aggregation) > 0:
@@ -621,7 +623,7 @@ func (rss *RoundStatsSelect) sqlScan(ctx context.Context, root *RoundStatsQuery,
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := selector.Query() 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 return err
} }
defer rows.Close() 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. // Modify adds a query modifier for attaching custom logic to queries.
func (rss *RoundStatsSelect) Modify(modifiers ...func(s *sql.Selector)) *RoundStatsSelect { func (_s *RoundStatsSelect) Modify(modifiers ...func(s *sql.Selector)) *RoundStatsSelect {
rss.modifiers = append(rss.modifiers, modifiers...) _s.modifiers = append(_s.modifiers, modifiers...)
return rss return _s
} }

View File

@@ -24,101 +24,133 @@ type RoundStatsUpdate struct {
} }
// Where appends a list predicates to the RoundStatsUpdate builder. // Where appends a list predicates to the RoundStatsUpdate builder.
func (rsu *RoundStatsUpdate) Where(ps ...predicate.RoundStats) *RoundStatsUpdate { func (_u *RoundStatsUpdate) Where(ps ...predicate.RoundStats) *RoundStatsUpdate {
rsu.mutation.Where(ps...) _u.mutation.Where(ps...)
return rsu return _u
} }
// SetRound sets the "round" field. // SetRound sets the "round" field.
func (rsu *RoundStatsUpdate) SetRound(u uint) *RoundStatsUpdate { func (_u *RoundStatsUpdate) SetRound(v uint) *RoundStatsUpdate {
rsu.mutation.ResetRound() _u.mutation.ResetRound()
rsu.mutation.SetRound(u) _u.mutation.SetRound(v)
return rsu return _u
} }
// AddRound adds u to the "round" field. // SetNillableRound sets the "round" field if the given value is not nil.
func (rsu *RoundStatsUpdate) AddRound(u int) *RoundStatsUpdate { func (_u *RoundStatsUpdate) SetNillableRound(v *uint) *RoundStatsUpdate {
rsu.mutation.AddRound(u) if v != nil {
return rsu _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. // SetBank sets the "bank" field.
func (rsu *RoundStatsUpdate) SetBank(u uint) *RoundStatsUpdate { func (_u *RoundStatsUpdate) SetBank(v uint) *RoundStatsUpdate {
rsu.mutation.ResetBank() _u.mutation.ResetBank()
rsu.mutation.SetBank(u) _u.mutation.SetBank(v)
return rsu return _u
} }
// AddBank adds u to the "bank" field. // SetNillableBank sets the "bank" field if the given value is not nil.
func (rsu *RoundStatsUpdate) AddBank(u int) *RoundStatsUpdate { func (_u *RoundStatsUpdate) SetNillableBank(v *uint) *RoundStatsUpdate {
rsu.mutation.AddBank(u) if v != nil {
return rsu _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. // SetEquipment sets the "equipment" field.
func (rsu *RoundStatsUpdate) SetEquipment(u uint) *RoundStatsUpdate { func (_u *RoundStatsUpdate) SetEquipment(v uint) *RoundStatsUpdate {
rsu.mutation.ResetEquipment() _u.mutation.ResetEquipment()
rsu.mutation.SetEquipment(u) _u.mutation.SetEquipment(v)
return rsu return _u
} }
// AddEquipment adds u to the "equipment" field. // SetNillableEquipment sets the "equipment" field if the given value is not nil.
func (rsu *RoundStatsUpdate) AddEquipment(u int) *RoundStatsUpdate { func (_u *RoundStatsUpdate) SetNillableEquipment(v *uint) *RoundStatsUpdate {
rsu.mutation.AddEquipment(u) if v != nil {
return rsu _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. // SetSpent sets the "spent" field.
func (rsu *RoundStatsUpdate) SetSpent(u uint) *RoundStatsUpdate { func (_u *RoundStatsUpdate) SetSpent(v uint) *RoundStatsUpdate {
rsu.mutation.ResetSpent() _u.mutation.ResetSpent()
rsu.mutation.SetSpent(u) _u.mutation.SetSpent(v)
return rsu return _u
} }
// AddSpent adds u to the "spent" field. // SetNillableSpent sets the "spent" field if the given value is not nil.
func (rsu *RoundStatsUpdate) AddSpent(u int) *RoundStatsUpdate { func (_u *RoundStatsUpdate) SetNillableSpent(v *uint) *RoundStatsUpdate {
rsu.mutation.AddSpent(u) if v != nil {
return rsu _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. // SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID.
func (rsu *RoundStatsUpdate) SetMatchPlayerID(id int) *RoundStatsUpdate { func (_u *RoundStatsUpdate) SetMatchPlayerID(id int) *RoundStatsUpdate {
rsu.mutation.SetMatchPlayerID(id) _u.mutation.SetMatchPlayerID(id)
return rsu return _u
} }
// SetNillableMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID if the given value is not nil. // 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 { 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. // SetMatchPlayer sets the "match_player" edge to the MatchPlayer entity.
func (rsu *RoundStatsUpdate) SetMatchPlayer(m *MatchPlayer) *RoundStatsUpdate { func (_u *RoundStatsUpdate) SetMatchPlayer(v *MatchPlayer) *RoundStatsUpdate {
return rsu.SetMatchPlayerID(m.ID) return _u.SetMatchPlayerID(v.ID)
} }
// Mutation returns the RoundStatsMutation object of the builder. // Mutation returns the RoundStatsMutation object of the builder.
func (rsu *RoundStatsUpdate) Mutation() *RoundStatsMutation { func (_u *RoundStatsUpdate) Mutation() *RoundStatsMutation {
return rsu.mutation return _u.mutation
} }
// ClearMatchPlayer clears the "match_player" edge to the MatchPlayer entity. // ClearMatchPlayer clears the "match_player" edge to the MatchPlayer entity.
func (rsu *RoundStatsUpdate) ClearMatchPlayer() *RoundStatsUpdate { func (_u *RoundStatsUpdate) ClearMatchPlayer() *RoundStatsUpdate {
rsu.mutation.ClearMatchPlayer() _u.mutation.ClearMatchPlayer()
return rsu return _u
} }
// Save executes the query and returns the number of nodes affected by the update operation. // Save executes the query and returns the number of nodes affected by the update operation.
func (rsu *RoundStatsUpdate) Save(ctx context.Context) (int, error) { func (_u *RoundStatsUpdate) Save(ctx context.Context) (int, error) {
return withHooks(ctx, rsu.sqlSave, rsu.mutation, rsu.hooks) return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
func (rsu *RoundStatsUpdate) SaveX(ctx context.Context) int { func (_u *RoundStatsUpdate) SaveX(ctx context.Context) int {
affected, err := rsu.Save(ctx) affected, err := _u.Save(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -126,58 +158,58 @@ func (rsu *RoundStatsUpdate) SaveX(ctx context.Context) int {
} }
// Exec executes the query. // Exec executes the query.
func (rsu *RoundStatsUpdate) Exec(ctx context.Context) error { func (_u *RoundStatsUpdate) Exec(ctx context.Context) error {
_, err := rsu.Save(ctx) _, err := _u.Save(ctx)
return err return err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (rsu *RoundStatsUpdate) ExecX(ctx context.Context) { func (_u *RoundStatsUpdate) ExecX(ctx context.Context) {
if err := rsu.Exec(ctx); err != nil { if err := _u.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. // Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (rsu *RoundStatsUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RoundStatsUpdate { func (_u *RoundStatsUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RoundStatsUpdate {
rsu.modifiers = append(rsu.modifiers, modifiers...) _u.modifiers = append(_u.modifiers, modifiers...)
return rsu 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)) _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) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) ps[i](selector)
} }
} }
} }
if value, ok := rsu.mutation.Round(); ok { if value, ok := _u.mutation.Round(); ok {
_spec.SetField(roundstats.FieldRound, field.TypeUint, value) _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) _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) _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) _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) _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) _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) _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) _spec.AddField(roundstats.FieldSpent, field.TypeUint, value)
} }
if rsu.mutation.MatchPlayerCleared() { if _u.mutation.MatchPlayerCleared() {
edge := &sqlgraph.EdgeSpec{ edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O, Rel: sqlgraph.M2O,
Inverse: true, 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) _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{ edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O, Rel: sqlgraph.M2O,
Inverse: true, 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.Edges.Add = append(_spec.Edges.Add, edge)
} }
_spec.AddModifiers(rsu.modifiers...) _spec.AddModifiers(_u.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, rsu.driver, _spec); err != nil { if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok { if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{roundstats.Label} err = &NotFoundError{roundstats.Label}
} else if sqlgraph.IsConstraintError(err) { } else if sqlgraph.IsConstraintError(err) {
@@ -215,8 +247,8 @@ func (rsu *RoundStatsUpdate) sqlSave(ctx context.Context) (n int, err error) {
} }
return 0, err return 0, err
} }
rsu.mutation.done = true _u.mutation.done = true
return n, nil return _node, nil
} }
// RoundStatsUpdateOne is the builder for updating a single RoundStats entity. // RoundStatsUpdateOne is the builder for updating a single RoundStats entity.
@@ -229,108 +261,140 @@ type RoundStatsUpdateOne struct {
} }
// SetRound sets the "round" field. // SetRound sets the "round" field.
func (rsuo *RoundStatsUpdateOne) SetRound(u uint) *RoundStatsUpdateOne { func (_u *RoundStatsUpdateOne) SetRound(v uint) *RoundStatsUpdateOne {
rsuo.mutation.ResetRound() _u.mutation.ResetRound()
rsuo.mutation.SetRound(u) _u.mutation.SetRound(v)
return rsuo return _u
} }
// AddRound adds u to the "round" field. // SetNillableRound sets the "round" field if the given value is not nil.
func (rsuo *RoundStatsUpdateOne) AddRound(u int) *RoundStatsUpdateOne { func (_u *RoundStatsUpdateOne) SetNillableRound(v *uint) *RoundStatsUpdateOne {
rsuo.mutation.AddRound(u) if v != nil {
return rsuo _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. // SetBank sets the "bank" field.
func (rsuo *RoundStatsUpdateOne) SetBank(u uint) *RoundStatsUpdateOne { func (_u *RoundStatsUpdateOne) SetBank(v uint) *RoundStatsUpdateOne {
rsuo.mutation.ResetBank() _u.mutation.ResetBank()
rsuo.mutation.SetBank(u) _u.mutation.SetBank(v)
return rsuo return _u
} }
// AddBank adds u to the "bank" field. // SetNillableBank sets the "bank" field if the given value is not nil.
func (rsuo *RoundStatsUpdateOne) AddBank(u int) *RoundStatsUpdateOne { func (_u *RoundStatsUpdateOne) SetNillableBank(v *uint) *RoundStatsUpdateOne {
rsuo.mutation.AddBank(u) if v != nil {
return rsuo _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. // SetEquipment sets the "equipment" field.
func (rsuo *RoundStatsUpdateOne) SetEquipment(u uint) *RoundStatsUpdateOne { func (_u *RoundStatsUpdateOne) SetEquipment(v uint) *RoundStatsUpdateOne {
rsuo.mutation.ResetEquipment() _u.mutation.ResetEquipment()
rsuo.mutation.SetEquipment(u) _u.mutation.SetEquipment(v)
return rsuo return _u
} }
// AddEquipment adds u to the "equipment" field. // SetNillableEquipment sets the "equipment" field if the given value is not nil.
func (rsuo *RoundStatsUpdateOne) AddEquipment(u int) *RoundStatsUpdateOne { func (_u *RoundStatsUpdateOne) SetNillableEquipment(v *uint) *RoundStatsUpdateOne {
rsuo.mutation.AddEquipment(u) if v != nil {
return rsuo _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. // SetSpent sets the "spent" field.
func (rsuo *RoundStatsUpdateOne) SetSpent(u uint) *RoundStatsUpdateOne { func (_u *RoundStatsUpdateOne) SetSpent(v uint) *RoundStatsUpdateOne {
rsuo.mutation.ResetSpent() _u.mutation.ResetSpent()
rsuo.mutation.SetSpent(u) _u.mutation.SetSpent(v)
return rsuo return _u
} }
// AddSpent adds u to the "spent" field. // SetNillableSpent sets the "spent" field if the given value is not nil.
func (rsuo *RoundStatsUpdateOne) AddSpent(u int) *RoundStatsUpdateOne { func (_u *RoundStatsUpdateOne) SetNillableSpent(v *uint) *RoundStatsUpdateOne {
rsuo.mutation.AddSpent(u) if v != nil {
return rsuo _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. // SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID.
func (rsuo *RoundStatsUpdateOne) SetMatchPlayerID(id int) *RoundStatsUpdateOne { func (_u *RoundStatsUpdateOne) SetMatchPlayerID(id int) *RoundStatsUpdateOne {
rsuo.mutation.SetMatchPlayerID(id) _u.mutation.SetMatchPlayerID(id)
return rsuo return _u
} }
// SetNillableMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID if the given value is not nil. // 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 { 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. // SetMatchPlayer sets the "match_player" edge to the MatchPlayer entity.
func (rsuo *RoundStatsUpdateOne) SetMatchPlayer(m *MatchPlayer) *RoundStatsUpdateOne { func (_u *RoundStatsUpdateOne) SetMatchPlayer(v *MatchPlayer) *RoundStatsUpdateOne {
return rsuo.SetMatchPlayerID(m.ID) return _u.SetMatchPlayerID(v.ID)
} }
// Mutation returns the RoundStatsMutation object of the builder. // Mutation returns the RoundStatsMutation object of the builder.
func (rsuo *RoundStatsUpdateOne) Mutation() *RoundStatsMutation { func (_u *RoundStatsUpdateOne) Mutation() *RoundStatsMutation {
return rsuo.mutation return _u.mutation
} }
// ClearMatchPlayer clears the "match_player" edge to the MatchPlayer entity. // ClearMatchPlayer clears the "match_player" edge to the MatchPlayer entity.
func (rsuo *RoundStatsUpdateOne) ClearMatchPlayer() *RoundStatsUpdateOne { func (_u *RoundStatsUpdateOne) ClearMatchPlayer() *RoundStatsUpdateOne {
rsuo.mutation.ClearMatchPlayer() _u.mutation.ClearMatchPlayer()
return rsuo return _u
} }
// Where appends a list predicates to the RoundStatsUpdate builder. // Where appends a list predicates to the RoundStatsUpdate builder.
func (rsuo *RoundStatsUpdateOne) Where(ps ...predicate.RoundStats) *RoundStatsUpdateOne { func (_u *RoundStatsUpdateOne) Where(ps ...predicate.RoundStats) *RoundStatsUpdateOne {
rsuo.mutation.Where(ps...) _u.mutation.Where(ps...)
return rsuo return _u
} }
// Select allows selecting one or more fields (columns) of the returned entity. // Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema. // The default is selecting all fields defined in the entity schema.
func (rsuo *RoundStatsUpdateOne) Select(field string, fields ...string) *RoundStatsUpdateOne { func (_u *RoundStatsUpdateOne) Select(field string, fields ...string) *RoundStatsUpdateOne {
rsuo.fields = append([]string{field}, fields...) _u.fields = append([]string{field}, fields...)
return rsuo return _u
} }
// Save executes the query and returns the updated RoundStats entity. // Save executes the query and returns the updated RoundStats entity.
func (rsuo *RoundStatsUpdateOne) Save(ctx context.Context) (*RoundStats, error) { func (_u *RoundStatsUpdateOne) Save(ctx context.Context) (*RoundStats, error) {
return withHooks(ctx, rsuo.sqlSave, rsuo.mutation, rsuo.hooks) return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
func (rsuo *RoundStatsUpdateOne) SaveX(ctx context.Context) *RoundStats { func (_u *RoundStatsUpdateOne) SaveX(ctx context.Context) *RoundStats {
node, err := rsuo.Save(ctx) node, err := _u.Save(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -338,32 +402,32 @@ func (rsuo *RoundStatsUpdateOne) SaveX(ctx context.Context) *RoundStats {
} }
// Exec executes the query on the entity. // Exec executes the query on the entity.
func (rsuo *RoundStatsUpdateOne) Exec(ctx context.Context) error { func (_u *RoundStatsUpdateOne) Exec(ctx context.Context) error {
_, err := rsuo.Save(ctx) _, err := _u.Save(ctx)
return err return err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (rsuo *RoundStatsUpdateOne) ExecX(ctx context.Context) { func (_u *RoundStatsUpdateOne) ExecX(ctx context.Context) {
if err := rsuo.Exec(ctx); err != nil { if err := _u.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. // Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (rsuo *RoundStatsUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RoundStatsUpdateOne { func (_u *RoundStatsUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RoundStatsUpdateOne {
rsuo.modifiers = append(rsuo.modifiers, modifiers...) _u.modifiers = append(_u.modifiers, modifiers...)
return rsuo 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)) _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 { if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "RoundStats.id" for update`)} return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "RoundStats.id" for update`)}
} }
_spec.Node.ID.Value = id _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 = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, roundstats.FieldID) _spec.Node.Columns = append(_spec.Node.Columns, roundstats.FieldID)
for _, f := range fields { 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) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) ps[i](selector)
} }
} }
} }
if value, ok := rsuo.mutation.Round(); ok { if value, ok := _u.mutation.Round(); ok {
_spec.SetField(roundstats.FieldRound, field.TypeUint, value) _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) _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) _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) _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) _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) _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) _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) _spec.AddField(roundstats.FieldSpent, field.TypeUint, value)
} }
if rsuo.mutation.MatchPlayerCleared() { if _u.mutation.MatchPlayerCleared() {
edge := &sqlgraph.EdgeSpec{ edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O, Rel: sqlgraph.M2O,
Inverse: true, Inverse: true,
@@ -419,7 +483,7 @@ func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats
} }
_spec.Edges.Clear = append(_spec.Edges.Clear, edge) _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{ edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O, Rel: sqlgraph.M2O,
Inverse: true, Inverse: true,
@@ -435,11 +499,11 @@ func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats
} }
_spec.Edges.Add = append(_spec.Edges.Add, edge) _spec.Edges.Add = append(_spec.Edges.Add, edge)
} }
_spec.AddModifiers(rsuo.modifiers...) _spec.AddModifiers(_u.modifiers...)
_node = &RoundStats{config: rsuo.config} _node = &RoundStats{config: _u.config}
_spec.Assign = _node.assignValues _spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues _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 { if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{roundstats.Label} err = &NotFoundError{roundstats.Label}
} else if sqlgraph.IsConstraintError(err) { } else if sqlgraph.IsConstraintError(err) {
@@ -447,6 +511,6 @@ func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats
} }
return nil, err return nil, err
} }
rsuo.mutation.done = true _u.mutation.done = true
return _node, nil return _node, nil
} }

View File

@@ -5,6 +5,6 @@ package runtime
// The schema-stitching logic is generated in somegit.dev/csgowtf/csgowtfd/ent/runtime.go // The schema-stitching logic is generated in somegit.dev/csgowtf/csgowtfd/ent/runtime.go
const ( const (
Version = "v0.12.3" // Version of ent codegen. Version = "v0.14.5" // Version of ent codegen.
Sum = "h1:N5lO2EOrHpCH5HYfiMOCHYbo+oh5M8GjT0/cx5x6xkk=" // Sum of ent codegen. Sum = "h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4=" // Sum of ent codegen.
) )

View File

@@ -40,12 +40,10 @@ type SprayEdges struct {
// MatchPlayersOrErr returns the MatchPlayers value or an error if the edge // MatchPlayersOrErr returns the MatchPlayers value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found. // was not loaded in eager-loading, or loaded but was not found.
func (e SprayEdges) MatchPlayersOrErr() (*MatchPlayer, error) { func (e SprayEdges) MatchPlayersOrErr() (*MatchPlayer, error) {
if e.loadedTypes[0] { if e.MatchPlayers != nil {
if e.MatchPlayers == nil {
// Edge was loaded but was not found.
return nil, &NotFoundError{label: matchplayer.Label}
}
return e.MatchPlayers, nil return e.MatchPlayers, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: matchplayer.Label}
} }
return nil, &NotLoadedError{edge: "match_players"} 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) // assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Spray fields. // 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 { if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", 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 { if !ok {
return fmt.Errorf("unexpected type %T for field id", value) return fmt.Errorf("unexpected type %T for field id", value)
} }
s.ID = int(value.Int64) _m.ID = int(value.Int64)
case spray.FieldWeapon: case spray.FieldWeapon:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field weapon", values[i]) return fmt.Errorf("unexpected type %T for field weapon", values[i])
} else if value.Valid { } else if value.Valid {
s.Weapon = int(value.Int64) _m.Weapon = int(value.Int64)
} }
case spray.FieldSpray: case spray.FieldSpray:
if value, ok := values[i].(*[]byte); !ok { if value, ok := values[i].(*[]byte); !ok {
return fmt.Errorf("unexpected type %T for field spray", values[i]) return fmt.Errorf("unexpected type %T for field spray", values[i])
} else if value != nil { } else if value != nil {
s.Spray = *value _m.Spray = *value
} }
case spray.ForeignKeys[0]: case spray.ForeignKeys[0]:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for edge-field match_player_spray", value) return fmt.Errorf("unexpected type %T for edge-field match_player_spray", value)
} else if value.Valid { } else if value.Valid {
s.match_player_spray = new(int) _m.match_player_spray = new(int)
*s.match_player_spray = int(value.Int64) *_m.match_player_spray = int(value.Int64)
} }
default: default:
s.selectValues.Set(columns[i], values[i]) _m.selectValues.Set(columns[i], values[i])
} }
} }
return nil 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. // Value returns the ent.Value that was dynamically selected and assigned to the Spray.
// This includes values selected through modifiers, order, etc. // This includes values selected through modifiers, order, etc.
func (s *Spray) Value(name string) (ent.Value, error) { func (_m *Spray) Value(name string) (ent.Value, error) {
return s.selectValues.Get(name) return _m.selectValues.Get(name)
} }
// QueryMatchPlayers queries the "match_players" edge of the Spray entity. // QueryMatchPlayers queries the "match_players" edge of the Spray entity.
func (s *Spray) QueryMatchPlayers() *MatchPlayerQuery { func (_m *Spray) QueryMatchPlayers() *MatchPlayerQuery {
return NewSprayClient(s.config).QueryMatchPlayers(s) return NewSprayClient(_m.config).QueryMatchPlayers(_m)
} }
// Update returns a builder for updating this Spray. // Update returns a builder for updating this Spray.
// Note that you need to call Spray.Unwrap() before calling this method if 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. // was returned from a transaction, and the transaction was committed or rolled back.
func (s *Spray) Update() *SprayUpdateOne { func (_m *Spray) Update() *SprayUpdateOne {
return NewSprayClient(s.config).UpdateOne(s) return NewSprayClient(_m.config).UpdateOne(_m)
} }
// Unwrap unwraps the Spray entity that was returned from a transaction after it was closed, // 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. // so that all future queries will be executed through the driver which created the transaction.
func (s *Spray) Unwrap() *Spray { func (_m *Spray) Unwrap() *Spray {
_tx, ok := s.config.driver.(*txDriver) _tx, ok := _m.config.driver.(*txDriver)
if !ok { if !ok {
panic("ent: Spray is not a transactional entity") panic("ent: Spray is not a transactional entity")
} }
s.config.driver = _tx.drv _m.config.driver = _tx.drv
return s return _m
} }
// String implements the fmt.Stringer. // String implements the fmt.Stringer.
func (s *Spray) String() string { func (_m *Spray) String() string {
var builder strings.Builder var builder strings.Builder
builder.WriteString("Spray(") builder.WriteString("Spray(")
builder.WriteString(fmt.Sprintf("id=%v, ", s.ID)) builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("weapon=") builder.WriteString("weapon=")
builder.WriteString(fmt.Sprintf("%v", s.Weapon)) builder.WriteString(fmt.Sprintf("%v", _m.Weapon))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("spray=") builder.WriteString("spray=")
builder.WriteString(fmt.Sprintf("%v", s.Spray)) builder.WriteString(fmt.Sprintf("%v", _m.Spray))
builder.WriteByte(')') builder.WriteByte(')')
return builder.String() return builder.String()
} }

View File

@@ -168,32 +168,15 @@ func HasMatchPlayersWith(preds ...predicate.MatchPlayer) predicate.Spray {
// And groups predicates with the AND operator between them. // And groups predicates with the AND operator between them.
func And(predicates ...predicate.Spray) predicate.Spray { func And(predicates ...predicate.Spray) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) { return predicate.Spray(sql.AndPredicates(predicates...))
s1 := s.Clone().SetP(nil)
for _, p := range predicates {
p(s1)
}
s.Where(s1.P())
})
} }
// Or groups predicates with the OR operator between them. // Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.Spray) predicate.Spray { func Or(predicates ...predicate.Spray) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) { return predicate.Spray(sql.OrPredicates(predicates...))
s1 := s.Clone().SetP(nil)
for i, p := range predicates {
if i > 0 {
s1.Or()
}
p(s1)
}
s.Where(s1.P())
})
} }
// Not applies the not operator on the given predicate. // Not applies the not operator on the given predicate.
func Not(p predicate.Spray) predicate.Spray { func Not(p predicate.Spray) predicate.Spray {
return predicate.Spray(func(s *sql.Selector) { return predicate.Spray(sql.NotPredicates(p))
p(s.Not())
})
} }

View File

@@ -21,49 +21,49 @@ type SprayCreate struct {
} }
// SetWeapon sets the "weapon" field. // SetWeapon sets the "weapon" field.
func (sc *SprayCreate) SetWeapon(i int) *SprayCreate { func (_c *SprayCreate) SetWeapon(v int) *SprayCreate {
sc.mutation.SetWeapon(i) _c.mutation.SetWeapon(v)
return sc return _c
} }
// SetSpray sets the "spray" field. // SetSpray sets the "spray" field.
func (sc *SprayCreate) SetSpray(b []byte) *SprayCreate { func (_c *SprayCreate) SetSpray(v []byte) *SprayCreate {
sc.mutation.SetSpray(b) _c.mutation.SetSpray(v)
return sc return _c
} }
// SetMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID. // SetMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID.
func (sc *SprayCreate) SetMatchPlayersID(id int) *SprayCreate { func (_c *SprayCreate) SetMatchPlayersID(id int) *SprayCreate {
sc.mutation.SetMatchPlayersID(id) _c.mutation.SetMatchPlayersID(id)
return sc return _c
} }
// SetNillableMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID if the given value is not nil. // 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 { 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. // SetMatchPlayers sets the "match_players" edge to the MatchPlayer entity.
func (sc *SprayCreate) SetMatchPlayers(m *MatchPlayer) *SprayCreate { func (_c *SprayCreate) SetMatchPlayers(v *MatchPlayer) *SprayCreate {
return sc.SetMatchPlayersID(m.ID) return _c.SetMatchPlayersID(v.ID)
} }
// Mutation returns the SprayMutation object of the builder. // Mutation returns the SprayMutation object of the builder.
func (sc *SprayCreate) Mutation() *SprayMutation { func (_c *SprayCreate) Mutation() *SprayMutation {
return sc.mutation return _c.mutation
} }
// Save creates the Spray in the database. // Save creates the Spray in the database.
func (sc *SprayCreate) Save(ctx context.Context) (*Spray, error) { func (_c *SprayCreate) Save(ctx context.Context) (*Spray, error) {
return withHooks(ctx, sc.sqlSave, sc.mutation, sc.hooks) return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
} }
// SaveX calls Save and panics if Save returns an error. // SaveX calls Save and panics if Save returns an error.
func (sc *SprayCreate) SaveX(ctx context.Context) *Spray { func (_c *SprayCreate) SaveX(ctx context.Context) *Spray {
v, err := sc.Save(ctx) v, err := _c.Save(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -71,35 +71,35 @@ func (sc *SprayCreate) SaveX(ctx context.Context) *Spray {
} }
// Exec executes the query. // Exec executes the query.
func (sc *SprayCreate) Exec(ctx context.Context) error { func (_c *SprayCreate) Exec(ctx context.Context) error {
_, err := sc.Save(ctx) _, err := _c.Save(ctx)
return err return err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (sc *SprayCreate) ExecX(ctx context.Context) { func (_c *SprayCreate) ExecX(ctx context.Context) {
if err := sc.Exec(ctx); err != nil { if err := _c.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }
// check runs all checks and user-defined validators on the builder. // check runs all checks and user-defined validators on the builder.
func (sc *SprayCreate) check() error { func (_c *SprayCreate) check() error {
if _, ok := sc.mutation.Weapon(); !ok { if _, ok := _c.mutation.Weapon(); !ok {
return &ValidationError{Name: "weapon", err: errors.New(`ent: missing required field "Spray.weapon"`)} 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 &ValidationError{Name: "spray", err: errors.New(`ent: missing required field "Spray.spray"`)}
} }
return nil return nil
} }
func (sc *SprayCreate) sqlSave(ctx context.Context) (*Spray, error) { func (_c *SprayCreate) sqlSave(ctx context.Context) (*Spray, error) {
if err := sc.check(); err != nil { if err := _c.check(); err != nil {
return nil, err return nil, err
} }
_node, _spec := sc.createSpec() _node, _spec := _c.createSpec()
if err := sqlgraph.CreateNode(ctx, sc.driver, _spec); err != nil { if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) { if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: 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) id := _spec.ID.Value.(int64)
_node.ID = int(id) _node.ID = int(id)
sc.mutation.id = &_node.ID _c.mutation.id = &_node.ID
sc.mutation.done = true _c.mutation.done = true
return _node, nil return _node, nil
} }
func (sc *SprayCreate) createSpec() (*Spray, *sqlgraph.CreateSpec) { func (_c *SprayCreate) createSpec() (*Spray, *sqlgraph.CreateSpec) {
var ( var (
_node = &Spray{config: sc.config} _node = &Spray{config: _c.config}
_spec = sqlgraph.NewCreateSpec(spray.Table, sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt)) _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) _spec.SetField(spray.FieldWeapon, field.TypeInt, value)
_node.Weapon = 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) _spec.SetField(spray.FieldSpray, field.TypeBytes, value)
_node.Spray = value _node.Spray = value
} }
if nodes := sc.mutation.MatchPlayersIDs(); len(nodes) > 0 { if nodes := _c.mutation.MatchPlayersIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{ edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O, Rel: sqlgraph.M2O,
Inverse: true, Inverse: true,
@@ -148,17 +148,21 @@ func (sc *SprayCreate) createSpec() (*Spray, *sqlgraph.CreateSpec) {
// SprayCreateBulk is the builder for creating many Spray entities in bulk. // SprayCreateBulk is the builder for creating many Spray entities in bulk.
type SprayCreateBulk struct { type SprayCreateBulk struct {
config config
err error
builders []*SprayCreate builders []*SprayCreate
} }
// Save creates the Spray entities in the database. // Save creates the Spray entities in the database.
func (scb *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) { func (_c *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) {
specs := make([]*sqlgraph.CreateSpec, len(scb.builders)) if _c.err != nil {
nodes := make([]*Spray, len(scb.builders)) return nil, _c.err
mutators := make([]Mutator, len(scb.builders)) }
for i := range scb.builders { 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) { 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) { var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*SprayMutation) mutation, ok := m.(*SprayMutation)
if !ok { if !ok {
@@ -171,11 +175,11 @@ func (scb *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) {
var err error var err error
nodes[i], specs[i] = builder.createSpec() nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 { 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 { } else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs} spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain. // 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) { if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
@@ -199,7 +203,7 @@ func (scb *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) {
}(i, ctx) }(i, ctx)
} }
if len(mutators) > 0 { 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 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. // SaveX is like Save, but panics if an error occurs.
func (scb *SprayCreateBulk) SaveX(ctx context.Context) []*Spray { func (_c *SprayCreateBulk) SaveX(ctx context.Context) []*Spray {
v, err := scb.Save(ctx) v, err := _c.Save(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -216,14 +220,14 @@ func (scb *SprayCreateBulk) SaveX(ctx context.Context) []*Spray {
} }
// Exec executes the query. // Exec executes the query.
func (scb *SprayCreateBulk) Exec(ctx context.Context) error { func (_c *SprayCreateBulk) Exec(ctx context.Context) error {
_, err := scb.Save(ctx) _, err := _c.Save(ctx)
return err return err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (scb *SprayCreateBulk) ExecX(ctx context.Context) { func (_c *SprayCreateBulk) ExecX(ctx context.Context) {
if err := scb.Exec(ctx); err != nil { if err := _c.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }

View File

@@ -20,56 +20,56 @@ type SprayDelete struct {
} }
// Where appends a list predicates to the SprayDelete builder. // Where appends a list predicates to the SprayDelete builder.
func (sd *SprayDelete) Where(ps ...predicate.Spray) *SprayDelete { func (_d *SprayDelete) Where(ps ...predicate.Spray) *SprayDelete {
sd.mutation.Where(ps...) _d.mutation.Where(ps...)
return sd return _d
} }
// Exec executes the deletion query and returns how many vertices were deleted. // Exec executes the deletion query and returns how many vertices were deleted.
func (sd *SprayDelete) Exec(ctx context.Context) (int, error) { func (_d *SprayDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, sd.sqlExec, sd.mutation, sd.hooks) return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (sd *SprayDelete) ExecX(ctx context.Context) int { func (_d *SprayDelete) ExecX(ctx context.Context) int {
n, err := sd.Exec(ctx) n, err := _d.Exec(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
return n 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)) _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) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) 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) { if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
sd.mutation.done = true _d.mutation.done = true
return affected, err return affected, err
} }
// SprayDeleteOne is the builder for deleting a single Spray entity. // SprayDeleteOne is the builder for deleting a single Spray entity.
type SprayDeleteOne struct { type SprayDeleteOne struct {
sd *SprayDelete _d *SprayDelete
} }
// Where appends a list predicates to the SprayDelete builder. // Where appends a list predicates to the SprayDelete builder.
func (sdo *SprayDeleteOne) Where(ps ...predicate.Spray) *SprayDeleteOne { func (_d *SprayDeleteOne) Where(ps ...predicate.Spray) *SprayDeleteOne {
sdo.sd.mutation.Where(ps...) _d._d.mutation.Where(ps...)
return sdo return _d
} }
// Exec executes the deletion query. // Exec executes the deletion query.
func (sdo *SprayDeleteOne) Exec(ctx context.Context) error { func (_d *SprayDeleteOne) Exec(ctx context.Context) error {
n, err := sdo.sd.Exec(ctx) n, err := _d._d.Exec(ctx)
switch { switch {
case err != nil: case err != nil:
return err return err
@@ -81,8 +81,8 @@ func (sdo *SprayDeleteOne) Exec(ctx context.Context) error {
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (sdo *SprayDeleteOne) ExecX(ctx context.Context) { func (_d *SprayDeleteOne) ExecX(ctx context.Context) {
if err := sdo.Exec(ctx); err != nil { if err := _d.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }

View File

@@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"math" "math"
"entgo.io/ent"
"entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field" "entgo.io/ent/schema/field"
@@ -31,44 +32,44 @@ type SprayQuery struct {
} }
// Where adds a new predicate for the SprayQuery builder. // Where adds a new predicate for the SprayQuery builder.
func (sq *SprayQuery) Where(ps ...predicate.Spray) *SprayQuery { func (_q *SprayQuery) Where(ps ...predicate.Spray) *SprayQuery {
sq.predicates = append(sq.predicates, ps...) _q.predicates = append(_q.predicates, ps...)
return sq return _q
} }
// Limit the number of records to be returned by this query. // Limit the number of records to be returned by this query.
func (sq *SprayQuery) Limit(limit int) *SprayQuery { func (_q *SprayQuery) Limit(limit int) *SprayQuery {
sq.ctx.Limit = &limit _q.ctx.Limit = &limit
return sq return _q
} }
// Offset to start from. // Offset to start from.
func (sq *SprayQuery) Offset(offset int) *SprayQuery { func (_q *SprayQuery) Offset(offset int) *SprayQuery {
sq.ctx.Offset = &offset _q.ctx.Offset = &offset
return sq return _q
} }
// Unique configures the query builder to filter duplicate records on query. // 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. // By default, unique is set to true, and can be disabled using this method.
func (sq *SprayQuery) Unique(unique bool) *SprayQuery { func (_q *SprayQuery) Unique(unique bool) *SprayQuery {
sq.ctx.Unique = &unique _q.ctx.Unique = &unique
return sq return _q
} }
// Order specifies how the records should be ordered. // Order specifies how the records should be ordered.
func (sq *SprayQuery) Order(o ...spray.OrderOption) *SprayQuery { func (_q *SprayQuery) Order(o ...spray.OrderOption) *SprayQuery {
sq.order = append(sq.order, o...) _q.order = append(_q.order, o...)
return sq return _q
} }
// QueryMatchPlayers chains the current query on the "match_players" edge. // QueryMatchPlayers chains the current query on the "match_players" edge.
func (sq *SprayQuery) QueryMatchPlayers() *MatchPlayerQuery { func (_q *SprayQuery) QueryMatchPlayers() *MatchPlayerQuery {
query := (&MatchPlayerClient{config: sq.config}).Query() query := (&MatchPlayerClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { 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 return nil, err
} }
selector := sq.sqlQuery(ctx) selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return nil, err return nil, err
} }
@@ -77,7 +78,7 @@ func (sq *SprayQuery) QueryMatchPlayers() *MatchPlayerQuery {
sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, spray.MatchPlayersTable, spray.MatchPlayersColumn), 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 fromU, nil
} }
return query return query
@@ -85,8 +86,8 @@ func (sq *SprayQuery) QueryMatchPlayers() *MatchPlayerQuery {
// First returns the first Spray entity from the query. // First returns the first Spray entity from the query.
// Returns a *NotFoundError when no Spray was found. // Returns a *NotFoundError when no Spray was found.
func (sq *SprayQuery) First(ctx context.Context) (*Spray, error) { func (_q *SprayQuery) First(ctx context.Context) (*Spray, error) {
nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, "First")) nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
if err != nil { if err != nil {
return nil, err 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. // FirstX is like First, but panics if an error occurs.
func (sq *SprayQuery) FirstX(ctx context.Context) *Spray { func (_q *SprayQuery) FirstX(ctx context.Context) *Spray {
node, err := sq.First(ctx) node, err := _q.First(ctx)
if err != nil && !IsNotFound(err) { if err != nil && !IsNotFound(err) {
panic(err) panic(err)
} }
@@ -107,9 +108,9 @@ func (sq *SprayQuery) FirstX(ctx context.Context) *Spray {
// FirstID returns the first Spray ID from the query. // FirstID returns the first Spray ID from the query.
// Returns a *NotFoundError when no Spray ID was found. // 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 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 return
} }
if len(ids) == 0 { 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. // FirstIDX is like FirstID, but panics if an error occurs.
func (sq *SprayQuery) FirstIDX(ctx context.Context) int { func (_q *SprayQuery) FirstIDX(ctx context.Context) int {
id, err := sq.FirstID(ctx) id, err := _q.FirstID(ctx)
if err != nil && !IsNotFound(err) { if err != nil && !IsNotFound(err) {
panic(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. // 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 *NotSingularError when more than one Spray entity is found.
// Returns a *NotFoundError when no Spray entities are found. // Returns a *NotFoundError when no Spray entities are found.
func (sq *SprayQuery) Only(ctx context.Context) (*Spray, error) { func (_q *SprayQuery) Only(ctx context.Context) (*Spray, error) {
nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, "Only")) nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
if err != nil { if err != nil {
return nil, err 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. // OnlyX is like Only, but panics if an error occurs.
func (sq *SprayQuery) OnlyX(ctx context.Context) *Spray { func (_q *SprayQuery) OnlyX(ctx context.Context) *Spray {
node, err := sq.Only(ctx) node, err := _q.Only(ctx)
if err != nil { if err != nil {
panic(err) 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. // 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 *NotSingularError when more than one Spray ID is found.
// Returns a *NotFoundError when no entities are 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 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 return
} }
switch len(ids) { 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. // OnlyIDX is like OnlyID, but panics if an error occurs.
func (sq *SprayQuery) OnlyIDX(ctx context.Context) int { func (_q *SprayQuery) OnlyIDX(ctx context.Context) int {
id, err := sq.OnlyID(ctx) id, err := _q.OnlyID(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -184,18 +185,18 @@ func (sq *SprayQuery) OnlyIDX(ctx context.Context) int {
} }
// All executes the query and returns a list of Sprays. // All executes the query and returns a list of Sprays.
func (sq *SprayQuery) All(ctx context.Context) ([]*Spray, error) { func (_q *SprayQuery) All(ctx context.Context) ([]*Spray, error) {
ctx = setContextOp(ctx, sq.ctx, "All") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
if err := sq.prepareQuery(ctx); err != nil { if err := _q.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
qr := querierAll[[]*Spray, *SprayQuery]() 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. // AllX is like All, but panics if an error occurs.
func (sq *SprayQuery) AllX(ctx context.Context) []*Spray { func (_q *SprayQuery) AllX(ctx context.Context) []*Spray {
nodes, err := sq.All(ctx) nodes, err := _q.All(ctx)
if err != nil { if err != nil {
panic(err) 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. // IDs executes the query and returns a list of Spray IDs.
func (sq *SprayQuery) IDs(ctx context.Context) (ids []int, err error) { func (_q *SprayQuery) IDs(ctx context.Context) (ids []int, err error) {
if sq.ctx.Unique == nil && sq.path != nil { if _q.ctx.Unique == nil && _q.path != nil {
sq.Unique(true) _q.Unique(true)
} }
ctx = setContextOp(ctx, sq.ctx, "IDs") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
if err = sq.Select(spray.FieldID).Scan(ctx, &ids); err != nil { if err = _q.Select(spray.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
return ids, nil return ids, nil
} }
// IDsX is like IDs, but panics if an error occurs. // IDsX is like IDs, but panics if an error occurs.
func (sq *SprayQuery) IDsX(ctx context.Context) []int { func (_q *SprayQuery) IDsX(ctx context.Context) []int {
ids, err := sq.IDs(ctx) ids, err := _q.IDs(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -224,17 +225,17 @@ func (sq *SprayQuery) IDsX(ctx context.Context) []int {
} }
// Count returns the count of the given query. // Count returns the count of the given query.
func (sq *SprayQuery) Count(ctx context.Context) (int, error) { func (_q *SprayQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, sq.ctx, "Count") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
if err := sq.prepareQuery(ctx); err != nil { if err := _q.prepareQuery(ctx); err != nil {
return 0, err 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. // CountX is like Count, but panics if an error occurs.
func (sq *SprayQuery) CountX(ctx context.Context) int { func (_q *SprayQuery) CountX(ctx context.Context) int {
count, err := sq.Count(ctx) count, err := _q.Count(ctx)
if err != nil { if err != nil {
panic(err) 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. // Exist returns true if the query has elements in the graph.
func (sq *SprayQuery) Exist(ctx context.Context) (bool, error) { func (_q *SprayQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, sq.ctx, "Exist") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
switch _, err := sq.FirstID(ctx); { switch _, err := _q.FirstID(ctx); {
case IsNotFound(err): case IsNotFound(err):
return false, nil return false, nil
case err != 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. // ExistX is like Exist, but panics if an error occurs.
func (sq *SprayQuery) ExistX(ctx context.Context) bool { func (_q *SprayQuery) ExistX(ctx context.Context) bool {
exist, err := sq.Exist(ctx) exist, err := _q.Exist(ctx)
if err != nil { if err != nil {
panic(err) 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 // 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. // used to prepare common query builders and use them differently after the clone is made.
func (sq *SprayQuery) Clone() *SprayQuery { func (_q *SprayQuery) Clone() *SprayQuery {
if sq == nil { if _q == nil {
return nil return nil
} }
return &SprayQuery{ return &SprayQuery{
config: sq.config, config: _q.config,
ctx: sq.ctx.Clone(), ctx: _q.ctx.Clone(),
order: append([]spray.OrderOption{}, sq.order...), order: append([]spray.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, sq.inters...), inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.Spray{}, sq.predicates...), predicates: append([]predicate.Spray{}, _q.predicates...),
withMatchPlayers: sq.withMatchPlayers.Clone(), withMatchPlayers: _q.withMatchPlayers.Clone(),
// clone intermediate query. // clone intermediate query.
sql: sq.sql.Clone(), sql: _q.sql.Clone(),
path: sq.path, path: _q.path,
modifiers: append([]func(*sql.Selector){}, _q.modifiers...),
} }
} }
// WithMatchPlayers tells the query-builder to eager-load the nodes that are connected to // 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. // 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 { func (_q *SprayQuery) WithMatchPlayers(opts ...func(*MatchPlayerQuery)) *SprayQuery {
query := (&MatchPlayerClient{config: sq.config}).Query() query := (&MatchPlayerClient{config: _q.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
sq.withMatchPlayers = query _q.withMatchPlayers = query
return sq return _q
} }
// GroupBy is used to group vertices by one or more fields/columns. // 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). // GroupBy(spray.FieldWeapon).
// Aggregate(ent.Count()). // Aggregate(ent.Count()).
// Scan(ctx, &v) // Scan(ctx, &v)
func (sq *SprayQuery) GroupBy(field string, fields ...string) *SprayGroupBy { func (_q *SprayQuery) GroupBy(field string, fields ...string) *SprayGroupBy {
sq.ctx.Fields = append([]string{field}, fields...) _q.ctx.Fields = append([]string{field}, fields...)
grbuild := &SprayGroupBy{build: sq} grbuild := &SprayGroupBy{build: _q}
grbuild.flds = &sq.ctx.Fields grbuild.flds = &_q.ctx.Fields
grbuild.label = spray.Label grbuild.label = spray.Label
grbuild.scan = grbuild.Scan grbuild.scan = grbuild.Scan
return grbuild return grbuild
@@ -328,55 +330,55 @@ func (sq *SprayQuery) GroupBy(field string, fields ...string) *SprayGroupBy {
// client.Spray.Query(). // client.Spray.Query().
// Select(spray.FieldWeapon). // Select(spray.FieldWeapon).
// Scan(ctx, &v) // Scan(ctx, &v)
func (sq *SprayQuery) Select(fields ...string) *SpraySelect { func (_q *SprayQuery) Select(fields ...string) *SpraySelect {
sq.ctx.Fields = append(sq.ctx.Fields, fields...) _q.ctx.Fields = append(_q.ctx.Fields, fields...)
sbuild := &SpraySelect{SprayQuery: sq} sbuild := &SpraySelect{SprayQuery: _q}
sbuild.label = spray.Label sbuild.label = spray.Label
sbuild.flds, sbuild.scan = &sq.ctx.Fields, sbuild.Scan sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
return sbuild return sbuild
} }
// Aggregate returns a SpraySelect configured with the given aggregations. // Aggregate returns a SpraySelect configured with the given aggregations.
func (sq *SprayQuery) Aggregate(fns ...AggregateFunc) *SpraySelect { func (_q *SprayQuery) Aggregate(fns ...AggregateFunc) *SpraySelect {
return sq.Select().Aggregate(fns...) return _q.Select().Aggregate(fns...)
} }
func (sq *SprayQuery) prepareQuery(ctx context.Context) error { func (_q *SprayQuery) prepareQuery(ctx context.Context) error {
for _, inter := range sq.inters { for _, inter := range _q.inters {
if inter == nil { if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
} }
if trv, ok := inter.(Traverser); ok { if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, sq); err != nil { if err := trv.Traverse(ctx, _q); err != nil {
return err return err
} }
} }
} }
for _, f := range sq.ctx.Fields { for _, f := range _q.ctx.Fields {
if !spray.ValidColumn(f) { if !spray.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
} }
} }
if sq.path != nil { if _q.path != nil {
prev, err := sq.path(ctx) prev, err := _q.path(ctx)
if err != nil { if err != nil {
return err return err
} }
sq.sql = prev _q.sql = prev
} }
return nil 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 ( var (
nodes = []*Spray{} nodes = []*Spray{}
withFKs = sq.withFKs withFKs = _q.withFKs
_spec = sq.querySpec() _spec = _q.querySpec()
loadedTypes = [1]bool{ loadedTypes = [1]bool{
sq.withMatchPlayers != nil, _q.withMatchPlayers != nil,
} }
) )
if sq.withMatchPlayers != nil { if _q.withMatchPlayers != nil {
withFKs = true withFKs = true
} }
if withFKs { if withFKs {
@@ -386,25 +388,25 @@ func (sq *SprayQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Spray,
return (*Spray).scanValues(nil, columns) return (*Spray).scanValues(nil, columns)
} }
_spec.Assign = func(columns []string, values []any) error { _spec.Assign = func(columns []string, values []any) error {
node := &Spray{config: sq.config} node := &Spray{config: _q.config}
nodes = append(nodes, node) nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values) return node.assignValues(columns, values)
} }
if len(sq.modifiers) > 0 { if len(_q.modifiers) > 0 {
_spec.Modifiers = sq.modifiers _spec.Modifiers = _q.modifiers
} }
for i := range hooks { for i := range hooks {
hooks[i](ctx, _spec) 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 return nil, err
} }
if len(nodes) == 0 { if len(nodes) == 0 {
return nodes, nil return nodes, nil
} }
if query := sq.withMatchPlayers; query != nil { if query := _q.withMatchPlayers; query != nil {
if err := sq.loadMatchPlayers(ctx, query, nodes, nil, if err := _q.loadMatchPlayers(ctx, query, nodes, nil,
func(n *Spray, e *MatchPlayer) { n.Edges.MatchPlayers = e }); err != nil { func(n *Spray, e *MatchPlayer) { n.Edges.MatchPlayers = e }); err != nil {
return nil, err return nil, err
} }
@@ -412,7 +414,7 @@ func (sq *SprayQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Spray,
return nodes, nil 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)) ids := make([]int, 0, len(nodes))
nodeids := make(map[int][]*Spray) nodeids := make(map[int][]*Spray)
for i := range nodes { for i := range nodes {
@@ -445,27 +447,27 @@ func (sq *SprayQuery) loadMatchPlayers(ctx context.Context, query *MatchPlayerQu
return nil return nil
} }
func (sq *SprayQuery) sqlCount(ctx context.Context) (int, error) { func (_q *SprayQuery) sqlCount(ctx context.Context) (int, error) {
_spec := sq.querySpec() _spec := _q.querySpec()
if len(sq.modifiers) > 0 { if len(_q.modifiers) > 0 {
_spec.Modifiers = sq.modifiers _spec.Modifiers = _q.modifiers
} }
_spec.Node.Columns = sq.ctx.Fields _spec.Node.Columns = _q.ctx.Fields
if len(sq.ctx.Fields) > 0 { if len(_q.ctx.Fields) > 0 {
_spec.Unique = sq.ctx.Unique != nil && *sq.ctx.Unique _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 := sqlgraph.NewQuerySpec(spray.Table, spray.Columns, sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt))
_spec.From = sq.sql _spec.From = _q.sql
if unique := sq.ctx.Unique; unique != nil { if unique := _q.ctx.Unique; unique != nil {
_spec.Unique = *unique _spec.Unique = *unique
} else if sq.path != nil { } else if _q.path != nil {
_spec.Unique = true _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 = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, spray.FieldID) _spec.Node.Columns = append(_spec.Node.Columns, spray.FieldID)
for i := range fields { 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) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) ps[i](selector)
} }
} }
} }
if limit := sq.ctx.Limit; limit != nil { if limit := _q.ctx.Limit; limit != nil {
_spec.Limit = *limit _spec.Limit = *limit
} }
if offset := sq.ctx.Offset; offset != nil { if offset := _q.ctx.Offset; offset != nil {
_spec.Offset = *offset _spec.Offset = *offset
} }
if ps := sq.order; len(ps) > 0 { if ps := _q.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) { _spec.Order = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) ps[i](selector)
@@ -497,45 +499,45 @@ func (sq *SprayQuery) querySpec() *sqlgraph.QuerySpec {
return _spec return _spec
} }
func (sq *SprayQuery) sqlQuery(ctx context.Context) *sql.Selector { func (_q *SprayQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(sq.driver.Dialect()) builder := sql.Dialect(_q.driver.Dialect())
t1 := builder.Table(spray.Table) t1 := builder.Table(spray.Table)
columns := sq.ctx.Fields columns := _q.ctx.Fields
if len(columns) == 0 { if len(columns) == 0 {
columns = spray.Columns columns = spray.Columns
} }
selector := builder.Select(t1.Columns(columns...)...).From(t1) selector := builder.Select(t1.Columns(columns...)...).From(t1)
if sq.sql != nil { if _q.sql != nil {
selector = sq.sql selector = _q.sql
selector.Select(selector.Columns(columns...)...) selector.Select(selector.Columns(columns...)...)
} }
if sq.ctx.Unique != nil && *sq.ctx.Unique { if _q.ctx.Unique != nil && *_q.ctx.Unique {
selector.Distinct() selector.Distinct()
} }
for _, m := range sq.modifiers { for _, m := range _q.modifiers {
m(selector) m(selector)
} }
for _, p := range sq.predicates { for _, p := range _q.predicates {
p(selector) p(selector)
} }
for _, p := range sq.order { for _, p := range _q.order {
p(selector) p(selector)
} }
if offset := sq.ctx.Offset; offset != nil { if offset := _q.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start // limit is mandatory for offset clause. We start
// with default value, and override it below if needed. // with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32) selector.Offset(*offset).Limit(math.MaxInt32)
} }
if limit := sq.ctx.Limit; limit != nil { if limit := _q.ctx.Limit; limit != nil {
selector.Limit(*limit) selector.Limit(*limit)
} }
return selector return selector
} }
// Modify adds a query modifier for attaching custom logic to queries. // Modify adds a query modifier for attaching custom logic to queries.
func (sq *SprayQuery) Modify(modifiers ...func(s *sql.Selector)) *SpraySelect { func (_q *SprayQuery) Modify(modifiers ...func(s *sql.Selector)) *SpraySelect {
sq.modifiers = append(sq.modifiers, modifiers...) _q.modifiers = append(_q.modifiers, modifiers...)
return sq.Select() return _q.Select()
} }
// SprayGroupBy is the group-by builder for Spray entities. // 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. // Aggregate adds the given aggregation functions to the group-by query.
func (sgb *SprayGroupBy) Aggregate(fns ...AggregateFunc) *SprayGroupBy { func (_g *SprayGroupBy) Aggregate(fns ...AggregateFunc) *SprayGroupBy {
sgb.fns = append(sgb.fns, fns...) _g.fns = append(_g.fns, fns...)
return sgb return _g
} }
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (sgb *SprayGroupBy) Scan(ctx context.Context, v any) error { func (_g *SprayGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, sgb.build.ctx, "GroupBy") ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
if err := sgb.build.prepareQuery(ctx); err != nil { if err := _g.build.prepareQuery(ctx); err != nil {
return err 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() selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(sgb.fns)) aggregation := make([]string, 0, len(_g.fns))
for _, fn := range sgb.fns { for _, fn := range _g.fns {
aggregation = append(aggregation, fn(selector)) aggregation = append(aggregation, fn(selector))
} }
if len(selector.SelectedColumns()) == 0 { if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*sgb.flds)+len(sgb.fns)) columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
for _, f := range *sgb.flds { for _, f := range *_g.flds {
columns = append(columns, selector.C(f)) columns = append(columns, selector.C(f))
} }
columns = append(columns, aggregation...) columns = append(columns, aggregation...)
selector.Select(columns...) selector.Select(columns...)
} }
selector.GroupBy(selector.Columns(*sgb.flds...)...) selector.GroupBy(selector.Columns(*_g.flds...)...)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return err return err
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := selector.Query() 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 return err
} }
defer rows.Close() defer rows.Close()
@@ -593,27 +595,27 @@ type SpraySelect struct {
} }
// Aggregate adds the given aggregation functions to the selector query. // Aggregate adds the given aggregation functions to the selector query.
func (ss *SpraySelect) Aggregate(fns ...AggregateFunc) *SpraySelect { func (_s *SpraySelect) Aggregate(fns ...AggregateFunc) *SpraySelect {
ss.fns = append(ss.fns, fns...) _s.fns = append(_s.fns, fns...)
return ss return _s
} }
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (ss *SpraySelect) Scan(ctx context.Context, v any) error { func (_s *SpraySelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, ss.ctx, "Select") ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
if err := ss.prepareQuery(ctx); err != nil { if err := _s.prepareQuery(ctx); err != nil {
return err 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) selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(ss.fns)) aggregation := make([]string, 0, len(_s.fns))
for _, fn := range ss.fns { for _, fn := range _s.fns {
aggregation = append(aggregation, fn(selector)) aggregation = append(aggregation, fn(selector))
} }
switch n := len(*ss.selector.flds); { switch n := len(*_s.selector.flds); {
case n == 0 && len(aggregation) > 0: case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...) selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0: 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{} rows := &sql.Rows{}
query, args := selector.Query() 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 return err
} }
defer rows.Close() 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. // Modify adds a query modifier for attaching custom logic to queries.
func (ss *SpraySelect) Modify(modifiers ...func(s *sql.Selector)) *SpraySelect { func (_s *SpraySelect) Modify(modifiers ...func(s *sql.Selector)) *SpraySelect {
ss.modifiers = append(ss.modifiers, modifiers...) _s.modifiers = append(_s.modifiers, modifiers...)
return ss return _s
} }

View File

@@ -24,68 +24,76 @@ type SprayUpdate struct {
} }
// Where appends a list predicates to the SprayUpdate builder. // Where appends a list predicates to the SprayUpdate builder.
func (su *SprayUpdate) Where(ps ...predicate.Spray) *SprayUpdate { func (_u *SprayUpdate) Where(ps ...predicate.Spray) *SprayUpdate {
su.mutation.Where(ps...) _u.mutation.Where(ps...)
return su return _u
} }
// SetWeapon sets the "weapon" field. // SetWeapon sets the "weapon" field.
func (su *SprayUpdate) SetWeapon(i int) *SprayUpdate { func (_u *SprayUpdate) SetWeapon(v int) *SprayUpdate {
su.mutation.ResetWeapon() _u.mutation.ResetWeapon()
su.mutation.SetWeapon(i) _u.mutation.SetWeapon(v)
return su return _u
} }
// AddWeapon adds i to the "weapon" field. // SetNillableWeapon sets the "weapon" field if the given value is not nil.
func (su *SprayUpdate) AddWeapon(i int) *SprayUpdate { func (_u *SprayUpdate) SetNillableWeapon(v *int) *SprayUpdate {
su.mutation.AddWeapon(i) if v != nil {
return su _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. // SetSpray sets the "spray" field.
func (su *SprayUpdate) SetSpray(b []byte) *SprayUpdate { func (_u *SprayUpdate) SetSpray(v []byte) *SprayUpdate {
su.mutation.SetSpray(b) _u.mutation.SetSpray(v)
return su return _u
} }
// SetMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID. // SetMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID.
func (su *SprayUpdate) SetMatchPlayersID(id int) *SprayUpdate { func (_u *SprayUpdate) SetMatchPlayersID(id int) *SprayUpdate {
su.mutation.SetMatchPlayersID(id) _u.mutation.SetMatchPlayersID(id)
return su return _u
} }
// SetNillableMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID if the given value is not nil. // 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 { 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. // SetMatchPlayers sets the "match_players" edge to the MatchPlayer entity.
func (su *SprayUpdate) SetMatchPlayers(m *MatchPlayer) *SprayUpdate { func (_u *SprayUpdate) SetMatchPlayers(v *MatchPlayer) *SprayUpdate {
return su.SetMatchPlayersID(m.ID) return _u.SetMatchPlayersID(v.ID)
} }
// Mutation returns the SprayMutation object of the builder. // Mutation returns the SprayMutation object of the builder.
func (su *SprayUpdate) Mutation() *SprayMutation { func (_u *SprayUpdate) Mutation() *SprayMutation {
return su.mutation return _u.mutation
} }
// ClearMatchPlayers clears the "match_players" edge to the MatchPlayer entity. // ClearMatchPlayers clears the "match_players" edge to the MatchPlayer entity.
func (su *SprayUpdate) ClearMatchPlayers() *SprayUpdate { func (_u *SprayUpdate) ClearMatchPlayers() *SprayUpdate {
su.mutation.ClearMatchPlayers() _u.mutation.ClearMatchPlayers()
return su return _u
} }
// Save executes the query and returns the number of nodes affected by the update operation. // Save executes the query and returns the number of nodes affected by the update operation.
func (su *SprayUpdate) Save(ctx context.Context) (int, error) { func (_u *SprayUpdate) Save(ctx context.Context) (int, error) {
return withHooks(ctx, su.sqlSave, su.mutation, su.hooks) return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
func (su *SprayUpdate) SaveX(ctx context.Context) int { func (_u *SprayUpdate) SaveX(ctx context.Context) int {
affected, err := su.Save(ctx) affected, err := _u.Save(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -93,43 +101,43 @@ func (su *SprayUpdate) SaveX(ctx context.Context) int {
} }
// Exec executes the query. // Exec executes the query.
func (su *SprayUpdate) Exec(ctx context.Context) error { func (_u *SprayUpdate) Exec(ctx context.Context) error {
_, err := su.Save(ctx) _, err := _u.Save(ctx)
return err return err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (su *SprayUpdate) ExecX(ctx context.Context) { func (_u *SprayUpdate) ExecX(ctx context.Context) {
if err := su.Exec(ctx); err != nil { if err := _u.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. // Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (su *SprayUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SprayUpdate { func (_u *SprayUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SprayUpdate {
su.modifiers = append(su.modifiers, modifiers...) _u.modifiers = append(_u.modifiers, modifiers...)
return su 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)) _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) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) ps[i](selector)
} }
} }
} }
if value, ok := su.mutation.Weapon(); ok { if value, ok := _u.mutation.Weapon(); ok {
_spec.SetField(spray.FieldWeapon, field.TypeInt, value) _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) _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) _spec.SetField(spray.FieldSpray, field.TypeBytes, value)
} }
if su.mutation.MatchPlayersCleared() { if _u.mutation.MatchPlayersCleared() {
edge := &sqlgraph.EdgeSpec{ edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O, Rel: sqlgraph.M2O,
Inverse: true, 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) _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{ edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O, Rel: sqlgraph.M2O,
Inverse: true, 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.Edges.Add = append(_spec.Edges.Add, edge)
} }
_spec.AddModifiers(su.modifiers...) _spec.AddModifiers(_u.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil { if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok { if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{spray.Label} err = &NotFoundError{spray.Label}
} else if sqlgraph.IsConstraintError(err) { } else if sqlgraph.IsConstraintError(err) {
@@ -167,8 +175,8 @@ func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) {
} }
return 0, err return 0, err
} }
su.mutation.done = true _u.mutation.done = true
return n, nil return _node, nil
} }
// SprayUpdateOne is the builder for updating a single Spray entity. // SprayUpdateOne is the builder for updating a single Spray entity.
@@ -181,75 +189,83 @@ type SprayUpdateOne struct {
} }
// SetWeapon sets the "weapon" field. // SetWeapon sets the "weapon" field.
func (suo *SprayUpdateOne) SetWeapon(i int) *SprayUpdateOne { func (_u *SprayUpdateOne) SetWeapon(v int) *SprayUpdateOne {
suo.mutation.ResetWeapon() _u.mutation.ResetWeapon()
suo.mutation.SetWeapon(i) _u.mutation.SetWeapon(v)
return suo return _u
} }
// AddWeapon adds i to the "weapon" field. // SetNillableWeapon sets the "weapon" field if the given value is not nil.
func (suo *SprayUpdateOne) AddWeapon(i int) *SprayUpdateOne { func (_u *SprayUpdateOne) SetNillableWeapon(v *int) *SprayUpdateOne {
suo.mutation.AddWeapon(i) if v != nil {
return suo _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. // SetSpray sets the "spray" field.
func (suo *SprayUpdateOne) SetSpray(b []byte) *SprayUpdateOne { func (_u *SprayUpdateOne) SetSpray(v []byte) *SprayUpdateOne {
suo.mutation.SetSpray(b) _u.mutation.SetSpray(v)
return suo return _u
} }
// SetMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID. // SetMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID.
func (suo *SprayUpdateOne) SetMatchPlayersID(id int) *SprayUpdateOne { func (_u *SprayUpdateOne) SetMatchPlayersID(id int) *SprayUpdateOne {
suo.mutation.SetMatchPlayersID(id) _u.mutation.SetMatchPlayersID(id)
return suo return _u
} }
// SetNillableMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID if the given value is not nil. // 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 { 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. // SetMatchPlayers sets the "match_players" edge to the MatchPlayer entity.
func (suo *SprayUpdateOne) SetMatchPlayers(m *MatchPlayer) *SprayUpdateOne { func (_u *SprayUpdateOne) SetMatchPlayers(v *MatchPlayer) *SprayUpdateOne {
return suo.SetMatchPlayersID(m.ID) return _u.SetMatchPlayersID(v.ID)
} }
// Mutation returns the SprayMutation object of the builder. // Mutation returns the SprayMutation object of the builder.
func (suo *SprayUpdateOne) Mutation() *SprayMutation { func (_u *SprayUpdateOne) Mutation() *SprayMutation {
return suo.mutation return _u.mutation
} }
// ClearMatchPlayers clears the "match_players" edge to the MatchPlayer entity. // ClearMatchPlayers clears the "match_players" edge to the MatchPlayer entity.
func (suo *SprayUpdateOne) ClearMatchPlayers() *SprayUpdateOne { func (_u *SprayUpdateOne) ClearMatchPlayers() *SprayUpdateOne {
suo.mutation.ClearMatchPlayers() _u.mutation.ClearMatchPlayers()
return suo return _u
} }
// Where appends a list predicates to the SprayUpdate builder. // Where appends a list predicates to the SprayUpdate builder.
func (suo *SprayUpdateOne) Where(ps ...predicate.Spray) *SprayUpdateOne { func (_u *SprayUpdateOne) Where(ps ...predicate.Spray) *SprayUpdateOne {
suo.mutation.Where(ps...) _u.mutation.Where(ps...)
return suo return _u
} }
// Select allows selecting one or more fields (columns) of the returned entity. // Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema. // The default is selecting all fields defined in the entity schema.
func (suo *SprayUpdateOne) Select(field string, fields ...string) *SprayUpdateOne { func (_u *SprayUpdateOne) Select(field string, fields ...string) *SprayUpdateOne {
suo.fields = append([]string{field}, fields...) _u.fields = append([]string{field}, fields...)
return suo return _u
} }
// Save executes the query and returns the updated Spray entity. // Save executes the query and returns the updated Spray entity.
func (suo *SprayUpdateOne) Save(ctx context.Context) (*Spray, error) { func (_u *SprayUpdateOne) Save(ctx context.Context) (*Spray, error) {
return withHooks(ctx, suo.sqlSave, suo.mutation, suo.hooks) return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
func (suo *SprayUpdateOne) SaveX(ctx context.Context) *Spray { func (_u *SprayUpdateOne) SaveX(ctx context.Context) *Spray {
node, err := suo.Save(ctx) node, err := _u.Save(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -257,32 +273,32 @@ func (suo *SprayUpdateOne) SaveX(ctx context.Context) *Spray {
} }
// Exec executes the query on the entity. // Exec executes the query on the entity.
func (suo *SprayUpdateOne) Exec(ctx context.Context) error { func (_u *SprayUpdateOne) Exec(ctx context.Context) error {
_, err := suo.Save(ctx) _, err := _u.Save(ctx)
return err return err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (suo *SprayUpdateOne) ExecX(ctx context.Context) { func (_u *SprayUpdateOne) ExecX(ctx context.Context) {
if err := suo.Exec(ctx); err != nil { if err := _u.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. // Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (suo *SprayUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SprayUpdateOne { func (_u *SprayUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SprayUpdateOne {
suo.modifiers = append(suo.modifiers, modifiers...) _u.modifiers = append(_u.modifiers, modifiers...)
return suo 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)) _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 { if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Spray.id" for update`)} return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Spray.id" for update`)}
} }
_spec.Node.ID.Value = id _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 = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, spray.FieldID) _spec.Node.Columns = append(_spec.Node.Columns, spray.FieldID)
for _, f := range fields { 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) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) ps[i](selector)
} }
} }
} }
if value, ok := suo.mutation.Weapon(); ok { if value, ok := _u.mutation.Weapon(); ok {
_spec.SetField(spray.FieldWeapon, field.TypeInt, value) _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) _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) _spec.SetField(spray.FieldSpray, field.TypeBytes, value)
} }
if suo.mutation.MatchPlayersCleared() { if _u.mutation.MatchPlayersCleared() {
edge := &sqlgraph.EdgeSpec{ edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O, Rel: sqlgraph.M2O,
Inverse: true, 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) _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{ edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O, Rel: sqlgraph.M2O,
Inverse: true, 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.Edges.Add = append(_spec.Edges.Add, edge)
} }
_spec.AddModifiers(suo.modifiers...) _spec.AddModifiers(_u.modifiers...)
_node = &Spray{config: suo.config} _node = &Spray{config: _u.config}
_spec.Assign = _node.assignValues _spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues _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 { if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{spray.Label} err = &NotFoundError{spray.Label}
} else if sqlgraph.IsConstraintError(err) { } else if sqlgraph.IsConstraintError(err) {
@@ -351,6 +367,6 @@ func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error
} }
return nil, err return nil, err
} }
suo.mutation.done = true _u.mutation.done = true
return _node, nil return _node, nil
} }

View File

@@ -44,12 +44,10 @@ type WeaponEdges struct {
// StatOrErr returns the Stat value or an error if the edge // StatOrErr returns the Stat value or an error if the edge
// was not loaded in eager-loading, or loaded but was not found. // was not loaded in eager-loading, or loaded but was not found.
func (e WeaponEdges) StatOrErr() (*MatchPlayer, error) { func (e WeaponEdges) StatOrErr() (*MatchPlayer, error) {
if e.loadedTypes[0] { if e.Stat != nil {
if e.Stat == nil {
// Edge was loaded but was not found.
return nil, &NotFoundError{label: matchplayer.Label}
}
return e.Stat, nil return e.Stat, nil
} else if e.loadedTypes[0] {
return nil, &NotFoundError{label: matchplayer.Label}
} }
return nil, &NotLoadedError{edge: "stat"} 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) // assignValues assigns the values that were returned from sql.Rows (after scanning)
// to the Weapon fields. // 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 { if m, n := len(values), len(columns); m < n {
return fmt.Errorf("mismatch number of scan values: %d != %d", 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 { if !ok {
return fmt.Errorf("unexpected type %T for field id", value) return fmt.Errorf("unexpected type %T for field id", value)
} }
w.ID = int(value.Int64) _m.ID = int(value.Int64)
case weapon.FieldVictim: case weapon.FieldVictim:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field victim", values[i]) return fmt.Errorf("unexpected type %T for field victim", values[i])
} else if value.Valid { } else if value.Valid {
w.Victim = uint64(value.Int64) _m.Victim = uint64(value.Int64)
} }
case weapon.FieldDmg: case weapon.FieldDmg:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field dmg", values[i]) return fmt.Errorf("unexpected type %T for field dmg", values[i])
} else if value.Valid { } else if value.Valid {
w.Dmg = uint(value.Int64) _m.Dmg = uint(value.Int64)
} }
case weapon.FieldEqType: case weapon.FieldEqType:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field eq_type", values[i]) return fmt.Errorf("unexpected type %T for field eq_type", values[i])
} else if value.Valid { } else if value.Valid {
w.EqType = int(value.Int64) _m.EqType = int(value.Int64)
} }
case weapon.FieldHitGroup: case weapon.FieldHitGroup:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field hit_group", values[i]) return fmt.Errorf("unexpected type %T for field hit_group", values[i])
} else if value.Valid { } else if value.Valid {
w.HitGroup = int(value.Int64) _m.HitGroup = int(value.Int64)
} }
case weapon.ForeignKeys[0]: case weapon.ForeignKeys[0]:
if value, ok := values[i].(*sql.NullInt64); !ok { if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for edge-field match_player_weapon_stats", value) return fmt.Errorf("unexpected type %T for edge-field match_player_weapon_stats", value)
} else if value.Valid { } else if value.Valid {
w.match_player_weapon_stats = new(int) _m.match_player_weapon_stats = new(int)
*w.match_player_weapon_stats = int(value.Int64) *_m.match_player_weapon_stats = int(value.Int64)
} }
default: default:
w.selectValues.Set(columns[i], values[i]) _m.selectValues.Set(columns[i], values[i])
} }
} }
return nil 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. // Value returns the ent.Value that was dynamically selected and assigned to the Weapon.
// This includes values selected through modifiers, order, etc. // This includes values selected through modifiers, order, etc.
func (w *Weapon) Value(name string) (ent.Value, error) { func (_m *Weapon) Value(name string) (ent.Value, error) {
return w.selectValues.Get(name) return _m.selectValues.Get(name)
} }
// QueryStat queries the "stat" edge of the Weapon entity. // QueryStat queries the "stat" edge of the Weapon entity.
func (w *Weapon) QueryStat() *MatchPlayerQuery { func (_m *Weapon) QueryStat() *MatchPlayerQuery {
return NewWeaponClient(w.config).QueryStat(w) return NewWeaponClient(_m.config).QueryStat(_m)
} }
// Update returns a builder for updating this Weapon. // Update returns a builder for updating this Weapon.
// Note that you need to call Weapon.Unwrap() before calling this method if 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. // was returned from a transaction, and the transaction was committed or rolled back.
func (w *Weapon) Update() *WeaponUpdateOne { func (_m *Weapon) Update() *WeaponUpdateOne {
return NewWeaponClient(w.config).UpdateOne(w) return NewWeaponClient(_m.config).UpdateOne(_m)
} }
// Unwrap unwraps the Weapon entity that was returned from a transaction after it was closed, // 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. // so that all future queries will be executed through the driver which created the transaction.
func (w *Weapon) Unwrap() *Weapon { func (_m *Weapon) Unwrap() *Weapon {
_tx, ok := w.config.driver.(*txDriver) _tx, ok := _m.config.driver.(*txDriver)
if !ok { if !ok {
panic("ent: Weapon is not a transactional entity") panic("ent: Weapon is not a transactional entity")
} }
w.config.driver = _tx.drv _m.config.driver = _tx.drv
return w return _m
} }
// String implements the fmt.Stringer. // String implements the fmt.Stringer.
func (w *Weapon) String() string { func (_m *Weapon) String() string {
var builder strings.Builder var builder strings.Builder
builder.WriteString("Weapon(") builder.WriteString("Weapon(")
builder.WriteString(fmt.Sprintf("id=%v, ", w.ID)) builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("victim=") builder.WriteString("victim=")
builder.WriteString(fmt.Sprintf("%v", w.Victim)) builder.WriteString(fmt.Sprintf("%v", _m.Victim))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("dmg=") builder.WriteString("dmg=")
builder.WriteString(fmt.Sprintf("%v", w.Dmg)) builder.WriteString(fmt.Sprintf("%v", _m.Dmg))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("eq_type=") builder.WriteString("eq_type=")
builder.WriteString(fmt.Sprintf("%v", w.EqType)) builder.WriteString(fmt.Sprintf("%v", _m.EqType))
builder.WriteString(", ") builder.WriteString(", ")
builder.WriteString("hit_group=") builder.WriteString("hit_group=")
builder.WriteString(fmt.Sprintf("%v", w.HitGroup)) builder.WriteString(fmt.Sprintf("%v", _m.HitGroup))
builder.WriteByte(')') builder.WriteByte(')')
return builder.String() return builder.String()
} }

View File

@@ -258,32 +258,15 @@ func HasStatWith(preds ...predicate.MatchPlayer) predicate.Weapon {
// And groups predicates with the AND operator between them. // And groups predicates with the AND operator between them.
func And(predicates ...predicate.Weapon) predicate.Weapon { func And(predicates ...predicate.Weapon) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) { return predicate.Weapon(sql.AndPredicates(predicates...))
s1 := s.Clone().SetP(nil)
for _, p := range predicates {
p(s1)
}
s.Where(s1.P())
})
} }
// Or groups predicates with the OR operator between them. // Or groups predicates with the OR operator between them.
func Or(predicates ...predicate.Weapon) predicate.Weapon { func Or(predicates ...predicate.Weapon) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) { return predicate.Weapon(sql.OrPredicates(predicates...))
s1 := s.Clone().SetP(nil)
for i, p := range predicates {
if i > 0 {
s1.Or()
}
p(s1)
}
s.Where(s1.P())
})
} }
// Not applies the not operator on the given predicate. // Not applies the not operator on the given predicate.
func Not(p predicate.Weapon) predicate.Weapon { func Not(p predicate.Weapon) predicate.Weapon {
return predicate.Weapon(func(s *sql.Selector) { return predicate.Weapon(sql.NotPredicates(p))
p(s.Not())
})
} }

View File

@@ -21,61 +21,61 @@ type WeaponCreate struct {
} }
// SetVictim sets the "victim" field. // SetVictim sets the "victim" field.
func (wc *WeaponCreate) SetVictim(u uint64) *WeaponCreate { func (_c *WeaponCreate) SetVictim(v uint64) *WeaponCreate {
wc.mutation.SetVictim(u) _c.mutation.SetVictim(v)
return wc return _c
} }
// SetDmg sets the "dmg" field. // SetDmg sets the "dmg" field.
func (wc *WeaponCreate) SetDmg(u uint) *WeaponCreate { func (_c *WeaponCreate) SetDmg(v uint) *WeaponCreate {
wc.mutation.SetDmg(u) _c.mutation.SetDmg(v)
return wc return _c
} }
// SetEqType sets the "eq_type" field. // SetEqType sets the "eq_type" field.
func (wc *WeaponCreate) SetEqType(i int) *WeaponCreate { func (_c *WeaponCreate) SetEqType(v int) *WeaponCreate {
wc.mutation.SetEqType(i) _c.mutation.SetEqType(v)
return wc return _c
} }
// SetHitGroup sets the "hit_group" field. // SetHitGroup sets the "hit_group" field.
func (wc *WeaponCreate) SetHitGroup(i int) *WeaponCreate { func (_c *WeaponCreate) SetHitGroup(v int) *WeaponCreate {
wc.mutation.SetHitGroup(i) _c.mutation.SetHitGroup(v)
return wc return _c
} }
// SetStatID sets the "stat" edge to the MatchPlayer entity by ID. // SetStatID sets the "stat" edge to the MatchPlayer entity by ID.
func (wc *WeaponCreate) SetStatID(id int) *WeaponCreate { func (_c *WeaponCreate) SetStatID(id int) *WeaponCreate {
wc.mutation.SetStatID(id) _c.mutation.SetStatID(id)
return wc return _c
} }
// SetNillableStatID sets the "stat" edge to the MatchPlayer entity by ID if the given value is not nil. // 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 { if id != nil {
wc = wc.SetStatID(*id) _c = _c.SetStatID(*id)
} }
return wc return _c
} }
// SetStat sets the "stat" edge to the MatchPlayer entity. // SetStat sets the "stat" edge to the MatchPlayer entity.
func (wc *WeaponCreate) SetStat(m *MatchPlayer) *WeaponCreate { func (_c *WeaponCreate) SetStat(v *MatchPlayer) *WeaponCreate {
return wc.SetStatID(m.ID) return _c.SetStatID(v.ID)
} }
// Mutation returns the WeaponMutation object of the builder. // Mutation returns the WeaponMutation object of the builder.
func (wc *WeaponCreate) Mutation() *WeaponMutation { func (_c *WeaponCreate) Mutation() *WeaponMutation {
return wc.mutation return _c.mutation
} }
// Save creates the Weapon in the database. // Save creates the Weapon in the database.
func (wc *WeaponCreate) Save(ctx context.Context) (*Weapon, error) { func (_c *WeaponCreate) Save(ctx context.Context) (*Weapon, error) {
return withHooks(ctx, wc.sqlSave, wc.mutation, wc.hooks) return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
} }
// SaveX calls Save and panics if Save returns an error. // SaveX calls Save and panics if Save returns an error.
func (wc *WeaponCreate) SaveX(ctx context.Context) *Weapon { func (_c *WeaponCreate) SaveX(ctx context.Context) *Weapon {
v, err := wc.Save(ctx) v, err := _c.Save(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -83,41 +83,41 @@ func (wc *WeaponCreate) SaveX(ctx context.Context) *Weapon {
} }
// Exec executes the query. // Exec executes the query.
func (wc *WeaponCreate) Exec(ctx context.Context) error { func (_c *WeaponCreate) Exec(ctx context.Context) error {
_, err := wc.Save(ctx) _, err := _c.Save(ctx)
return err return err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (wc *WeaponCreate) ExecX(ctx context.Context) { func (_c *WeaponCreate) ExecX(ctx context.Context) {
if err := wc.Exec(ctx); err != nil { if err := _c.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }
// check runs all checks and user-defined validators on the builder. // check runs all checks and user-defined validators on the builder.
func (wc *WeaponCreate) check() error { func (_c *WeaponCreate) check() error {
if _, ok := wc.mutation.Victim(); !ok { if _, ok := _c.mutation.Victim(); !ok {
return &ValidationError{Name: "victim", err: errors.New(`ent: missing required field "Weapon.victim"`)} 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"`)} 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"`)} 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 &ValidationError{Name: "hit_group", err: errors.New(`ent: missing required field "Weapon.hit_group"`)}
} }
return nil return nil
} }
func (wc *WeaponCreate) sqlSave(ctx context.Context) (*Weapon, error) { func (_c *WeaponCreate) sqlSave(ctx context.Context) (*Weapon, error) {
if err := wc.check(); err != nil { if err := _c.check(); err != nil {
return nil, err return nil, err
} }
_node, _spec := wc.createSpec() _node, _spec := _c.createSpec()
if err := sqlgraph.CreateNode(ctx, wc.driver, _spec); err != nil { if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
if sqlgraph.IsConstraintError(err) { if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: 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) id := _spec.ID.Value.(int64)
_node.ID = int(id) _node.ID = int(id)
wc.mutation.id = &_node.ID _c.mutation.id = &_node.ID
wc.mutation.done = true _c.mutation.done = true
return _node, nil return _node, nil
} }
func (wc *WeaponCreate) createSpec() (*Weapon, *sqlgraph.CreateSpec) { func (_c *WeaponCreate) createSpec() (*Weapon, *sqlgraph.CreateSpec) {
var ( var (
_node = &Weapon{config: wc.config} _node = &Weapon{config: _c.config}
_spec = sqlgraph.NewCreateSpec(weapon.Table, sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt)) _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) _spec.SetField(weapon.FieldVictim, field.TypeUint64, value)
_node.Victim = 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) _spec.SetField(weapon.FieldDmg, field.TypeUint, value)
_node.Dmg = 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) _spec.SetField(weapon.FieldEqType, field.TypeInt, value)
_node.EqType = 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) _spec.SetField(weapon.FieldHitGroup, field.TypeInt, value)
_node.HitGroup = value _node.HitGroup = value
} }
if nodes := wc.mutation.StatIDs(); len(nodes) > 0 { if nodes := _c.mutation.StatIDs(); len(nodes) > 0 {
edge := &sqlgraph.EdgeSpec{ edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O, Rel: sqlgraph.M2O,
Inverse: true, Inverse: true,
@@ -174,17 +174,21 @@ func (wc *WeaponCreate) createSpec() (*Weapon, *sqlgraph.CreateSpec) {
// WeaponCreateBulk is the builder for creating many Weapon entities in bulk. // WeaponCreateBulk is the builder for creating many Weapon entities in bulk.
type WeaponCreateBulk struct { type WeaponCreateBulk struct {
config config
err error
builders []*WeaponCreate builders []*WeaponCreate
} }
// Save creates the Weapon entities in the database. // Save creates the Weapon entities in the database.
func (wcb *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) { func (_c *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) {
specs := make([]*sqlgraph.CreateSpec, len(wcb.builders)) if _c.err != nil {
nodes := make([]*Weapon, len(wcb.builders)) return nil, _c.err
mutators := make([]Mutator, len(wcb.builders)) }
for i := range wcb.builders { 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) { 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) { var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
mutation, ok := m.(*WeaponMutation) mutation, ok := m.(*WeaponMutation)
if !ok { if !ok {
@@ -197,11 +201,11 @@ func (wcb *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) {
var err error var err error
nodes[i], specs[i] = builder.createSpec() nodes[i], specs[i] = builder.createSpec()
if i < len(mutators)-1 { 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 { } else {
spec := &sqlgraph.BatchCreateSpec{Nodes: specs} spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
// Invoke the actual operation on the latest mutation in the chain. // 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) { if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
@@ -225,7 +229,7 @@ func (wcb *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) {
}(i, ctx) }(i, ctx)
} }
if len(mutators) > 0 { 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 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. // SaveX is like Save, but panics if an error occurs.
func (wcb *WeaponCreateBulk) SaveX(ctx context.Context) []*Weapon { func (_c *WeaponCreateBulk) SaveX(ctx context.Context) []*Weapon {
v, err := wcb.Save(ctx) v, err := _c.Save(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -242,14 +246,14 @@ func (wcb *WeaponCreateBulk) SaveX(ctx context.Context) []*Weapon {
} }
// Exec executes the query. // Exec executes the query.
func (wcb *WeaponCreateBulk) Exec(ctx context.Context) error { func (_c *WeaponCreateBulk) Exec(ctx context.Context) error {
_, err := wcb.Save(ctx) _, err := _c.Save(ctx)
return err return err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (wcb *WeaponCreateBulk) ExecX(ctx context.Context) { func (_c *WeaponCreateBulk) ExecX(ctx context.Context) {
if err := wcb.Exec(ctx); err != nil { if err := _c.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }

View File

@@ -20,56 +20,56 @@ type WeaponDelete struct {
} }
// Where appends a list predicates to the WeaponDelete builder. // Where appends a list predicates to the WeaponDelete builder.
func (wd *WeaponDelete) Where(ps ...predicate.Weapon) *WeaponDelete { func (_d *WeaponDelete) Where(ps ...predicate.Weapon) *WeaponDelete {
wd.mutation.Where(ps...) _d.mutation.Where(ps...)
return wd return _d
} }
// Exec executes the deletion query and returns how many vertices were deleted. // Exec executes the deletion query and returns how many vertices were deleted.
func (wd *WeaponDelete) Exec(ctx context.Context) (int, error) { func (_d *WeaponDelete) Exec(ctx context.Context) (int, error) {
return withHooks(ctx, wd.sqlExec, wd.mutation, wd.hooks) return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (wd *WeaponDelete) ExecX(ctx context.Context) int { func (_d *WeaponDelete) ExecX(ctx context.Context) int {
n, err := wd.Exec(ctx) n, err := _d.Exec(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
return n 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)) _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) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) 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) { if err != nil && sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err} err = &ConstraintError{msg: err.Error(), wrap: err}
} }
wd.mutation.done = true _d.mutation.done = true
return affected, err return affected, err
} }
// WeaponDeleteOne is the builder for deleting a single Weapon entity. // WeaponDeleteOne is the builder for deleting a single Weapon entity.
type WeaponDeleteOne struct { type WeaponDeleteOne struct {
wd *WeaponDelete _d *WeaponDelete
} }
// Where appends a list predicates to the WeaponDelete builder. // Where appends a list predicates to the WeaponDelete builder.
func (wdo *WeaponDeleteOne) Where(ps ...predicate.Weapon) *WeaponDeleteOne { func (_d *WeaponDeleteOne) Where(ps ...predicate.Weapon) *WeaponDeleteOne {
wdo.wd.mutation.Where(ps...) _d._d.mutation.Where(ps...)
return wdo return _d
} }
// Exec executes the deletion query. // Exec executes the deletion query.
func (wdo *WeaponDeleteOne) Exec(ctx context.Context) error { func (_d *WeaponDeleteOne) Exec(ctx context.Context) error {
n, err := wdo.wd.Exec(ctx) n, err := _d._d.Exec(ctx)
switch { switch {
case err != nil: case err != nil:
return err return err
@@ -81,8 +81,8 @@ func (wdo *WeaponDeleteOne) Exec(ctx context.Context) error {
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (wdo *WeaponDeleteOne) ExecX(ctx context.Context) { func (_d *WeaponDeleteOne) ExecX(ctx context.Context) {
if err := wdo.Exec(ctx); err != nil { if err := _d.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }

View File

@@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"math" "math"
"entgo.io/ent"
"entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph" "entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field" "entgo.io/ent/schema/field"
@@ -31,44 +32,44 @@ type WeaponQuery struct {
} }
// Where adds a new predicate for the WeaponQuery builder. // Where adds a new predicate for the WeaponQuery builder.
func (wq *WeaponQuery) Where(ps ...predicate.Weapon) *WeaponQuery { func (_q *WeaponQuery) Where(ps ...predicate.Weapon) *WeaponQuery {
wq.predicates = append(wq.predicates, ps...) _q.predicates = append(_q.predicates, ps...)
return wq return _q
} }
// Limit the number of records to be returned by this query. // Limit the number of records to be returned by this query.
func (wq *WeaponQuery) Limit(limit int) *WeaponQuery { func (_q *WeaponQuery) Limit(limit int) *WeaponQuery {
wq.ctx.Limit = &limit _q.ctx.Limit = &limit
return wq return _q
} }
// Offset to start from. // Offset to start from.
func (wq *WeaponQuery) Offset(offset int) *WeaponQuery { func (_q *WeaponQuery) Offset(offset int) *WeaponQuery {
wq.ctx.Offset = &offset _q.ctx.Offset = &offset
return wq return _q
} }
// Unique configures the query builder to filter duplicate records on query. // 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. // By default, unique is set to true, and can be disabled using this method.
func (wq *WeaponQuery) Unique(unique bool) *WeaponQuery { func (_q *WeaponQuery) Unique(unique bool) *WeaponQuery {
wq.ctx.Unique = &unique _q.ctx.Unique = &unique
return wq return _q
} }
// Order specifies how the records should be ordered. // Order specifies how the records should be ordered.
func (wq *WeaponQuery) Order(o ...weapon.OrderOption) *WeaponQuery { func (_q *WeaponQuery) Order(o ...weapon.OrderOption) *WeaponQuery {
wq.order = append(wq.order, o...) _q.order = append(_q.order, o...)
return wq return _q
} }
// QueryStat chains the current query on the "stat" edge. // QueryStat chains the current query on the "stat" edge.
func (wq *WeaponQuery) QueryStat() *MatchPlayerQuery { func (_q *WeaponQuery) QueryStat() *MatchPlayerQuery {
query := (&MatchPlayerClient{config: wq.config}).Query() query := (&MatchPlayerClient{config: _q.config}).Query()
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { 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 return nil, err
} }
selector := wq.sqlQuery(ctx) selector := _q.sqlQuery(ctx)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return nil, err return nil, err
} }
@@ -77,7 +78,7 @@ func (wq *WeaponQuery) QueryStat() *MatchPlayerQuery {
sqlgraph.To(matchplayer.Table, matchplayer.FieldID), sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
sqlgraph.Edge(sqlgraph.M2O, true, weapon.StatTable, weapon.StatColumn), 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 fromU, nil
} }
return query return query
@@ -85,8 +86,8 @@ func (wq *WeaponQuery) QueryStat() *MatchPlayerQuery {
// First returns the first Weapon entity from the query. // First returns the first Weapon entity from the query.
// Returns a *NotFoundError when no Weapon was found. // Returns a *NotFoundError when no Weapon was found.
func (wq *WeaponQuery) First(ctx context.Context) (*Weapon, error) { func (_q *WeaponQuery) First(ctx context.Context) (*Weapon, error) {
nodes, err := wq.Limit(1).All(setContextOp(ctx, wq.ctx, "First")) nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
if err != nil { if err != nil {
return nil, err 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. // FirstX is like First, but panics if an error occurs.
func (wq *WeaponQuery) FirstX(ctx context.Context) *Weapon { func (_q *WeaponQuery) FirstX(ctx context.Context) *Weapon {
node, err := wq.First(ctx) node, err := _q.First(ctx)
if err != nil && !IsNotFound(err) { if err != nil && !IsNotFound(err) {
panic(err) panic(err)
} }
@@ -107,9 +108,9 @@ func (wq *WeaponQuery) FirstX(ctx context.Context) *Weapon {
// FirstID returns the first Weapon ID from the query. // FirstID returns the first Weapon ID from the query.
// Returns a *NotFoundError when no Weapon ID was found. // 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 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 return
} }
if len(ids) == 0 { 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. // FirstIDX is like FirstID, but panics if an error occurs.
func (wq *WeaponQuery) FirstIDX(ctx context.Context) int { func (_q *WeaponQuery) FirstIDX(ctx context.Context) int {
id, err := wq.FirstID(ctx) id, err := _q.FirstID(ctx)
if err != nil && !IsNotFound(err) { if err != nil && !IsNotFound(err) {
panic(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. // 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 *NotSingularError when more than one Weapon entity is found.
// Returns a *NotFoundError when no Weapon entities are found. // Returns a *NotFoundError when no Weapon entities are found.
func (wq *WeaponQuery) Only(ctx context.Context) (*Weapon, error) { func (_q *WeaponQuery) Only(ctx context.Context) (*Weapon, error) {
nodes, err := wq.Limit(2).All(setContextOp(ctx, wq.ctx, "Only")) nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
if err != nil { if err != nil {
return nil, err 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. // OnlyX is like Only, but panics if an error occurs.
func (wq *WeaponQuery) OnlyX(ctx context.Context) *Weapon { func (_q *WeaponQuery) OnlyX(ctx context.Context) *Weapon {
node, err := wq.Only(ctx) node, err := _q.Only(ctx)
if err != nil { if err != nil {
panic(err) 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. // 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 *NotSingularError when more than one Weapon ID is found.
// Returns a *NotFoundError when no entities are 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 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 return
} }
switch len(ids) { 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. // OnlyIDX is like OnlyID, but panics if an error occurs.
func (wq *WeaponQuery) OnlyIDX(ctx context.Context) int { func (_q *WeaponQuery) OnlyIDX(ctx context.Context) int {
id, err := wq.OnlyID(ctx) id, err := _q.OnlyID(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -184,18 +185,18 @@ func (wq *WeaponQuery) OnlyIDX(ctx context.Context) int {
} }
// All executes the query and returns a list of Weapons. // All executes the query and returns a list of Weapons.
func (wq *WeaponQuery) All(ctx context.Context) ([]*Weapon, error) { func (_q *WeaponQuery) All(ctx context.Context) ([]*Weapon, error) {
ctx = setContextOp(ctx, wq.ctx, "All") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
if err := wq.prepareQuery(ctx); err != nil { if err := _q.prepareQuery(ctx); err != nil {
return nil, err return nil, err
} }
qr := querierAll[[]*Weapon, *WeaponQuery]() 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. // AllX is like All, but panics if an error occurs.
func (wq *WeaponQuery) AllX(ctx context.Context) []*Weapon { func (_q *WeaponQuery) AllX(ctx context.Context) []*Weapon {
nodes, err := wq.All(ctx) nodes, err := _q.All(ctx)
if err != nil { if err != nil {
panic(err) 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. // IDs executes the query and returns a list of Weapon IDs.
func (wq *WeaponQuery) IDs(ctx context.Context) (ids []int, err error) { func (_q *WeaponQuery) IDs(ctx context.Context) (ids []int, err error) {
if wq.ctx.Unique == nil && wq.path != nil { if _q.ctx.Unique == nil && _q.path != nil {
wq.Unique(true) _q.Unique(true)
} }
ctx = setContextOp(ctx, wq.ctx, "IDs") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
if err = wq.Select(weapon.FieldID).Scan(ctx, &ids); err != nil { if err = _q.Select(weapon.FieldID).Scan(ctx, &ids); err != nil {
return nil, err return nil, err
} }
return ids, nil return ids, nil
} }
// IDsX is like IDs, but panics if an error occurs. // IDsX is like IDs, but panics if an error occurs.
func (wq *WeaponQuery) IDsX(ctx context.Context) []int { func (_q *WeaponQuery) IDsX(ctx context.Context) []int {
ids, err := wq.IDs(ctx) ids, err := _q.IDs(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -224,17 +225,17 @@ func (wq *WeaponQuery) IDsX(ctx context.Context) []int {
} }
// Count returns the count of the given query. // Count returns the count of the given query.
func (wq *WeaponQuery) Count(ctx context.Context) (int, error) { func (_q *WeaponQuery) Count(ctx context.Context) (int, error) {
ctx = setContextOp(ctx, wq.ctx, "Count") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
if err := wq.prepareQuery(ctx); err != nil { if err := _q.prepareQuery(ctx); err != nil {
return 0, err 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. // CountX is like Count, but panics if an error occurs.
func (wq *WeaponQuery) CountX(ctx context.Context) int { func (_q *WeaponQuery) CountX(ctx context.Context) int {
count, err := wq.Count(ctx) count, err := _q.Count(ctx)
if err != nil { if err != nil {
panic(err) 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. // Exist returns true if the query has elements in the graph.
func (wq *WeaponQuery) Exist(ctx context.Context) (bool, error) { func (_q *WeaponQuery) Exist(ctx context.Context) (bool, error) {
ctx = setContextOp(ctx, wq.ctx, "Exist") ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
switch _, err := wq.FirstID(ctx); { switch _, err := _q.FirstID(ctx); {
case IsNotFound(err): case IsNotFound(err):
return false, nil return false, nil
case err != 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. // ExistX is like Exist, but panics if an error occurs.
func (wq *WeaponQuery) ExistX(ctx context.Context) bool { func (_q *WeaponQuery) ExistX(ctx context.Context) bool {
exist, err := wq.Exist(ctx) exist, err := _q.Exist(ctx)
if err != nil { if err != nil {
panic(err) 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 // 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. // used to prepare common query builders and use them differently after the clone is made.
func (wq *WeaponQuery) Clone() *WeaponQuery { func (_q *WeaponQuery) Clone() *WeaponQuery {
if wq == nil { if _q == nil {
return nil return nil
} }
return &WeaponQuery{ return &WeaponQuery{
config: wq.config, config: _q.config,
ctx: wq.ctx.Clone(), ctx: _q.ctx.Clone(),
order: append([]weapon.OrderOption{}, wq.order...), order: append([]weapon.OrderOption{}, _q.order...),
inters: append([]Interceptor{}, wq.inters...), inters: append([]Interceptor{}, _q.inters...),
predicates: append([]predicate.Weapon{}, wq.predicates...), predicates: append([]predicate.Weapon{}, _q.predicates...),
withStat: wq.withStat.Clone(), withStat: _q.withStat.Clone(),
// clone intermediate query. // clone intermediate query.
sql: wq.sql.Clone(), sql: _q.sql.Clone(),
path: wq.path, path: _q.path,
modifiers: append([]func(*sql.Selector){}, _q.modifiers...),
} }
} }
// WithStat tells the query-builder to eager-load the nodes that are connected to // 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. // the "stat" edge. The optional arguments are used to configure the query builder of the edge.
func (wq *WeaponQuery) WithStat(opts ...func(*MatchPlayerQuery)) *WeaponQuery { func (_q *WeaponQuery) WithStat(opts ...func(*MatchPlayerQuery)) *WeaponQuery {
query := (&MatchPlayerClient{config: wq.config}).Query() query := (&MatchPlayerClient{config: _q.config}).Query()
for _, opt := range opts { for _, opt := range opts {
opt(query) opt(query)
} }
wq.withStat = query _q.withStat = query
return wq return _q
} }
// GroupBy is used to group vertices by one or more fields/columns. // 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). // GroupBy(weapon.FieldVictim).
// Aggregate(ent.Count()). // Aggregate(ent.Count()).
// Scan(ctx, &v) // Scan(ctx, &v)
func (wq *WeaponQuery) GroupBy(field string, fields ...string) *WeaponGroupBy { func (_q *WeaponQuery) GroupBy(field string, fields ...string) *WeaponGroupBy {
wq.ctx.Fields = append([]string{field}, fields...) _q.ctx.Fields = append([]string{field}, fields...)
grbuild := &WeaponGroupBy{build: wq} grbuild := &WeaponGroupBy{build: _q}
grbuild.flds = &wq.ctx.Fields grbuild.flds = &_q.ctx.Fields
grbuild.label = weapon.Label grbuild.label = weapon.Label
grbuild.scan = grbuild.Scan grbuild.scan = grbuild.Scan
return grbuild return grbuild
@@ -328,55 +330,55 @@ func (wq *WeaponQuery) GroupBy(field string, fields ...string) *WeaponGroupBy {
// client.Weapon.Query(). // client.Weapon.Query().
// Select(weapon.FieldVictim). // Select(weapon.FieldVictim).
// Scan(ctx, &v) // Scan(ctx, &v)
func (wq *WeaponQuery) Select(fields ...string) *WeaponSelect { func (_q *WeaponQuery) Select(fields ...string) *WeaponSelect {
wq.ctx.Fields = append(wq.ctx.Fields, fields...) _q.ctx.Fields = append(_q.ctx.Fields, fields...)
sbuild := &WeaponSelect{WeaponQuery: wq} sbuild := &WeaponSelect{WeaponQuery: _q}
sbuild.label = weapon.Label sbuild.label = weapon.Label
sbuild.flds, sbuild.scan = &wq.ctx.Fields, sbuild.Scan sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
return sbuild return sbuild
} }
// Aggregate returns a WeaponSelect configured with the given aggregations. // Aggregate returns a WeaponSelect configured with the given aggregations.
func (wq *WeaponQuery) Aggregate(fns ...AggregateFunc) *WeaponSelect { func (_q *WeaponQuery) Aggregate(fns ...AggregateFunc) *WeaponSelect {
return wq.Select().Aggregate(fns...) return _q.Select().Aggregate(fns...)
} }
func (wq *WeaponQuery) prepareQuery(ctx context.Context) error { func (_q *WeaponQuery) prepareQuery(ctx context.Context) error {
for _, inter := range wq.inters { for _, inter := range _q.inters {
if inter == nil { if inter == nil {
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)") return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
} }
if trv, ok := inter.(Traverser); ok { if trv, ok := inter.(Traverser); ok {
if err := trv.Traverse(ctx, wq); err != nil { if err := trv.Traverse(ctx, _q); err != nil {
return err return err
} }
} }
} }
for _, f := range wq.ctx.Fields { for _, f := range _q.ctx.Fields {
if !weapon.ValidColumn(f) { if !weapon.ValidColumn(f) {
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
} }
} }
if wq.path != nil { if _q.path != nil {
prev, err := wq.path(ctx) prev, err := _q.path(ctx)
if err != nil { if err != nil {
return err return err
} }
wq.sql = prev _q.sql = prev
} }
return nil 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 ( var (
nodes = []*Weapon{} nodes = []*Weapon{}
withFKs = wq.withFKs withFKs = _q.withFKs
_spec = wq.querySpec() _spec = _q.querySpec()
loadedTypes = [1]bool{ loadedTypes = [1]bool{
wq.withStat != nil, _q.withStat != nil,
} }
) )
if wq.withStat != nil { if _q.withStat != nil {
withFKs = true withFKs = true
} }
if withFKs { if withFKs {
@@ -386,25 +388,25 @@ func (wq *WeaponQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Weapo
return (*Weapon).scanValues(nil, columns) return (*Weapon).scanValues(nil, columns)
} }
_spec.Assign = func(columns []string, values []any) error { _spec.Assign = func(columns []string, values []any) error {
node := &Weapon{config: wq.config} node := &Weapon{config: _q.config}
nodes = append(nodes, node) nodes = append(nodes, node)
node.Edges.loadedTypes = loadedTypes node.Edges.loadedTypes = loadedTypes
return node.assignValues(columns, values) return node.assignValues(columns, values)
} }
if len(wq.modifiers) > 0 { if len(_q.modifiers) > 0 {
_spec.Modifiers = wq.modifiers _spec.Modifiers = _q.modifiers
} }
for i := range hooks { for i := range hooks {
hooks[i](ctx, _spec) 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 return nil, err
} }
if len(nodes) == 0 { if len(nodes) == 0 {
return nodes, nil return nodes, nil
} }
if query := wq.withStat; query != nil { if query := _q.withStat; query != nil {
if err := wq.loadStat(ctx, query, nodes, nil, if err := _q.loadStat(ctx, query, nodes, nil,
func(n *Weapon, e *MatchPlayer) { n.Edges.Stat = e }); err != nil { func(n *Weapon, e *MatchPlayer) { n.Edges.Stat = e }); err != nil {
return nil, err return nil, err
} }
@@ -412,7 +414,7 @@ func (wq *WeaponQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Weapo
return nodes, nil 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)) ids := make([]int, 0, len(nodes))
nodeids := make(map[int][]*Weapon) nodeids := make(map[int][]*Weapon)
for i := range nodes { for i := range nodes {
@@ -445,27 +447,27 @@ func (wq *WeaponQuery) loadStat(ctx context.Context, query *MatchPlayerQuery, no
return nil return nil
} }
func (wq *WeaponQuery) sqlCount(ctx context.Context) (int, error) { func (_q *WeaponQuery) sqlCount(ctx context.Context) (int, error) {
_spec := wq.querySpec() _spec := _q.querySpec()
if len(wq.modifiers) > 0 { if len(_q.modifiers) > 0 {
_spec.Modifiers = wq.modifiers _spec.Modifiers = _q.modifiers
} }
_spec.Node.Columns = wq.ctx.Fields _spec.Node.Columns = _q.ctx.Fields
if len(wq.ctx.Fields) > 0 { if len(_q.ctx.Fields) > 0 {
_spec.Unique = wq.ctx.Unique != nil && *wq.ctx.Unique _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 := sqlgraph.NewQuerySpec(weapon.Table, weapon.Columns, sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt))
_spec.From = wq.sql _spec.From = _q.sql
if unique := wq.ctx.Unique; unique != nil { if unique := _q.ctx.Unique; unique != nil {
_spec.Unique = *unique _spec.Unique = *unique
} else if wq.path != nil { } else if _q.path != nil {
_spec.Unique = true _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 = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, weapon.FieldID) _spec.Node.Columns = append(_spec.Node.Columns, weapon.FieldID)
for i := range fields { 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) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) ps[i](selector)
} }
} }
} }
if limit := wq.ctx.Limit; limit != nil { if limit := _q.ctx.Limit; limit != nil {
_spec.Limit = *limit _spec.Limit = *limit
} }
if offset := wq.ctx.Offset; offset != nil { if offset := _q.ctx.Offset; offset != nil {
_spec.Offset = *offset _spec.Offset = *offset
} }
if ps := wq.order; len(ps) > 0 { if ps := _q.order; len(ps) > 0 {
_spec.Order = func(selector *sql.Selector) { _spec.Order = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) ps[i](selector)
@@ -497,45 +499,45 @@ func (wq *WeaponQuery) querySpec() *sqlgraph.QuerySpec {
return _spec return _spec
} }
func (wq *WeaponQuery) sqlQuery(ctx context.Context) *sql.Selector { func (_q *WeaponQuery) sqlQuery(ctx context.Context) *sql.Selector {
builder := sql.Dialect(wq.driver.Dialect()) builder := sql.Dialect(_q.driver.Dialect())
t1 := builder.Table(weapon.Table) t1 := builder.Table(weapon.Table)
columns := wq.ctx.Fields columns := _q.ctx.Fields
if len(columns) == 0 { if len(columns) == 0 {
columns = weapon.Columns columns = weapon.Columns
} }
selector := builder.Select(t1.Columns(columns...)...).From(t1) selector := builder.Select(t1.Columns(columns...)...).From(t1)
if wq.sql != nil { if _q.sql != nil {
selector = wq.sql selector = _q.sql
selector.Select(selector.Columns(columns...)...) selector.Select(selector.Columns(columns...)...)
} }
if wq.ctx.Unique != nil && *wq.ctx.Unique { if _q.ctx.Unique != nil && *_q.ctx.Unique {
selector.Distinct() selector.Distinct()
} }
for _, m := range wq.modifiers { for _, m := range _q.modifiers {
m(selector) m(selector)
} }
for _, p := range wq.predicates { for _, p := range _q.predicates {
p(selector) p(selector)
} }
for _, p := range wq.order { for _, p := range _q.order {
p(selector) p(selector)
} }
if offset := wq.ctx.Offset; offset != nil { if offset := _q.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start // limit is mandatory for offset clause. We start
// with default value, and override it below if needed. // with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32) selector.Offset(*offset).Limit(math.MaxInt32)
} }
if limit := wq.ctx.Limit; limit != nil { if limit := _q.ctx.Limit; limit != nil {
selector.Limit(*limit) selector.Limit(*limit)
} }
return selector return selector
} }
// Modify adds a query modifier for attaching custom logic to queries. // Modify adds a query modifier for attaching custom logic to queries.
func (wq *WeaponQuery) Modify(modifiers ...func(s *sql.Selector)) *WeaponSelect { func (_q *WeaponQuery) Modify(modifiers ...func(s *sql.Selector)) *WeaponSelect {
wq.modifiers = append(wq.modifiers, modifiers...) _q.modifiers = append(_q.modifiers, modifiers...)
return wq.Select() return _q.Select()
} }
// WeaponGroupBy is the group-by builder for Weapon entities. // 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. // Aggregate adds the given aggregation functions to the group-by query.
func (wgb *WeaponGroupBy) Aggregate(fns ...AggregateFunc) *WeaponGroupBy { func (_g *WeaponGroupBy) Aggregate(fns ...AggregateFunc) *WeaponGroupBy {
wgb.fns = append(wgb.fns, fns...) _g.fns = append(_g.fns, fns...)
return wgb return _g
} }
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (wgb *WeaponGroupBy) Scan(ctx context.Context, v any) error { func (_g *WeaponGroupBy) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, wgb.build.ctx, "GroupBy") ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
if err := wgb.build.prepareQuery(ctx); err != nil { if err := _g.build.prepareQuery(ctx); err != nil {
return err 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() selector := root.sqlQuery(ctx).Select()
aggregation := make([]string, 0, len(wgb.fns)) aggregation := make([]string, 0, len(_g.fns))
for _, fn := range wgb.fns { for _, fn := range _g.fns {
aggregation = append(aggregation, fn(selector)) aggregation = append(aggregation, fn(selector))
} }
if len(selector.SelectedColumns()) == 0 { if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len(*wgb.flds)+len(wgb.fns)) columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
for _, f := range *wgb.flds { for _, f := range *_g.flds {
columns = append(columns, selector.C(f)) columns = append(columns, selector.C(f))
} }
columns = append(columns, aggregation...) columns = append(columns, aggregation...)
selector.Select(columns...) selector.Select(columns...)
} }
selector.GroupBy(selector.Columns(*wgb.flds...)...) selector.GroupBy(selector.Columns(*_g.flds...)...)
if err := selector.Err(); err != nil { if err := selector.Err(); err != nil {
return err return err
} }
rows := &sql.Rows{} rows := &sql.Rows{}
query, args := selector.Query() 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 return err
} }
defer rows.Close() defer rows.Close()
@@ -593,27 +595,27 @@ type WeaponSelect struct {
} }
// Aggregate adds the given aggregation functions to the selector query. // Aggregate adds the given aggregation functions to the selector query.
func (ws *WeaponSelect) Aggregate(fns ...AggregateFunc) *WeaponSelect { func (_s *WeaponSelect) Aggregate(fns ...AggregateFunc) *WeaponSelect {
ws.fns = append(ws.fns, fns...) _s.fns = append(_s.fns, fns...)
return ws return _s
} }
// Scan applies the selector query and scans the result into the given value. // Scan applies the selector query and scans the result into the given value.
func (ws *WeaponSelect) Scan(ctx context.Context, v any) error { func (_s *WeaponSelect) Scan(ctx context.Context, v any) error {
ctx = setContextOp(ctx, ws.ctx, "Select") ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
if err := ws.prepareQuery(ctx); err != nil { if err := _s.prepareQuery(ctx); err != nil {
return err 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) selector := root.sqlQuery(ctx)
aggregation := make([]string, 0, len(ws.fns)) aggregation := make([]string, 0, len(_s.fns))
for _, fn := range ws.fns { for _, fn := range _s.fns {
aggregation = append(aggregation, fn(selector)) aggregation = append(aggregation, fn(selector))
} }
switch n := len(*ws.selector.flds); { switch n := len(*_s.selector.flds); {
case n == 0 && len(aggregation) > 0: case n == 0 && len(aggregation) > 0:
selector.Select(aggregation...) selector.Select(aggregation...)
case n != 0 && len(aggregation) > 0: 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{} rows := &sql.Rows{}
query, args := selector.Query() 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 return err
} }
defer rows.Close() 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. // Modify adds a query modifier for attaching custom logic to queries.
func (ws *WeaponSelect) Modify(modifiers ...func(s *sql.Selector)) *WeaponSelect { func (_s *WeaponSelect) Modify(modifiers ...func(s *sql.Selector)) *WeaponSelect {
ws.modifiers = append(ws.modifiers, modifiers...) _s.modifiers = append(_s.modifiers, modifiers...)
return ws return _s
} }

View File

@@ -24,101 +24,133 @@ type WeaponUpdate struct {
} }
// Where appends a list predicates to the WeaponUpdate builder. // Where appends a list predicates to the WeaponUpdate builder.
func (wu *WeaponUpdate) Where(ps ...predicate.Weapon) *WeaponUpdate { func (_u *WeaponUpdate) Where(ps ...predicate.Weapon) *WeaponUpdate {
wu.mutation.Where(ps...) _u.mutation.Where(ps...)
return wu return _u
} }
// SetVictim sets the "victim" field. // SetVictim sets the "victim" field.
func (wu *WeaponUpdate) SetVictim(u uint64) *WeaponUpdate { func (_u *WeaponUpdate) SetVictim(v uint64) *WeaponUpdate {
wu.mutation.ResetVictim() _u.mutation.ResetVictim()
wu.mutation.SetVictim(u) _u.mutation.SetVictim(v)
return wu return _u
} }
// AddVictim adds u to the "victim" field. // SetNillableVictim sets the "victim" field if the given value is not nil.
func (wu *WeaponUpdate) AddVictim(u int64) *WeaponUpdate { func (_u *WeaponUpdate) SetNillableVictim(v *uint64) *WeaponUpdate {
wu.mutation.AddVictim(u) if v != nil {
return wu _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. // SetDmg sets the "dmg" field.
func (wu *WeaponUpdate) SetDmg(u uint) *WeaponUpdate { func (_u *WeaponUpdate) SetDmg(v uint) *WeaponUpdate {
wu.mutation.ResetDmg() _u.mutation.ResetDmg()
wu.mutation.SetDmg(u) _u.mutation.SetDmg(v)
return wu return _u
} }
// AddDmg adds u to the "dmg" field. // SetNillableDmg sets the "dmg" field if the given value is not nil.
func (wu *WeaponUpdate) AddDmg(u int) *WeaponUpdate { func (_u *WeaponUpdate) SetNillableDmg(v *uint) *WeaponUpdate {
wu.mutation.AddDmg(u) if v != nil {
return wu _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. // SetEqType sets the "eq_type" field.
func (wu *WeaponUpdate) SetEqType(i int) *WeaponUpdate { func (_u *WeaponUpdate) SetEqType(v int) *WeaponUpdate {
wu.mutation.ResetEqType() _u.mutation.ResetEqType()
wu.mutation.SetEqType(i) _u.mutation.SetEqType(v)
return wu return _u
} }
// AddEqType adds i to the "eq_type" field. // SetNillableEqType sets the "eq_type" field if the given value is not nil.
func (wu *WeaponUpdate) AddEqType(i int) *WeaponUpdate { func (_u *WeaponUpdate) SetNillableEqType(v *int) *WeaponUpdate {
wu.mutation.AddEqType(i) if v != nil {
return wu _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. // SetHitGroup sets the "hit_group" field.
func (wu *WeaponUpdate) SetHitGroup(i int) *WeaponUpdate { func (_u *WeaponUpdate) SetHitGroup(v int) *WeaponUpdate {
wu.mutation.ResetHitGroup() _u.mutation.ResetHitGroup()
wu.mutation.SetHitGroup(i) _u.mutation.SetHitGroup(v)
return wu return _u
} }
// AddHitGroup adds i to the "hit_group" field. // SetNillableHitGroup sets the "hit_group" field if the given value is not nil.
func (wu *WeaponUpdate) AddHitGroup(i int) *WeaponUpdate { func (_u *WeaponUpdate) SetNillableHitGroup(v *int) *WeaponUpdate {
wu.mutation.AddHitGroup(i) if v != nil {
return wu _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. // SetStatID sets the "stat" edge to the MatchPlayer entity by ID.
func (wu *WeaponUpdate) SetStatID(id int) *WeaponUpdate { func (_u *WeaponUpdate) SetStatID(id int) *WeaponUpdate {
wu.mutation.SetStatID(id) _u.mutation.SetStatID(id)
return wu return _u
} }
// SetNillableStatID sets the "stat" edge to the MatchPlayer entity by ID if the given value is not nil. // 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 { if id != nil {
wu = wu.SetStatID(*id) _u = _u.SetStatID(*id)
} }
return wu return _u
} }
// SetStat sets the "stat" edge to the MatchPlayer entity. // SetStat sets the "stat" edge to the MatchPlayer entity.
func (wu *WeaponUpdate) SetStat(m *MatchPlayer) *WeaponUpdate { func (_u *WeaponUpdate) SetStat(v *MatchPlayer) *WeaponUpdate {
return wu.SetStatID(m.ID) return _u.SetStatID(v.ID)
} }
// Mutation returns the WeaponMutation object of the builder. // Mutation returns the WeaponMutation object of the builder.
func (wu *WeaponUpdate) Mutation() *WeaponMutation { func (_u *WeaponUpdate) Mutation() *WeaponMutation {
return wu.mutation return _u.mutation
} }
// ClearStat clears the "stat" edge to the MatchPlayer entity. // ClearStat clears the "stat" edge to the MatchPlayer entity.
func (wu *WeaponUpdate) ClearStat() *WeaponUpdate { func (_u *WeaponUpdate) ClearStat() *WeaponUpdate {
wu.mutation.ClearStat() _u.mutation.ClearStat()
return wu return _u
} }
// Save executes the query and returns the number of nodes affected by the update operation. // Save executes the query and returns the number of nodes affected by the update operation.
func (wu *WeaponUpdate) Save(ctx context.Context) (int, error) { func (_u *WeaponUpdate) Save(ctx context.Context) (int, error) {
return withHooks(ctx, wu.sqlSave, wu.mutation, wu.hooks) return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
func (wu *WeaponUpdate) SaveX(ctx context.Context) int { func (_u *WeaponUpdate) SaveX(ctx context.Context) int {
affected, err := wu.Save(ctx) affected, err := _u.Save(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -126,58 +158,58 @@ func (wu *WeaponUpdate) SaveX(ctx context.Context) int {
} }
// Exec executes the query. // Exec executes the query.
func (wu *WeaponUpdate) Exec(ctx context.Context) error { func (_u *WeaponUpdate) Exec(ctx context.Context) error {
_, err := wu.Save(ctx) _, err := _u.Save(ctx)
return err return err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (wu *WeaponUpdate) ExecX(ctx context.Context) { func (_u *WeaponUpdate) ExecX(ctx context.Context) {
if err := wu.Exec(ctx); err != nil { if err := _u.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. // Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (wu *WeaponUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WeaponUpdate { func (_u *WeaponUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WeaponUpdate {
wu.modifiers = append(wu.modifiers, modifiers...) _u.modifiers = append(_u.modifiers, modifiers...)
return wu 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)) _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) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) ps[i](selector)
} }
} }
} }
if value, ok := wu.mutation.Victim(); ok { if value, ok := _u.mutation.Victim(); ok {
_spec.SetField(weapon.FieldVictim, field.TypeUint64, value) _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) _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) _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) _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) _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) _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) _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) _spec.AddField(weapon.FieldHitGroup, field.TypeInt, value)
} }
if wu.mutation.StatCleared() { if _u.mutation.StatCleared() {
edge := &sqlgraph.EdgeSpec{ edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O, Rel: sqlgraph.M2O,
Inverse: true, 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) _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{ edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O, Rel: sqlgraph.M2O,
Inverse: true, 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.Edges.Add = append(_spec.Edges.Add, edge)
} }
_spec.AddModifiers(wu.modifiers...) _spec.AddModifiers(_u.modifiers...)
if n, err = sqlgraph.UpdateNodes(ctx, wu.driver, _spec); err != nil { if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok { if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{weapon.Label} err = &NotFoundError{weapon.Label}
} else if sqlgraph.IsConstraintError(err) { } else if sqlgraph.IsConstraintError(err) {
@@ -215,8 +247,8 @@ func (wu *WeaponUpdate) sqlSave(ctx context.Context) (n int, err error) {
} }
return 0, err return 0, err
} }
wu.mutation.done = true _u.mutation.done = true
return n, nil return _node, nil
} }
// WeaponUpdateOne is the builder for updating a single Weapon entity. // WeaponUpdateOne is the builder for updating a single Weapon entity.
@@ -229,108 +261,140 @@ type WeaponUpdateOne struct {
} }
// SetVictim sets the "victim" field. // SetVictim sets the "victim" field.
func (wuo *WeaponUpdateOne) SetVictim(u uint64) *WeaponUpdateOne { func (_u *WeaponUpdateOne) SetVictim(v uint64) *WeaponUpdateOne {
wuo.mutation.ResetVictim() _u.mutation.ResetVictim()
wuo.mutation.SetVictim(u) _u.mutation.SetVictim(v)
return wuo return _u
} }
// AddVictim adds u to the "victim" field. // SetNillableVictim sets the "victim" field if the given value is not nil.
func (wuo *WeaponUpdateOne) AddVictim(u int64) *WeaponUpdateOne { func (_u *WeaponUpdateOne) SetNillableVictim(v *uint64) *WeaponUpdateOne {
wuo.mutation.AddVictim(u) if v != nil {
return wuo _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. // SetDmg sets the "dmg" field.
func (wuo *WeaponUpdateOne) SetDmg(u uint) *WeaponUpdateOne { func (_u *WeaponUpdateOne) SetDmg(v uint) *WeaponUpdateOne {
wuo.mutation.ResetDmg() _u.mutation.ResetDmg()
wuo.mutation.SetDmg(u) _u.mutation.SetDmg(v)
return wuo return _u
} }
// AddDmg adds u to the "dmg" field. // SetNillableDmg sets the "dmg" field if the given value is not nil.
func (wuo *WeaponUpdateOne) AddDmg(u int) *WeaponUpdateOne { func (_u *WeaponUpdateOne) SetNillableDmg(v *uint) *WeaponUpdateOne {
wuo.mutation.AddDmg(u) if v != nil {
return wuo _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. // SetEqType sets the "eq_type" field.
func (wuo *WeaponUpdateOne) SetEqType(i int) *WeaponUpdateOne { func (_u *WeaponUpdateOne) SetEqType(v int) *WeaponUpdateOne {
wuo.mutation.ResetEqType() _u.mutation.ResetEqType()
wuo.mutation.SetEqType(i) _u.mutation.SetEqType(v)
return wuo return _u
} }
// AddEqType adds i to the "eq_type" field. // SetNillableEqType sets the "eq_type" field if the given value is not nil.
func (wuo *WeaponUpdateOne) AddEqType(i int) *WeaponUpdateOne { func (_u *WeaponUpdateOne) SetNillableEqType(v *int) *WeaponUpdateOne {
wuo.mutation.AddEqType(i) if v != nil {
return wuo _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. // SetHitGroup sets the "hit_group" field.
func (wuo *WeaponUpdateOne) SetHitGroup(i int) *WeaponUpdateOne { func (_u *WeaponUpdateOne) SetHitGroup(v int) *WeaponUpdateOne {
wuo.mutation.ResetHitGroup() _u.mutation.ResetHitGroup()
wuo.mutation.SetHitGroup(i) _u.mutation.SetHitGroup(v)
return wuo return _u
} }
// AddHitGroup adds i to the "hit_group" field. // SetNillableHitGroup sets the "hit_group" field if the given value is not nil.
func (wuo *WeaponUpdateOne) AddHitGroup(i int) *WeaponUpdateOne { func (_u *WeaponUpdateOne) SetNillableHitGroup(v *int) *WeaponUpdateOne {
wuo.mutation.AddHitGroup(i) if v != nil {
return wuo _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. // SetStatID sets the "stat" edge to the MatchPlayer entity by ID.
func (wuo *WeaponUpdateOne) SetStatID(id int) *WeaponUpdateOne { func (_u *WeaponUpdateOne) SetStatID(id int) *WeaponUpdateOne {
wuo.mutation.SetStatID(id) _u.mutation.SetStatID(id)
return wuo return _u
} }
// SetNillableStatID sets the "stat" edge to the MatchPlayer entity by ID if the given value is not nil. // 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 { if id != nil {
wuo = wuo.SetStatID(*id) _u = _u.SetStatID(*id)
} }
return wuo return _u
} }
// SetStat sets the "stat" edge to the MatchPlayer entity. // SetStat sets the "stat" edge to the MatchPlayer entity.
func (wuo *WeaponUpdateOne) SetStat(m *MatchPlayer) *WeaponUpdateOne { func (_u *WeaponUpdateOne) SetStat(v *MatchPlayer) *WeaponUpdateOne {
return wuo.SetStatID(m.ID) return _u.SetStatID(v.ID)
} }
// Mutation returns the WeaponMutation object of the builder. // Mutation returns the WeaponMutation object of the builder.
func (wuo *WeaponUpdateOne) Mutation() *WeaponMutation { func (_u *WeaponUpdateOne) Mutation() *WeaponMutation {
return wuo.mutation return _u.mutation
} }
// ClearStat clears the "stat" edge to the MatchPlayer entity. // ClearStat clears the "stat" edge to the MatchPlayer entity.
func (wuo *WeaponUpdateOne) ClearStat() *WeaponUpdateOne { func (_u *WeaponUpdateOne) ClearStat() *WeaponUpdateOne {
wuo.mutation.ClearStat() _u.mutation.ClearStat()
return wuo return _u
} }
// Where appends a list predicates to the WeaponUpdate builder. // Where appends a list predicates to the WeaponUpdate builder.
func (wuo *WeaponUpdateOne) Where(ps ...predicate.Weapon) *WeaponUpdateOne { func (_u *WeaponUpdateOne) Where(ps ...predicate.Weapon) *WeaponUpdateOne {
wuo.mutation.Where(ps...) _u.mutation.Where(ps...)
return wuo return _u
} }
// Select allows selecting one or more fields (columns) of the returned entity. // Select allows selecting one or more fields (columns) of the returned entity.
// The default is selecting all fields defined in the entity schema. // The default is selecting all fields defined in the entity schema.
func (wuo *WeaponUpdateOne) Select(field string, fields ...string) *WeaponUpdateOne { func (_u *WeaponUpdateOne) Select(field string, fields ...string) *WeaponUpdateOne {
wuo.fields = append([]string{field}, fields...) _u.fields = append([]string{field}, fields...)
return wuo return _u
} }
// Save executes the query and returns the updated Weapon entity. // Save executes the query and returns the updated Weapon entity.
func (wuo *WeaponUpdateOne) Save(ctx context.Context) (*Weapon, error) { func (_u *WeaponUpdateOne) Save(ctx context.Context) (*Weapon, error) {
return withHooks(ctx, wuo.sqlSave, wuo.mutation, wuo.hooks) return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
} }
// SaveX is like Save, but panics if an error occurs. // SaveX is like Save, but panics if an error occurs.
func (wuo *WeaponUpdateOne) SaveX(ctx context.Context) *Weapon { func (_u *WeaponUpdateOne) SaveX(ctx context.Context) *Weapon {
node, err := wuo.Save(ctx) node, err := _u.Save(ctx)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -338,32 +402,32 @@ func (wuo *WeaponUpdateOne) SaveX(ctx context.Context) *Weapon {
} }
// Exec executes the query on the entity. // Exec executes the query on the entity.
func (wuo *WeaponUpdateOne) Exec(ctx context.Context) error { func (_u *WeaponUpdateOne) Exec(ctx context.Context) error {
_, err := wuo.Save(ctx) _, err := _u.Save(ctx)
return err return err
} }
// ExecX is like Exec, but panics if an error occurs. // ExecX is like Exec, but panics if an error occurs.
func (wuo *WeaponUpdateOne) ExecX(ctx context.Context) { func (_u *WeaponUpdateOne) ExecX(ctx context.Context) {
if err := wuo.Exec(ctx); err != nil { if err := _u.Exec(ctx); err != nil {
panic(err) panic(err)
} }
} }
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement. // Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
func (wuo *WeaponUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WeaponUpdateOne { func (_u *WeaponUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WeaponUpdateOne {
wuo.modifiers = append(wuo.modifiers, modifiers...) _u.modifiers = append(_u.modifiers, modifiers...)
return wuo 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)) _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 { if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Weapon.id" for update`)} return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Weapon.id" for update`)}
} }
_spec.Node.ID.Value = id _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 = make([]string, 0, len(fields))
_spec.Node.Columns = append(_spec.Node.Columns, weapon.FieldID) _spec.Node.Columns = append(_spec.Node.Columns, weapon.FieldID)
for _, f := range fields { 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) { _spec.Predicate = func(selector *sql.Selector) {
for i := range ps { for i := range ps {
ps[i](selector) ps[i](selector)
} }
} }
} }
if value, ok := wuo.mutation.Victim(); ok { if value, ok := _u.mutation.Victim(); ok {
_spec.SetField(weapon.FieldVictim, field.TypeUint64, value) _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) _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) _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) _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) _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) _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) _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) _spec.AddField(weapon.FieldHitGroup, field.TypeInt, value)
} }
if wuo.mutation.StatCleared() { if _u.mutation.StatCleared() {
edge := &sqlgraph.EdgeSpec{ edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O, Rel: sqlgraph.M2O,
Inverse: true, 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) _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{ edge := &sqlgraph.EdgeSpec{
Rel: sqlgraph.M2O, Rel: sqlgraph.M2O,
Inverse: true, 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.Edges.Add = append(_spec.Edges.Add, edge)
} }
_spec.AddModifiers(wuo.modifiers...) _spec.AddModifiers(_u.modifiers...)
_node = &Weapon{config: wuo.config} _node = &Weapon{config: _u.config}
_spec.Assign = _node.assignValues _spec.Assign = _node.assignValues
_spec.ScanValues = _node.scanValues _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 { if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{weapon.Label} err = &NotFoundError{weapon.Label}
} else if sqlgraph.IsConstraintError(err) { } else if sqlgraph.IsConstraintError(err) {
@@ -447,6 +511,6 @@ func (wuo *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err err
} }
return nil, err return nil, err
} }
wuo.mutation.done = true _u.mutation.done = true
return _node, nil return _node, nil
} }