regenerate ent
This commit is contained in:
262
ent/client.go
262
ent/client.go
@@ -7,6 +7,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"reflect"
|
||||
|
||||
"somegit.dev/csgowtf/csgowtfd/ent/migrate"
|
||||
|
||||
@@ -46,9 +47,7 @@ type Client struct {
|
||||
|
||||
// NewClient creates a new client configured with the given options.
|
||||
func NewClient(opts ...Option) *Client {
|
||||
cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}}
|
||||
cfg.options(opts...)
|
||||
client := &Client{config: cfg}
|
||||
client := &Client{config: newConfig(opts...)}
|
||||
client.init()
|
||||
return client
|
||||
}
|
||||
@@ -82,6 +81,13 @@ type (
|
||||
Option func(*config)
|
||||
)
|
||||
|
||||
// newConfig creates a new config for the client.
|
||||
func newConfig(opts ...Option) config {
|
||||
cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}}
|
||||
cfg.options(opts...)
|
||||
return cfg
|
||||
}
|
||||
|
||||
// options applies the options on the config object.
|
||||
func (c *config) options(opts ...Option) {
|
||||
for _, opt := range opts {
|
||||
@@ -129,11 +135,14 @@ func Open(driverName, dataSourceName string, options ...Option) (*Client, error)
|
||||
}
|
||||
}
|
||||
|
||||
// ErrTxStarted is returned when trying to start a new transaction from a transactional client.
|
||||
var ErrTxStarted = errors.New("ent: cannot start a transaction within a transaction")
|
||||
|
||||
// Tx returns a new transactional client. The provided context
|
||||
// is used until the transaction is committed or rolled back.
|
||||
func (c *Client) Tx(ctx context.Context) (*Tx, error) {
|
||||
if _, ok := c.driver.(*txDriver); ok {
|
||||
return nil, errors.New("ent: cannot start a transaction within a transaction")
|
||||
return nil, ErrTxStarted
|
||||
}
|
||||
tx, err := newTx(ctx, c.driver)
|
||||
if err != nil {
|
||||
@@ -277,6 +286,21 @@ func (c *MatchClient) CreateBulk(builders ...*MatchCreate) *MatchCreateBulk {
|
||||
return &MatchCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||
// a builder and applies setFunc on it.
|
||||
func (c *MatchClient) MapCreateBulk(slice any, setFunc func(*MatchCreate, int)) *MatchCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &MatchCreateBulk{err: fmt.Errorf("calling to MatchClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*MatchCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &MatchCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for Match.
|
||||
func (c *MatchClient) Update() *MatchUpdate {
|
||||
mutation := newMatchMutation(c.config, OpUpdate)
|
||||
@@ -284,8 +308,8 @@ func (c *MatchClient) Update() *MatchUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *MatchClient) UpdateOne(m *Match) *MatchUpdateOne {
|
||||
mutation := newMatchMutation(c.config, OpUpdateOne, withMatch(m))
|
||||
func (c *MatchClient) UpdateOne(_m *Match) *MatchUpdateOne {
|
||||
mutation := newMatchMutation(c.config, OpUpdateOne, withMatch(_m))
|
||||
return &MatchUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -302,8 +326,8 @@ func (c *MatchClient) Delete() *MatchDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *MatchClient) DeleteOne(m *Match) *MatchDeleteOne {
|
||||
return c.DeleteOneID(m.ID)
|
||||
func (c *MatchClient) DeleteOne(_m *Match) *MatchDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -338,32 +362,32 @@ func (c *MatchClient) GetX(ctx context.Context, id uint64) *Match {
|
||||
}
|
||||
|
||||
// QueryStats queries the stats edge of a Match.
|
||||
func (c *MatchClient) QueryStats(m *Match) *MatchPlayerQuery {
|
||||
func (c *MatchClient) QueryStats(_m *Match) *MatchPlayerQuery {
|
||||
query := (&MatchPlayerClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := m.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(match.Table, match.FieldID, id),
|
||||
sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, match.StatsTable, match.StatsColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(m.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryPlayers queries the players edge of a Match.
|
||||
func (c *MatchClient) QueryPlayers(m *Match) *PlayerQuery {
|
||||
func (c *MatchClient) QueryPlayers(_m *Match) *PlayerQuery {
|
||||
query := (&PlayerClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := m.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(match.Table, match.FieldID, id),
|
||||
sqlgraph.To(player.Table, player.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, true, match.PlayersTable, match.PlayersPrimaryKey...),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(m.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
@@ -427,6 +451,21 @@ func (c *MatchPlayerClient) CreateBulk(builders ...*MatchPlayerCreate) *MatchPla
|
||||
return &MatchPlayerCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||
// a builder and applies setFunc on it.
|
||||
func (c *MatchPlayerClient) MapCreateBulk(slice any, setFunc func(*MatchPlayerCreate, int)) *MatchPlayerCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &MatchPlayerCreateBulk{err: fmt.Errorf("calling to MatchPlayerClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*MatchPlayerCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &MatchPlayerCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for MatchPlayer.
|
||||
func (c *MatchPlayerClient) Update() *MatchPlayerUpdate {
|
||||
mutation := newMatchPlayerMutation(c.config, OpUpdate)
|
||||
@@ -434,8 +473,8 @@ func (c *MatchPlayerClient) Update() *MatchPlayerUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *MatchPlayerClient) UpdateOne(mp *MatchPlayer) *MatchPlayerUpdateOne {
|
||||
mutation := newMatchPlayerMutation(c.config, OpUpdateOne, withMatchPlayer(mp))
|
||||
func (c *MatchPlayerClient) UpdateOne(_m *MatchPlayer) *MatchPlayerUpdateOne {
|
||||
mutation := newMatchPlayerMutation(c.config, OpUpdateOne, withMatchPlayer(_m))
|
||||
return &MatchPlayerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -452,8 +491,8 @@ func (c *MatchPlayerClient) Delete() *MatchPlayerDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *MatchPlayerClient) DeleteOne(mp *MatchPlayer) *MatchPlayerDeleteOne {
|
||||
return c.DeleteOneID(mp.ID)
|
||||
func (c *MatchPlayerClient) DeleteOne(_m *MatchPlayer) *MatchPlayerDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -488,96 +527,96 @@ func (c *MatchPlayerClient) GetX(ctx context.Context, id int) *MatchPlayer {
|
||||
}
|
||||
|
||||
// QueryMatches queries the matches edge of a MatchPlayer.
|
||||
func (c *MatchPlayerClient) QueryMatches(mp *MatchPlayer) *MatchQuery {
|
||||
func (c *MatchPlayerClient) QueryMatches(_m *MatchPlayer) *MatchQuery {
|
||||
query := (&MatchClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := mp.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id),
|
||||
sqlgraph.To(match.Table, match.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, matchplayer.MatchesTable, matchplayer.MatchesColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(mp.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryPlayers queries the players edge of a MatchPlayer.
|
||||
func (c *MatchPlayerClient) QueryPlayers(mp *MatchPlayer) *PlayerQuery {
|
||||
func (c *MatchPlayerClient) QueryPlayers(_m *MatchPlayer) *PlayerQuery {
|
||||
query := (&PlayerClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := mp.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id),
|
||||
sqlgraph.To(player.Table, player.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, matchplayer.PlayersTable, matchplayer.PlayersColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(mp.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryWeaponStats queries the weapon_stats edge of a MatchPlayer.
|
||||
func (c *MatchPlayerClient) QueryWeaponStats(mp *MatchPlayer) *WeaponQuery {
|
||||
func (c *MatchPlayerClient) QueryWeaponStats(_m *MatchPlayer) *WeaponQuery {
|
||||
query := (&WeaponClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := mp.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id),
|
||||
sqlgraph.To(weapon.Table, weapon.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.WeaponStatsTable, matchplayer.WeaponStatsColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(mp.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryRoundStats queries the round_stats edge of a MatchPlayer.
|
||||
func (c *MatchPlayerClient) QueryRoundStats(mp *MatchPlayer) *RoundStatsQuery {
|
||||
func (c *MatchPlayerClient) QueryRoundStats(_m *MatchPlayer) *RoundStatsQuery {
|
||||
query := (&RoundStatsClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := mp.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id),
|
||||
sqlgraph.To(roundstats.Table, roundstats.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.RoundStatsTable, matchplayer.RoundStatsColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(mp.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QuerySpray queries the spray edge of a MatchPlayer.
|
||||
func (c *MatchPlayerClient) QuerySpray(mp *MatchPlayer) *SprayQuery {
|
||||
func (c *MatchPlayerClient) QuerySpray(_m *MatchPlayer) *SprayQuery {
|
||||
query := (&SprayClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := mp.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id),
|
||||
sqlgraph.To(spray.Table, spray.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.SprayTable, matchplayer.SprayColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(mp.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryMessages queries the messages edge of a MatchPlayer.
|
||||
func (c *MatchPlayerClient) QueryMessages(mp *MatchPlayer) *MessagesQuery {
|
||||
func (c *MatchPlayerClient) QueryMessages(_m *MatchPlayer) *MessagesQuery {
|
||||
query := (&MessagesClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := mp.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(matchplayer.Table, matchplayer.FieldID, id),
|
||||
sqlgraph.To(messages.Table, messages.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.MessagesTable, matchplayer.MessagesColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(mp.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
@@ -641,6 +680,21 @@ func (c *MessagesClient) CreateBulk(builders ...*MessagesCreate) *MessagesCreate
|
||||
return &MessagesCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||
// a builder and applies setFunc on it.
|
||||
func (c *MessagesClient) MapCreateBulk(slice any, setFunc func(*MessagesCreate, int)) *MessagesCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &MessagesCreateBulk{err: fmt.Errorf("calling to MessagesClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*MessagesCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &MessagesCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for Messages.
|
||||
func (c *MessagesClient) Update() *MessagesUpdate {
|
||||
mutation := newMessagesMutation(c.config, OpUpdate)
|
||||
@@ -648,8 +702,8 @@ func (c *MessagesClient) Update() *MessagesUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *MessagesClient) UpdateOne(m *Messages) *MessagesUpdateOne {
|
||||
mutation := newMessagesMutation(c.config, OpUpdateOne, withMessages(m))
|
||||
func (c *MessagesClient) UpdateOne(_m *Messages) *MessagesUpdateOne {
|
||||
mutation := newMessagesMutation(c.config, OpUpdateOne, withMessages(_m))
|
||||
return &MessagesUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -666,8 +720,8 @@ func (c *MessagesClient) Delete() *MessagesDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *MessagesClient) DeleteOne(m *Messages) *MessagesDeleteOne {
|
||||
return c.DeleteOneID(m.ID)
|
||||
func (c *MessagesClient) DeleteOne(_m *Messages) *MessagesDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -702,16 +756,16 @@ func (c *MessagesClient) GetX(ctx context.Context, id int) *Messages {
|
||||
}
|
||||
|
||||
// QueryMatchPlayer queries the match_player edge of a Messages.
|
||||
func (c *MessagesClient) QueryMatchPlayer(m *Messages) *MatchPlayerQuery {
|
||||
func (c *MessagesClient) QueryMatchPlayer(_m *Messages) *MatchPlayerQuery {
|
||||
query := (&MatchPlayerClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := m.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(messages.Table, messages.FieldID, id),
|
||||
sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, messages.MatchPlayerTable, messages.MatchPlayerColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(m.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
@@ -775,6 +829,21 @@ func (c *PlayerClient) CreateBulk(builders ...*PlayerCreate) *PlayerCreateBulk {
|
||||
return &PlayerCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||
// a builder and applies setFunc on it.
|
||||
func (c *PlayerClient) MapCreateBulk(slice any, setFunc func(*PlayerCreate, int)) *PlayerCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &PlayerCreateBulk{err: fmt.Errorf("calling to PlayerClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*PlayerCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &PlayerCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for Player.
|
||||
func (c *PlayerClient) Update() *PlayerUpdate {
|
||||
mutation := newPlayerMutation(c.config, OpUpdate)
|
||||
@@ -782,8 +851,8 @@ func (c *PlayerClient) Update() *PlayerUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *PlayerClient) UpdateOne(pl *Player) *PlayerUpdateOne {
|
||||
mutation := newPlayerMutation(c.config, OpUpdateOne, withPlayer(pl))
|
||||
func (c *PlayerClient) UpdateOne(_m *Player) *PlayerUpdateOne {
|
||||
mutation := newPlayerMutation(c.config, OpUpdateOne, withPlayer(_m))
|
||||
return &PlayerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -800,8 +869,8 @@ func (c *PlayerClient) Delete() *PlayerDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *PlayerClient) DeleteOne(pl *Player) *PlayerDeleteOne {
|
||||
return c.DeleteOneID(pl.ID)
|
||||
func (c *PlayerClient) DeleteOne(_m *Player) *PlayerDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -836,32 +905,32 @@ func (c *PlayerClient) GetX(ctx context.Context, id uint64) *Player {
|
||||
}
|
||||
|
||||
// QueryStats queries the stats edge of a Player.
|
||||
func (c *PlayerClient) QueryStats(pl *Player) *MatchPlayerQuery {
|
||||
func (c *PlayerClient) QueryStats(_m *Player) *MatchPlayerQuery {
|
||||
query := (&MatchPlayerClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := pl.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(player.Table, player.FieldID, id),
|
||||
sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, player.StatsTable, player.StatsColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(pl.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryMatches queries the matches edge of a Player.
|
||||
func (c *PlayerClient) QueryMatches(pl *Player) *MatchQuery {
|
||||
func (c *PlayerClient) QueryMatches(_m *Player) *MatchQuery {
|
||||
query := (&MatchClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := pl.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(player.Table, player.FieldID, id),
|
||||
sqlgraph.To(match.Table, match.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, false, player.MatchesTable, player.MatchesPrimaryKey...),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(pl.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
@@ -925,6 +994,21 @@ func (c *RoundStatsClient) CreateBulk(builders ...*RoundStatsCreate) *RoundStats
|
||||
return &RoundStatsCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||
// a builder and applies setFunc on it.
|
||||
func (c *RoundStatsClient) MapCreateBulk(slice any, setFunc func(*RoundStatsCreate, int)) *RoundStatsCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &RoundStatsCreateBulk{err: fmt.Errorf("calling to RoundStatsClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*RoundStatsCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &RoundStatsCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for RoundStats.
|
||||
func (c *RoundStatsClient) Update() *RoundStatsUpdate {
|
||||
mutation := newRoundStatsMutation(c.config, OpUpdate)
|
||||
@@ -932,8 +1016,8 @@ func (c *RoundStatsClient) Update() *RoundStatsUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *RoundStatsClient) UpdateOne(rs *RoundStats) *RoundStatsUpdateOne {
|
||||
mutation := newRoundStatsMutation(c.config, OpUpdateOne, withRoundStats(rs))
|
||||
func (c *RoundStatsClient) UpdateOne(_m *RoundStats) *RoundStatsUpdateOne {
|
||||
mutation := newRoundStatsMutation(c.config, OpUpdateOne, withRoundStats(_m))
|
||||
return &RoundStatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -950,8 +1034,8 @@ func (c *RoundStatsClient) Delete() *RoundStatsDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *RoundStatsClient) DeleteOne(rs *RoundStats) *RoundStatsDeleteOne {
|
||||
return c.DeleteOneID(rs.ID)
|
||||
func (c *RoundStatsClient) DeleteOne(_m *RoundStats) *RoundStatsDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -986,16 +1070,16 @@ func (c *RoundStatsClient) GetX(ctx context.Context, id int) *RoundStats {
|
||||
}
|
||||
|
||||
// QueryMatchPlayer queries the match_player edge of a RoundStats.
|
||||
func (c *RoundStatsClient) QueryMatchPlayer(rs *RoundStats) *MatchPlayerQuery {
|
||||
func (c *RoundStatsClient) QueryMatchPlayer(_m *RoundStats) *MatchPlayerQuery {
|
||||
query := (&MatchPlayerClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := rs.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(roundstats.Table, roundstats.FieldID, id),
|
||||
sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, roundstats.MatchPlayerTable, roundstats.MatchPlayerColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(rs.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
@@ -1059,6 +1143,21 @@ func (c *SprayClient) CreateBulk(builders ...*SprayCreate) *SprayCreateBulk {
|
||||
return &SprayCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||
// a builder and applies setFunc on it.
|
||||
func (c *SprayClient) MapCreateBulk(slice any, setFunc func(*SprayCreate, int)) *SprayCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &SprayCreateBulk{err: fmt.Errorf("calling to SprayClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*SprayCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &SprayCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for Spray.
|
||||
func (c *SprayClient) Update() *SprayUpdate {
|
||||
mutation := newSprayMutation(c.config, OpUpdate)
|
||||
@@ -1066,8 +1165,8 @@ func (c *SprayClient) Update() *SprayUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *SprayClient) UpdateOne(s *Spray) *SprayUpdateOne {
|
||||
mutation := newSprayMutation(c.config, OpUpdateOne, withSpray(s))
|
||||
func (c *SprayClient) UpdateOne(_m *Spray) *SprayUpdateOne {
|
||||
mutation := newSprayMutation(c.config, OpUpdateOne, withSpray(_m))
|
||||
return &SprayUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -1084,8 +1183,8 @@ func (c *SprayClient) Delete() *SprayDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *SprayClient) DeleteOne(s *Spray) *SprayDeleteOne {
|
||||
return c.DeleteOneID(s.ID)
|
||||
func (c *SprayClient) DeleteOne(_m *Spray) *SprayDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -1120,16 +1219,16 @@ func (c *SprayClient) GetX(ctx context.Context, id int) *Spray {
|
||||
}
|
||||
|
||||
// QueryMatchPlayers queries the match_players edge of a Spray.
|
||||
func (c *SprayClient) QueryMatchPlayers(s *Spray) *MatchPlayerQuery {
|
||||
func (c *SprayClient) QueryMatchPlayers(_m *Spray) *MatchPlayerQuery {
|
||||
query := (&MatchPlayerClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := s.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(spray.Table, spray.FieldID, id),
|
||||
sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, spray.MatchPlayersTable, spray.MatchPlayersColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(s.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
@@ -1193,6 +1292,21 @@ func (c *WeaponClient) CreateBulk(builders ...*WeaponCreate) *WeaponCreateBulk {
|
||||
return &WeaponCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
|
||||
// a builder and applies setFunc on it.
|
||||
func (c *WeaponClient) MapCreateBulk(slice any, setFunc func(*WeaponCreate, int)) *WeaponCreateBulk {
|
||||
rv := reflect.ValueOf(slice)
|
||||
if rv.Kind() != reflect.Slice {
|
||||
return &WeaponCreateBulk{err: fmt.Errorf("calling to WeaponClient.MapCreateBulk with wrong type %T, need slice", slice)}
|
||||
}
|
||||
builders := make([]*WeaponCreate, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
builders[i] = c.Create()
|
||||
setFunc(builders[i], i)
|
||||
}
|
||||
return &WeaponCreateBulk{config: c.config, builders: builders}
|
||||
}
|
||||
|
||||
// Update returns an update builder for Weapon.
|
||||
func (c *WeaponClient) Update() *WeaponUpdate {
|
||||
mutation := newWeaponMutation(c.config, OpUpdate)
|
||||
@@ -1200,8 +1314,8 @@ func (c *WeaponClient) Update() *WeaponUpdate {
|
||||
}
|
||||
|
||||
// UpdateOne returns an update builder for the given entity.
|
||||
func (c *WeaponClient) UpdateOne(w *Weapon) *WeaponUpdateOne {
|
||||
mutation := newWeaponMutation(c.config, OpUpdateOne, withWeapon(w))
|
||||
func (c *WeaponClient) UpdateOne(_m *Weapon) *WeaponUpdateOne {
|
||||
mutation := newWeaponMutation(c.config, OpUpdateOne, withWeapon(_m))
|
||||
return &WeaponUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
|
||||
}
|
||||
|
||||
@@ -1218,8 +1332,8 @@ func (c *WeaponClient) Delete() *WeaponDelete {
|
||||
}
|
||||
|
||||
// DeleteOne returns a builder for deleting the given entity.
|
||||
func (c *WeaponClient) DeleteOne(w *Weapon) *WeaponDeleteOne {
|
||||
return c.DeleteOneID(w.ID)
|
||||
func (c *WeaponClient) DeleteOne(_m *Weapon) *WeaponDeleteOne {
|
||||
return c.DeleteOneID(_m.ID)
|
||||
}
|
||||
|
||||
// DeleteOneID returns a builder for deleting the given entity by its id.
|
||||
@@ -1254,16 +1368,16 @@ func (c *WeaponClient) GetX(ctx context.Context, id int) *Weapon {
|
||||
}
|
||||
|
||||
// QueryStat queries the stat edge of a Weapon.
|
||||
func (c *WeaponClient) QueryStat(w *Weapon) *MatchPlayerQuery {
|
||||
func (c *WeaponClient) QueryStat(_m *Weapon) *MatchPlayerQuery {
|
||||
query := (&MatchPlayerClient{config: c.config}).Query()
|
||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||
id := w.ID
|
||||
id := _m.ID
|
||||
step := sqlgraph.NewStep(
|
||||
sqlgraph.From(weapon.Table, weapon.FieldID, id),
|
||||
sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, weapon.StatTable, weapon.StatColumn),
|
||||
)
|
||||
fromV = sqlgraph.Neighbors(w.driver.Dialect(), step)
|
||||
fromV = sqlgraph.Neighbors(_m.driver.Dialect(), step)
|
||||
return fromV, nil
|
||||
}
|
||||
return query
|
||||
|
||||
@@ -75,8 +75,8 @@ var (
|
||||
columnCheck sql.ColumnCheck
|
||||
)
|
||||
|
||||
// columnChecker checks if the column exists in the given table.
|
||||
func checkColumn(table, column string) error {
|
||||
// checkColumn checks if the column exists in the given table.
|
||||
func checkColumn(t, c string) error {
|
||||
initCheck.Do(func() {
|
||||
columnCheck = sql.NewColumnCheck(map[string]func(string) bool{
|
||||
match.Table: match.ValidColumn,
|
||||
@@ -88,7 +88,7 @@ func checkColumn(table, column string) error {
|
||||
weapon.Table: weapon.ValidColumn,
|
||||
})
|
||||
})
|
||||
return columnCheck(table, column)
|
||||
return columnCheck(t, c)
|
||||
}
|
||||
|
||||
// Asc applies the given fields in ASC order.
|
||||
|
||||
90
ent/match.go
90
ent/match.go
@@ -106,7 +106,7 @@ func (*Match) scanValues(columns []string) ([]any, error) {
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Match fields.
|
||||
func (m *Match) assignValues(columns []string, values []any) error {
|
||||
func (_m *Match) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
@@ -117,93 +117,93 @@ func (m *Match) assignValues(columns []string, values []any) error {
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
m.ID = uint64(value.Int64)
|
||||
_m.ID = uint64(value.Int64)
|
||||
case match.FieldShareCode:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field share_code", values[i])
|
||||
} else if value.Valid {
|
||||
m.ShareCode = value.String
|
||||
_m.ShareCode = value.String
|
||||
}
|
||||
case match.FieldMap:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field map", values[i])
|
||||
} else if value.Valid {
|
||||
m.Map = value.String
|
||||
_m.Map = value.String
|
||||
}
|
||||
case match.FieldDate:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field date", values[i])
|
||||
} else if value.Valid {
|
||||
m.Date = value.Time
|
||||
_m.Date = value.Time
|
||||
}
|
||||
case match.FieldScoreTeamA:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field score_team_a", values[i])
|
||||
} else if value.Valid {
|
||||
m.ScoreTeamA = int(value.Int64)
|
||||
_m.ScoreTeamA = int(value.Int64)
|
||||
}
|
||||
case match.FieldScoreTeamB:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field score_team_b", values[i])
|
||||
} else if value.Valid {
|
||||
m.ScoreTeamB = int(value.Int64)
|
||||
_m.ScoreTeamB = int(value.Int64)
|
||||
}
|
||||
case match.FieldReplayURL:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field replay_url", values[i])
|
||||
} else if value.Valid {
|
||||
m.ReplayURL = value.String
|
||||
_m.ReplayURL = value.String
|
||||
}
|
||||
case match.FieldDuration:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field duration", values[i])
|
||||
} else if value.Valid {
|
||||
m.Duration = int(value.Int64)
|
||||
_m.Duration = int(value.Int64)
|
||||
}
|
||||
case match.FieldMatchResult:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field match_result", values[i])
|
||||
} else if value.Valid {
|
||||
m.MatchResult = int(value.Int64)
|
||||
_m.MatchResult = int(value.Int64)
|
||||
}
|
||||
case match.FieldMaxRounds:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field max_rounds", values[i])
|
||||
} else if value.Valid {
|
||||
m.MaxRounds = int(value.Int64)
|
||||
_m.MaxRounds = int(value.Int64)
|
||||
}
|
||||
case match.FieldDemoParsed:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field demo_parsed", values[i])
|
||||
} else if value.Valid {
|
||||
m.DemoParsed = value.Bool
|
||||
_m.DemoParsed = value.Bool
|
||||
}
|
||||
case match.FieldVacPresent:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field vac_present", values[i])
|
||||
} else if value.Valid {
|
||||
m.VacPresent = value.Bool
|
||||
_m.VacPresent = value.Bool
|
||||
}
|
||||
case match.FieldGamebanPresent:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field gameban_present", values[i])
|
||||
} else if value.Valid {
|
||||
m.GamebanPresent = value.Bool
|
||||
_m.GamebanPresent = value.Bool
|
||||
}
|
||||
case match.FieldDecryptionKey:
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field decryption_key", values[i])
|
||||
} else if value != nil {
|
||||
m.DecryptionKey = *value
|
||||
_m.DecryptionKey = *value
|
||||
}
|
||||
case match.FieldTickRate:
|
||||
if value, ok := values[i].(*sql.NullFloat64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field tick_rate", values[i])
|
||||
} else if value.Valid {
|
||||
m.TickRate = value.Float64
|
||||
_m.TickRate = value.Float64
|
||||
}
|
||||
default:
|
||||
m.selectValues.Set(columns[i], values[i])
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -211,84 +211,84 @@ func (m *Match) assignValues(columns []string, values []any) error {
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Match.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (m *Match) Value(name string) (ent.Value, error) {
|
||||
return m.selectValues.Get(name)
|
||||
func (_m *Match) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryStats queries the "stats" edge of the Match entity.
|
||||
func (m *Match) QueryStats() *MatchPlayerQuery {
|
||||
return NewMatchClient(m.config).QueryStats(m)
|
||||
func (_m *Match) QueryStats() *MatchPlayerQuery {
|
||||
return NewMatchClient(_m.config).QueryStats(_m)
|
||||
}
|
||||
|
||||
// QueryPlayers queries the "players" edge of the Match entity.
|
||||
func (m *Match) QueryPlayers() *PlayerQuery {
|
||||
return NewMatchClient(m.config).QueryPlayers(m)
|
||||
func (_m *Match) QueryPlayers() *PlayerQuery {
|
||||
return NewMatchClient(_m.config).QueryPlayers(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Match.
|
||||
// Note that you need to call Match.Unwrap() before calling this method if this Match
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (m *Match) Update() *MatchUpdateOne {
|
||||
return NewMatchClient(m.config).UpdateOne(m)
|
||||
func (_m *Match) Update() *MatchUpdateOne {
|
||||
return NewMatchClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Match entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (m *Match) Unwrap() *Match {
|
||||
_tx, ok := m.config.driver.(*txDriver)
|
||||
func (_m *Match) Unwrap() *Match {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Match is not a transactional entity")
|
||||
}
|
||||
m.config.driver = _tx.drv
|
||||
return m
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (m *Match) String() string {
|
||||
func (_m *Match) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Match(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", m.ID))
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("share_code=")
|
||||
builder.WriteString(m.ShareCode)
|
||||
builder.WriteString(_m.ShareCode)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("map=")
|
||||
builder.WriteString(m.Map)
|
||||
builder.WriteString(_m.Map)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("date=")
|
||||
builder.WriteString(m.Date.Format(time.ANSIC))
|
||||
builder.WriteString(_m.Date.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("score_team_a=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.ScoreTeamA))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.ScoreTeamA))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("score_team_b=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.ScoreTeamB))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.ScoreTeamB))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("replay_url=")
|
||||
builder.WriteString(m.ReplayURL)
|
||||
builder.WriteString(_m.ReplayURL)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("duration=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.Duration))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Duration))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("match_result=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.MatchResult))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.MatchResult))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("max_rounds=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.MaxRounds))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.MaxRounds))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("demo_parsed=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.DemoParsed))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.DemoParsed))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("vac_present=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.VacPresent))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.VacPresent))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("gameban_present=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.GamebanPresent))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.GamebanPresent))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("decryption_key=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.DecryptionKey))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.DecryptionKey))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("tick_rate=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.TickRate))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.TickRate))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -758,32 +758,15 @@ func HasPlayersWith(preds ...predicate.Player) predicate.Match {
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Match) predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for _, p := range predicates {
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
return predicate.Match(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.Match) predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for i, p := range predicates {
|
||||
if i > 0 {
|
||||
s1.Or()
|
||||
}
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
return predicate.Match(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.Match) predicate.Match {
|
||||
return predicate.Match(func(s *sql.Selector) {
|
||||
p(s.Not())
|
||||
})
|
||||
return predicate.Match(sql.NotPredicates(p))
|
||||
}
|
||||
|
||||
@@ -23,187 +23,187 @@ type MatchCreate struct {
|
||||
}
|
||||
|
||||
// SetShareCode sets the "share_code" field.
|
||||
func (mc *MatchCreate) SetShareCode(s string) *MatchCreate {
|
||||
mc.mutation.SetShareCode(s)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetShareCode(v string) *MatchCreate {
|
||||
_c.mutation.SetShareCode(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetMap sets the "map" field.
|
||||
func (mc *MatchCreate) SetMap(s string) *MatchCreate {
|
||||
mc.mutation.SetMap(s)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetMap(v string) *MatchCreate {
|
||||
_c.mutation.SetMap(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableMap sets the "map" field if the given value is not nil.
|
||||
func (mc *MatchCreate) SetNillableMap(s *string) *MatchCreate {
|
||||
if s != nil {
|
||||
mc.SetMap(*s)
|
||||
func (_c *MatchCreate) SetNillableMap(v *string) *MatchCreate {
|
||||
if v != nil {
|
||||
_c.SetMap(*v)
|
||||
}
|
||||
return mc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDate sets the "date" field.
|
||||
func (mc *MatchCreate) SetDate(t time.Time) *MatchCreate {
|
||||
mc.mutation.SetDate(t)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetDate(v time.Time) *MatchCreate {
|
||||
_c.mutation.SetDate(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetScoreTeamA sets the "score_team_a" field.
|
||||
func (mc *MatchCreate) SetScoreTeamA(i int) *MatchCreate {
|
||||
mc.mutation.SetScoreTeamA(i)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetScoreTeamA(v int) *MatchCreate {
|
||||
_c.mutation.SetScoreTeamA(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetScoreTeamB sets the "score_team_b" field.
|
||||
func (mc *MatchCreate) SetScoreTeamB(i int) *MatchCreate {
|
||||
mc.mutation.SetScoreTeamB(i)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetScoreTeamB(v int) *MatchCreate {
|
||||
_c.mutation.SetScoreTeamB(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetReplayURL sets the "replay_url" field.
|
||||
func (mc *MatchCreate) SetReplayURL(s string) *MatchCreate {
|
||||
mc.mutation.SetReplayURL(s)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetReplayURL(v string) *MatchCreate {
|
||||
_c.mutation.SetReplayURL(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableReplayURL sets the "replay_url" field if the given value is not nil.
|
||||
func (mc *MatchCreate) SetNillableReplayURL(s *string) *MatchCreate {
|
||||
if s != nil {
|
||||
mc.SetReplayURL(*s)
|
||||
func (_c *MatchCreate) SetNillableReplayURL(v *string) *MatchCreate {
|
||||
if v != nil {
|
||||
_c.SetReplayURL(*v)
|
||||
}
|
||||
return mc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDuration sets the "duration" field.
|
||||
func (mc *MatchCreate) SetDuration(i int) *MatchCreate {
|
||||
mc.mutation.SetDuration(i)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetDuration(v int) *MatchCreate {
|
||||
_c.mutation.SetDuration(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetMatchResult sets the "match_result" field.
|
||||
func (mc *MatchCreate) SetMatchResult(i int) *MatchCreate {
|
||||
mc.mutation.SetMatchResult(i)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetMatchResult(v int) *MatchCreate {
|
||||
_c.mutation.SetMatchResult(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetMaxRounds sets the "max_rounds" field.
|
||||
func (mc *MatchCreate) SetMaxRounds(i int) *MatchCreate {
|
||||
mc.mutation.SetMaxRounds(i)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetMaxRounds(v int) *MatchCreate {
|
||||
_c.mutation.SetMaxRounds(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDemoParsed sets the "demo_parsed" field.
|
||||
func (mc *MatchCreate) SetDemoParsed(b bool) *MatchCreate {
|
||||
mc.mutation.SetDemoParsed(b)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetDemoParsed(v bool) *MatchCreate {
|
||||
_c.mutation.SetDemoParsed(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableDemoParsed sets the "demo_parsed" field if the given value is not nil.
|
||||
func (mc *MatchCreate) SetNillableDemoParsed(b *bool) *MatchCreate {
|
||||
if b != nil {
|
||||
mc.SetDemoParsed(*b)
|
||||
func (_c *MatchCreate) SetNillableDemoParsed(v *bool) *MatchCreate {
|
||||
if v != nil {
|
||||
_c.SetDemoParsed(*v)
|
||||
}
|
||||
return mc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetVacPresent sets the "vac_present" field.
|
||||
func (mc *MatchCreate) SetVacPresent(b bool) *MatchCreate {
|
||||
mc.mutation.SetVacPresent(b)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetVacPresent(v bool) *MatchCreate {
|
||||
_c.mutation.SetVacPresent(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableVacPresent sets the "vac_present" field if the given value is not nil.
|
||||
func (mc *MatchCreate) SetNillableVacPresent(b *bool) *MatchCreate {
|
||||
if b != nil {
|
||||
mc.SetVacPresent(*b)
|
||||
func (_c *MatchCreate) SetNillableVacPresent(v *bool) *MatchCreate {
|
||||
if v != nil {
|
||||
_c.SetVacPresent(*v)
|
||||
}
|
||||
return mc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetGamebanPresent sets the "gameban_present" field.
|
||||
func (mc *MatchCreate) SetGamebanPresent(b bool) *MatchCreate {
|
||||
mc.mutation.SetGamebanPresent(b)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetGamebanPresent(v bool) *MatchCreate {
|
||||
_c.mutation.SetGamebanPresent(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableGamebanPresent sets the "gameban_present" field if the given value is not nil.
|
||||
func (mc *MatchCreate) SetNillableGamebanPresent(b *bool) *MatchCreate {
|
||||
if b != nil {
|
||||
mc.SetGamebanPresent(*b)
|
||||
func (_c *MatchCreate) SetNillableGamebanPresent(v *bool) *MatchCreate {
|
||||
if v != nil {
|
||||
_c.SetGamebanPresent(*v)
|
||||
}
|
||||
return mc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDecryptionKey sets the "decryption_key" field.
|
||||
func (mc *MatchCreate) SetDecryptionKey(b []byte) *MatchCreate {
|
||||
mc.mutation.SetDecryptionKey(b)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetDecryptionKey(v []byte) *MatchCreate {
|
||||
_c.mutation.SetDecryptionKey(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetTickRate sets the "tick_rate" field.
|
||||
func (mc *MatchCreate) SetTickRate(f float64) *MatchCreate {
|
||||
mc.mutation.SetTickRate(f)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetTickRate(v float64) *MatchCreate {
|
||||
_c.mutation.SetTickRate(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableTickRate sets the "tick_rate" field if the given value is not nil.
|
||||
func (mc *MatchCreate) SetNillableTickRate(f *float64) *MatchCreate {
|
||||
if f != nil {
|
||||
mc.SetTickRate(*f)
|
||||
func (_c *MatchCreate) SetNillableTickRate(v *float64) *MatchCreate {
|
||||
if v != nil {
|
||||
_c.SetTickRate(*v)
|
||||
}
|
||||
return mc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (mc *MatchCreate) SetID(u uint64) *MatchCreate {
|
||||
mc.mutation.SetID(u)
|
||||
return mc
|
||||
func (_c *MatchCreate) SetID(v uint64) *MatchCreate {
|
||||
_c.mutation.SetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs.
|
||||
func (mc *MatchCreate) AddStatIDs(ids ...int) *MatchCreate {
|
||||
mc.mutation.AddStatIDs(ids...)
|
||||
return mc
|
||||
func (_c *MatchCreate) AddStatIDs(ids ...int) *MatchCreate {
|
||||
_c.mutation.AddStatIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddStats adds the "stats" edges to the MatchPlayer entity.
|
||||
func (mc *MatchCreate) AddStats(m ...*MatchPlayer) *MatchCreate {
|
||||
ids := make([]int, len(m))
|
||||
for i := range m {
|
||||
ids[i] = m[i].ID
|
||||
func (_c *MatchCreate) AddStats(v ...*MatchPlayer) *MatchCreate {
|
||||
ids := make([]int, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return mc.AddStatIDs(ids...)
|
||||
return _c.AddStatIDs(ids...)
|
||||
}
|
||||
|
||||
// AddPlayerIDs adds the "players" edge to the Player entity by IDs.
|
||||
func (mc *MatchCreate) AddPlayerIDs(ids ...uint64) *MatchCreate {
|
||||
mc.mutation.AddPlayerIDs(ids...)
|
||||
return mc
|
||||
func (_c *MatchCreate) AddPlayerIDs(ids ...uint64) *MatchCreate {
|
||||
_c.mutation.AddPlayerIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddPlayers adds the "players" edges to the Player entity.
|
||||
func (mc *MatchCreate) AddPlayers(p ...*Player) *MatchCreate {
|
||||
ids := make([]uint64, len(p))
|
||||
for i := range p {
|
||||
ids[i] = p[i].ID
|
||||
func (_c *MatchCreate) AddPlayers(v ...*Player) *MatchCreate {
|
||||
ids := make([]uint64, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return mc.AddPlayerIDs(ids...)
|
||||
return _c.AddPlayerIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the MatchMutation object of the builder.
|
||||
func (mc *MatchCreate) Mutation() *MatchMutation {
|
||||
return mc.mutation
|
||||
func (_c *MatchCreate) Mutation() *MatchMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the Match in the database.
|
||||
func (mc *MatchCreate) Save(ctx context.Context) (*Match, error) {
|
||||
mc.defaults()
|
||||
return withHooks(ctx, mc.sqlSave, mc.mutation, mc.hooks)
|
||||
func (_c *MatchCreate) Save(ctx context.Context) (*Match, error) {
|
||||
_c.defaults()
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (mc *MatchCreate) SaveX(ctx context.Context) *Match {
|
||||
v, err := mc.Save(ctx)
|
||||
func (_c *MatchCreate) SaveX(ctx context.Context) *Match {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -211,75 +211,75 @@ func (mc *MatchCreate) SaveX(ctx context.Context) *Match {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (mc *MatchCreate) Exec(ctx context.Context) error {
|
||||
_, err := mc.Save(ctx)
|
||||
func (_c *MatchCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (mc *MatchCreate) ExecX(ctx context.Context) {
|
||||
if err := mc.Exec(ctx); err != nil {
|
||||
func (_c *MatchCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (mc *MatchCreate) defaults() {
|
||||
if _, ok := mc.mutation.DemoParsed(); !ok {
|
||||
func (_c *MatchCreate) defaults() {
|
||||
if _, ok := _c.mutation.DemoParsed(); !ok {
|
||||
v := match.DefaultDemoParsed
|
||||
mc.mutation.SetDemoParsed(v)
|
||||
_c.mutation.SetDemoParsed(v)
|
||||
}
|
||||
if _, ok := mc.mutation.VacPresent(); !ok {
|
||||
if _, ok := _c.mutation.VacPresent(); !ok {
|
||||
v := match.DefaultVacPresent
|
||||
mc.mutation.SetVacPresent(v)
|
||||
_c.mutation.SetVacPresent(v)
|
||||
}
|
||||
if _, ok := mc.mutation.GamebanPresent(); !ok {
|
||||
if _, ok := _c.mutation.GamebanPresent(); !ok {
|
||||
v := match.DefaultGamebanPresent
|
||||
mc.mutation.SetGamebanPresent(v)
|
||||
_c.mutation.SetGamebanPresent(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (mc *MatchCreate) check() error {
|
||||
if _, ok := mc.mutation.ShareCode(); !ok {
|
||||
func (_c *MatchCreate) check() error {
|
||||
if _, ok := _c.mutation.ShareCode(); !ok {
|
||||
return &ValidationError{Name: "share_code", err: errors.New(`ent: missing required field "Match.share_code"`)}
|
||||
}
|
||||
if _, ok := mc.mutation.Date(); !ok {
|
||||
if _, ok := _c.mutation.Date(); !ok {
|
||||
return &ValidationError{Name: "date", err: errors.New(`ent: missing required field "Match.date"`)}
|
||||
}
|
||||
if _, ok := mc.mutation.ScoreTeamA(); !ok {
|
||||
if _, ok := _c.mutation.ScoreTeamA(); !ok {
|
||||
return &ValidationError{Name: "score_team_a", err: errors.New(`ent: missing required field "Match.score_team_a"`)}
|
||||
}
|
||||
if _, ok := mc.mutation.ScoreTeamB(); !ok {
|
||||
if _, ok := _c.mutation.ScoreTeamB(); !ok {
|
||||
return &ValidationError{Name: "score_team_b", err: errors.New(`ent: missing required field "Match.score_team_b"`)}
|
||||
}
|
||||
if _, ok := mc.mutation.Duration(); !ok {
|
||||
if _, ok := _c.mutation.Duration(); !ok {
|
||||
return &ValidationError{Name: "duration", err: errors.New(`ent: missing required field "Match.duration"`)}
|
||||
}
|
||||
if _, ok := mc.mutation.MatchResult(); !ok {
|
||||
if _, ok := _c.mutation.MatchResult(); !ok {
|
||||
return &ValidationError{Name: "match_result", err: errors.New(`ent: missing required field "Match.match_result"`)}
|
||||
}
|
||||
if _, ok := mc.mutation.MaxRounds(); !ok {
|
||||
if _, ok := _c.mutation.MaxRounds(); !ok {
|
||||
return &ValidationError{Name: "max_rounds", err: errors.New(`ent: missing required field "Match.max_rounds"`)}
|
||||
}
|
||||
if _, ok := mc.mutation.DemoParsed(); !ok {
|
||||
if _, ok := _c.mutation.DemoParsed(); !ok {
|
||||
return &ValidationError{Name: "demo_parsed", err: errors.New(`ent: missing required field "Match.demo_parsed"`)}
|
||||
}
|
||||
if _, ok := mc.mutation.VacPresent(); !ok {
|
||||
if _, ok := _c.mutation.VacPresent(); !ok {
|
||||
return &ValidationError{Name: "vac_present", err: errors.New(`ent: missing required field "Match.vac_present"`)}
|
||||
}
|
||||
if _, ok := mc.mutation.GamebanPresent(); !ok {
|
||||
if _, ok := _c.mutation.GamebanPresent(); !ok {
|
||||
return &ValidationError{Name: "gameban_present", err: errors.New(`ent: missing required field "Match.gameban_present"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mc *MatchCreate) sqlSave(ctx context.Context) (*Match, error) {
|
||||
if err := mc.check(); err != nil {
|
||||
func (_c *MatchCreate) sqlSave(ctx context.Context) (*Match, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := mc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, mc.driver, _spec); err != nil {
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -289,77 +289,77 @@ func (mc *MatchCreate) sqlSave(ctx context.Context) (*Match, error) {
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = uint64(id)
|
||||
}
|
||||
mc.mutation.id = &_node.ID
|
||||
mc.mutation.done = true
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) {
|
||||
func (_c *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Match{config: mc.config}
|
||||
_node = &Match{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(match.Table, sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64))
|
||||
)
|
||||
if id, ok := mc.mutation.ID(); ok {
|
||||
if id, ok := _c.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = id
|
||||
}
|
||||
if value, ok := mc.mutation.ShareCode(); ok {
|
||||
if value, ok := _c.mutation.ShareCode(); ok {
|
||||
_spec.SetField(match.FieldShareCode, field.TypeString, value)
|
||||
_node.ShareCode = value
|
||||
}
|
||||
if value, ok := mc.mutation.Map(); ok {
|
||||
if value, ok := _c.mutation.Map(); ok {
|
||||
_spec.SetField(match.FieldMap, field.TypeString, value)
|
||||
_node.Map = value
|
||||
}
|
||||
if value, ok := mc.mutation.Date(); ok {
|
||||
if value, ok := _c.mutation.Date(); ok {
|
||||
_spec.SetField(match.FieldDate, field.TypeTime, value)
|
||||
_node.Date = value
|
||||
}
|
||||
if value, ok := mc.mutation.ScoreTeamA(); ok {
|
||||
if value, ok := _c.mutation.ScoreTeamA(); ok {
|
||||
_spec.SetField(match.FieldScoreTeamA, field.TypeInt, value)
|
||||
_node.ScoreTeamA = value
|
||||
}
|
||||
if value, ok := mc.mutation.ScoreTeamB(); ok {
|
||||
if value, ok := _c.mutation.ScoreTeamB(); ok {
|
||||
_spec.SetField(match.FieldScoreTeamB, field.TypeInt, value)
|
||||
_node.ScoreTeamB = value
|
||||
}
|
||||
if value, ok := mc.mutation.ReplayURL(); ok {
|
||||
if value, ok := _c.mutation.ReplayURL(); ok {
|
||||
_spec.SetField(match.FieldReplayURL, field.TypeString, value)
|
||||
_node.ReplayURL = value
|
||||
}
|
||||
if value, ok := mc.mutation.Duration(); ok {
|
||||
if value, ok := _c.mutation.Duration(); ok {
|
||||
_spec.SetField(match.FieldDuration, field.TypeInt, value)
|
||||
_node.Duration = value
|
||||
}
|
||||
if value, ok := mc.mutation.MatchResult(); ok {
|
||||
if value, ok := _c.mutation.MatchResult(); ok {
|
||||
_spec.SetField(match.FieldMatchResult, field.TypeInt, value)
|
||||
_node.MatchResult = value
|
||||
}
|
||||
if value, ok := mc.mutation.MaxRounds(); ok {
|
||||
if value, ok := _c.mutation.MaxRounds(); ok {
|
||||
_spec.SetField(match.FieldMaxRounds, field.TypeInt, value)
|
||||
_node.MaxRounds = value
|
||||
}
|
||||
if value, ok := mc.mutation.DemoParsed(); ok {
|
||||
if value, ok := _c.mutation.DemoParsed(); ok {
|
||||
_spec.SetField(match.FieldDemoParsed, field.TypeBool, value)
|
||||
_node.DemoParsed = value
|
||||
}
|
||||
if value, ok := mc.mutation.VacPresent(); ok {
|
||||
if value, ok := _c.mutation.VacPresent(); ok {
|
||||
_spec.SetField(match.FieldVacPresent, field.TypeBool, value)
|
||||
_node.VacPresent = value
|
||||
}
|
||||
if value, ok := mc.mutation.GamebanPresent(); ok {
|
||||
if value, ok := _c.mutation.GamebanPresent(); ok {
|
||||
_spec.SetField(match.FieldGamebanPresent, field.TypeBool, value)
|
||||
_node.GamebanPresent = value
|
||||
}
|
||||
if value, ok := mc.mutation.DecryptionKey(); ok {
|
||||
if value, ok := _c.mutation.DecryptionKey(); ok {
|
||||
_spec.SetField(match.FieldDecryptionKey, field.TypeBytes, value)
|
||||
_node.DecryptionKey = value
|
||||
}
|
||||
if value, ok := mc.mutation.TickRate(); ok {
|
||||
if value, ok := _c.mutation.TickRate(); ok {
|
||||
_spec.SetField(match.FieldTickRate, field.TypeFloat64, value)
|
||||
_node.TickRate = value
|
||||
}
|
||||
if nodes := mc.mutation.StatsIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.StatsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
@@ -375,7 +375,7 @@ func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) {
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := mc.mutation.PlayersIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.PlayersIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: true,
|
||||
@@ -397,17 +397,21 @@ func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) {
|
||||
// MatchCreateBulk is the builder for creating many Match entities in bulk.
|
||||
type MatchCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*MatchCreate
|
||||
}
|
||||
|
||||
// Save creates the Match entities in the database.
|
||||
func (mcb *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(mcb.builders))
|
||||
nodes := make([]*Match, len(mcb.builders))
|
||||
mutators := make([]Mutator, len(mcb.builders))
|
||||
for i := range mcb.builders {
|
||||
func (_c *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*Match, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := mcb.builders[i]
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*MatchMutation)
|
||||
@@ -421,11 +425,11 @@ func (mcb *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) {
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, mcb.builders[i+1].mutation)
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, mcb.driver, spec); err != nil {
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -449,7 +453,7 @@ func (mcb *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) {
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, mcb.builders[0].mutation); err != nil {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -457,8 +461,8 @@ func (mcb *MatchCreateBulk) Save(ctx context.Context) ([]*Match, error) {
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (mcb *MatchCreateBulk) SaveX(ctx context.Context) []*Match {
|
||||
v, err := mcb.Save(ctx)
|
||||
func (_c *MatchCreateBulk) SaveX(ctx context.Context) []*Match {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -466,14 +470,14 @@ func (mcb *MatchCreateBulk) SaveX(ctx context.Context) []*Match {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (mcb *MatchCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := mcb.Save(ctx)
|
||||
func (_c *MatchCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (mcb *MatchCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := mcb.Exec(ctx); err != nil {
|
||||
func (_c *MatchCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,56 +20,56 @@ type MatchDelete struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the MatchDelete builder.
|
||||
func (md *MatchDelete) Where(ps ...predicate.Match) *MatchDelete {
|
||||
md.mutation.Where(ps...)
|
||||
return md
|
||||
func (_d *MatchDelete) Where(ps ...predicate.Match) *MatchDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (md *MatchDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, md.sqlExec, md.mutation, md.hooks)
|
||||
func (_d *MatchDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (md *MatchDelete) ExecX(ctx context.Context) int {
|
||||
n, err := md.Exec(ctx)
|
||||
func (_d *MatchDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (md *MatchDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
func (_d *MatchDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(match.Table, sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64))
|
||||
if ps := md.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, md.driver, _spec)
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
md.mutation.done = true
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// MatchDeleteOne is the builder for deleting a single Match entity.
|
||||
type MatchDeleteOne struct {
|
||||
md *MatchDelete
|
||||
_d *MatchDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the MatchDelete builder.
|
||||
func (mdo *MatchDeleteOne) Where(ps ...predicate.Match) *MatchDeleteOne {
|
||||
mdo.md.mutation.Where(ps...)
|
||||
return mdo
|
||||
func (_d *MatchDeleteOne) Where(ps ...predicate.Match) *MatchDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (mdo *MatchDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := mdo.md.Exec(ctx)
|
||||
func (_d *MatchDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
@@ -81,8 +81,8 @@ func (mdo *MatchDeleteOne) Exec(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (mdo *MatchDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := mdo.Exec(ctx); err != nil {
|
||||
func (_d *MatchDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
@@ -33,44 +34,44 @@ type MatchQuery struct {
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the MatchQuery builder.
|
||||
func (mq *MatchQuery) Where(ps ...predicate.Match) *MatchQuery {
|
||||
mq.predicates = append(mq.predicates, ps...)
|
||||
return mq
|
||||
func (_q *MatchQuery) Where(ps ...predicate.Match) *MatchQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (mq *MatchQuery) Limit(limit int) *MatchQuery {
|
||||
mq.ctx.Limit = &limit
|
||||
return mq
|
||||
func (_q *MatchQuery) Limit(limit int) *MatchQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (mq *MatchQuery) Offset(offset int) *MatchQuery {
|
||||
mq.ctx.Offset = &offset
|
||||
return mq
|
||||
func (_q *MatchQuery) Offset(offset int) *MatchQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (mq *MatchQuery) Unique(unique bool) *MatchQuery {
|
||||
mq.ctx.Unique = &unique
|
||||
return mq
|
||||
func (_q *MatchQuery) Unique(unique bool) *MatchQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (mq *MatchQuery) Order(o ...match.OrderOption) *MatchQuery {
|
||||
mq.order = append(mq.order, o...)
|
||||
return mq
|
||||
func (_q *MatchQuery) Order(o ...match.OrderOption) *MatchQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryStats chains the current query on the "stats" edge.
|
||||
func (mq *MatchQuery) QueryStats() *MatchPlayerQuery {
|
||||
query := (&MatchPlayerClient{config: mq.config}).Query()
|
||||
func (_q *MatchQuery) QueryStats() *MatchPlayerQuery {
|
||||
query := (&MatchPlayerClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := mq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := mq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -79,20 +80,20 @@ func (mq *MatchQuery) QueryStats() *MatchPlayerQuery {
|
||||
sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, match.StatsTable, match.StatsColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryPlayers chains the current query on the "players" edge.
|
||||
func (mq *MatchQuery) QueryPlayers() *PlayerQuery {
|
||||
query := (&PlayerClient{config: mq.config}).Query()
|
||||
func (_q *MatchQuery) QueryPlayers() *PlayerQuery {
|
||||
query := (&PlayerClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := mq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := mq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -101,7 +102,7 @@ func (mq *MatchQuery) QueryPlayers() *PlayerQuery {
|
||||
sqlgraph.To(player.Table, player.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, true, match.PlayersTable, match.PlayersPrimaryKey...),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
@@ -109,8 +110,8 @@ func (mq *MatchQuery) QueryPlayers() *PlayerQuery {
|
||||
|
||||
// First returns the first Match entity from the query.
|
||||
// Returns a *NotFoundError when no Match was found.
|
||||
func (mq *MatchQuery) First(ctx context.Context) (*Match, error) {
|
||||
nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, "First"))
|
||||
func (_q *MatchQuery) First(ctx context.Context) (*Match, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -121,8 +122,8 @@ func (mq *MatchQuery) First(ctx context.Context) (*Match, error) {
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (mq *MatchQuery) FirstX(ctx context.Context) *Match {
|
||||
node, err := mq.First(ctx)
|
||||
func (_q *MatchQuery) FirstX(ctx context.Context) *Match {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -131,9 +132,9 @@ func (mq *MatchQuery) FirstX(ctx context.Context) *Match {
|
||||
|
||||
// FirstID returns the first Match ID from the query.
|
||||
// Returns a *NotFoundError when no Match ID was found.
|
||||
func (mq *MatchQuery) FirstID(ctx context.Context) (id uint64, err error) {
|
||||
func (_q *MatchQuery) FirstID(ctx context.Context) (id uint64, err error) {
|
||||
var ids []uint64
|
||||
if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, "FirstID")); err != nil {
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
@@ -144,8 +145,8 @@ func (mq *MatchQuery) FirstID(ctx context.Context) (id uint64, err error) {
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (mq *MatchQuery) FirstIDX(ctx context.Context) uint64 {
|
||||
id, err := mq.FirstID(ctx)
|
||||
func (_q *MatchQuery) FirstIDX(ctx context.Context) uint64 {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -155,8 +156,8 @@ func (mq *MatchQuery) FirstIDX(ctx context.Context) uint64 {
|
||||
// Only returns a single Match entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one Match entity is found.
|
||||
// Returns a *NotFoundError when no Match entities are found.
|
||||
func (mq *MatchQuery) Only(ctx context.Context) (*Match, error) {
|
||||
nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, "Only"))
|
||||
func (_q *MatchQuery) Only(ctx context.Context) (*Match, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -171,8 +172,8 @@ func (mq *MatchQuery) Only(ctx context.Context) (*Match, error) {
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (mq *MatchQuery) OnlyX(ctx context.Context) *Match {
|
||||
node, err := mq.Only(ctx)
|
||||
func (_q *MatchQuery) OnlyX(ctx context.Context) *Match {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -182,9 +183,9 @@ func (mq *MatchQuery) OnlyX(ctx context.Context) *Match {
|
||||
// OnlyID is like Only, but returns the only Match ID in the query.
|
||||
// Returns a *NotSingularError when more than one Match ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (mq *MatchQuery) OnlyID(ctx context.Context) (id uint64, err error) {
|
||||
func (_q *MatchQuery) OnlyID(ctx context.Context) (id uint64, err error) {
|
||||
var ids []uint64
|
||||
if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, "OnlyID")); err != nil {
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
@@ -199,8 +200,8 @@ func (mq *MatchQuery) OnlyID(ctx context.Context) (id uint64, err error) {
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (mq *MatchQuery) OnlyIDX(ctx context.Context) uint64 {
|
||||
id, err := mq.OnlyID(ctx)
|
||||
func (_q *MatchQuery) OnlyIDX(ctx context.Context) uint64 {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -208,18 +209,18 @@ func (mq *MatchQuery) OnlyIDX(ctx context.Context) uint64 {
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of Matches.
|
||||
func (mq *MatchQuery) All(ctx context.Context) ([]*Match, error) {
|
||||
ctx = setContextOp(ctx, mq.ctx, "All")
|
||||
if err := mq.prepareQuery(ctx); err != nil {
|
||||
func (_q *MatchQuery) All(ctx context.Context) ([]*Match, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*Match, *MatchQuery]()
|
||||
return withInterceptors[[]*Match](ctx, mq, qr, mq.inters)
|
||||
return withInterceptors[[]*Match](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (mq *MatchQuery) AllX(ctx context.Context) []*Match {
|
||||
nodes, err := mq.All(ctx)
|
||||
func (_q *MatchQuery) AllX(ctx context.Context) []*Match {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -227,20 +228,20 @@ func (mq *MatchQuery) AllX(ctx context.Context) []*Match {
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Match IDs.
|
||||
func (mq *MatchQuery) IDs(ctx context.Context) (ids []uint64, err error) {
|
||||
if mq.ctx.Unique == nil && mq.path != nil {
|
||||
mq.Unique(true)
|
||||
func (_q *MatchQuery) IDs(ctx context.Context) (ids []uint64, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, mq.ctx, "IDs")
|
||||
if err = mq.Select(match.FieldID).Scan(ctx, &ids); err != nil {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(match.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (mq *MatchQuery) IDsX(ctx context.Context) []uint64 {
|
||||
ids, err := mq.IDs(ctx)
|
||||
func (_q *MatchQuery) IDsX(ctx context.Context) []uint64 {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -248,17 +249,17 @@ func (mq *MatchQuery) IDsX(ctx context.Context) []uint64 {
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (mq *MatchQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, mq.ctx, "Count")
|
||||
if err := mq.prepareQuery(ctx); err != nil {
|
||||
func (_q *MatchQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, mq, querierCount[*MatchQuery](), mq.inters)
|
||||
return withInterceptors[int](ctx, _q, querierCount[*MatchQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (mq *MatchQuery) CountX(ctx context.Context) int {
|
||||
count, err := mq.Count(ctx)
|
||||
func (_q *MatchQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -266,9 +267,9 @@ func (mq *MatchQuery) CountX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (mq *MatchQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, mq.ctx, "Exist")
|
||||
switch _, err := mq.FirstID(ctx); {
|
||||
func (_q *MatchQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
@@ -279,8 +280,8 @@ func (mq *MatchQuery) Exist(ctx context.Context) (bool, error) {
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (mq *MatchQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := mq.Exist(ctx)
|
||||
func (_q *MatchQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -289,44 +290,45 @@ func (mq *MatchQuery) ExistX(ctx context.Context) bool {
|
||||
|
||||
// Clone returns a duplicate of the MatchQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (mq *MatchQuery) Clone() *MatchQuery {
|
||||
if mq == nil {
|
||||
func (_q *MatchQuery) Clone() *MatchQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &MatchQuery{
|
||||
config: mq.config,
|
||||
ctx: mq.ctx.Clone(),
|
||||
order: append([]match.OrderOption{}, mq.order...),
|
||||
inters: append([]Interceptor{}, mq.inters...),
|
||||
predicates: append([]predicate.Match{}, mq.predicates...),
|
||||
withStats: mq.withStats.Clone(),
|
||||
withPlayers: mq.withPlayers.Clone(),
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]match.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.Match{}, _q.predicates...),
|
||||
withStats: _q.withStats.Clone(),
|
||||
withPlayers: _q.withPlayers.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: mq.sql.Clone(),
|
||||
path: mq.path,
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
modifiers: append([]func(*sql.Selector){}, _q.modifiers...),
|
||||
}
|
||||
}
|
||||
|
||||
// WithStats tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "stats" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (mq *MatchQuery) WithStats(opts ...func(*MatchPlayerQuery)) *MatchQuery {
|
||||
query := (&MatchPlayerClient{config: mq.config}).Query()
|
||||
func (_q *MatchQuery) WithStats(opts ...func(*MatchPlayerQuery)) *MatchQuery {
|
||||
query := (&MatchPlayerClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
mq.withStats = query
|
||||
return mq
|
||||
_q.withStats = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithPlayers tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "players" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (mq *MatchQuery) WithPlayers(opts ...func(*PlayerQuery)) *MatchQuery {
|
||||
query := (&PlayerClient{config: mq.config}).Query()
|
||||
func (_q *MatchQuery) WithPlayers(opts ...func(*PlayerQuery)) *MatchQuery {
|
||||
query := (&PlayerClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
mq.withPlayers = query
|
||||
return mq
|
||||
_q.withPlayers = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
@@ -343,10 +345,10 @@ func (mq *MatchQuery) WithPlayers(opts ...func(*PlayerQuery)) *MatchQuery {
|
||||
// GroupBy(match.FieldShareCode).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (mq *MatchQuery) GroupBy(field string, fields ...string) *MatchGroupBy {
|
||||
mq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &MatchGroupBy{build: mq}
|
||||
grbuild.flds = &mq.ctx.Fields
|
||||
func (_q *MatchQuery) GroupBy(field string, fields ...string) *MatchGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &MatchGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = match.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
@@ -364,84 +366,84 @@ func (mq *MatchQuery) GroupBy(field string, fields ...string) *MatchGroupBy {
|
||||
// client.Match.Query().
|
||||
// Select(match.FieldShareCode).
|
||||
// Scan(ctx, &v)
|
||||
func (mq *MatchQuery) Select(fields ...string) *MatchSelect {
|
||||
mq.ctx.Fields = append(mq.ctx.Fields, fields...)
|
||||
sbuild := &MatchSelect{MatchQuery: mq}
|
||||
func (_q *MatchQuery) Select(fields ...string) *MatchSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &MatchSelect{MatchQuery: _q}
|
||||
sbuild.label = match.Label
|
||||
sbuild.flds, sbuild.scan = &mq.ctx.Fields, sbuild.Scan
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a MatchSelect configured with the given aggregations.
|
||||
func (mq *MatchQuery) Aggregate(fns ...AggregateFunc) *MatchSelect {
|
||||
return mq.Select().Aggregate(fns...)
|
||||
func (_q *MatchQuery) Aggregate(fns ...AggregateFunc) *MatchSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (mq *MatchQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range mq.inters {
|
||||
func (_q *MatchQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, mq); err != nil {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range mq.ctx.Fields {
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !match.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if mq.path != nil {
|
||||
prev, err := mq.path(ctx)
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mq.sql = prev
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mq *MatchQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Match, error) {
|
||||
func (_q *MatchQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Match, error) {
|
||||
var (
|
||||
nodes = []*Match{}
|
||||
_spec = mq.querySpec()
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [2]bool{
|
||||
mq.withStats != nil,
|
||||
mq.withPlayers != nil,
|
||||
_q.withStats != nil,
|
||||
_q.withPlayers != nil,
|
||||
}
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*Match).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &Match{config: mq.config}
|
||||
node := &Match{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
if len(mq.modifiers) > 0 {
|
||||
_spec.Modifiers = mq.modifiers
|
||||
if len(_q.modifiers) > 0 {
|
||||
_spec.Modifiers = _q.modifiers
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, mq.driver, _spec); err != nil {
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := mq.withStats; query != nil {
|
||||
if err := mq.loadStats(ctx, query, nodes,
|
||||
if query := _q.withStats; query != nil {
|
||||
if err := _q.loadStats(ctx, query, nodes,
|
||||
func(n *Match) { n.Edges.Stats = []*MatchPlayer{} },
|
||||
func(n *Match, e *MatchPlayer) { n.Edges.Stats = append(n.Edges.Stats, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := mq.withPlayers; query != nil {
|
||||
if err := mq.loadPlayers(ctx, query, nodes,
|
||||
if query := _q.withPlayers; query != nil {
|
||||
if err := _q.loadPlayers(ctx, query, nodes,
|
||||
func(n *Match) { n.Edges.Players = []*Player{} },
|
||||
func(n *Match, e *Player) { n.Edges.Players = append(n.Edges.Players, e) }); err != nil {
|
||||
return nil, err
|
||||
@@ -450,7 +452,7 @@ func (mq *MatchQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Match,
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (mq *MatchQuery) loadStats(ctx context.Context, query *MatchPlayerQuery, nodes []*Match, init func(*Match), assign func(*Match, *MatchPlayer)) error {
|
||||
func (_q *MatchQuery) loadStats(ctx context.Context, query *MatchPlayerQuery, nodes []*Match, init func(*Match), assign func(*Match, *MatchPlayer)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[uint64]*Match)
|
||||
for i := range nodes {
|
||||
@@ -480,7 +482,7 @@ func (mq *MatchQuery) loadStats(ctx context.Context, query *MatchPlayerQuery, no
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (mq *MatchQuery) loadPlayers(ctx context.Context, query *PlayerQuery, nodes []*Match, init func(*Match), assign func(*Match, *Player)) error {
|
||||
func (_q *MatchQuery) loadPlayers(ctx context.Context, query *PlayerQuery, nodes []*Match, init func(*Match), assign func(*Match, *Player)) error {
|
||||
edgeIDs := make([]driver.Value, len(nodes))
|
||||
byID := make(map[uint64]*Match)
|
||||
nids := make(map[uint64]map[*Match]struct{})
|
||||
@@ -542,27 +544,27 @@ func (mq *MatchQuery) loadPlayers(ctx context.Context, query *PlayerQuery, nodes
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mq *MatchQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := mq.querySpec()
|
||||
if len(mq.modifiers) > 0 {
|
||||
_spec.Modifiers = mq.modifiers
|
||||
func (_q *MatchQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
if len(_q.modifiers) > 0 {
|
||||
_spec.Modifiers = _q.modifiers
|
||||
}
|
||||
_spec.Node.Columns = mq.ctx.Fields
|
||||
if len(mq.ctx.Fields) > 0 {
|
||||
_spec.Unique = mq.ctx.Unique != nil && *mq.ctx.Unique
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, mq.driver, _spec)
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (mq *MatchQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
func (_q *MatchQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(match.Table, match.Columns, sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64))
|
||||
_spec.From = mq.sql
|
||||
if unique := mq.ctx.Unique; unique != nil {
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if mq.path != nil {
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := mq.ctx.Fields; len(fields) > 0 {
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, match.FieldID)
|
||||
for i := range fields {
|
||||
@@ -571,20 +573,20 @@ func (mq *MatchQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := mq.predicates; len(ps) > 0 {
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := mq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := mq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := mq.order; len(ps) > 0 {
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
@@ -594,45 +596,45 @@ func (mq *MatchQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (mq *MatchQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(mq.driver.Dialect())
|
||||
func (_q *MatchQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(match.Table)
|
||||
columns := mq.ctx.Fields
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = match.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if mq.sql != nil {
|
||||
selector = mq.sql
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if mq.ctx.Unique != nil && *mq.ctx.Unique {
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, m := range mq.modifiers {
|
||||
for _, m := range _q.modifiers {
|
||||
m(selector)
|
||||
}
|
||||
for _, p := range mq.predicates {
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range mq.order {
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := mq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := mq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// Modify adds a query modifier for attaching custom logic to queries.
|
||||
func (mq *MatchQuery) Modify(modifiers ...func(s *sql.Selector)) *MatchSelect {
|
||||
mq.modifiers = append(mq.modifiers, modifiers...)
|
||||
return mq.Select()
|
||||
func (_q *MatchQuery) Modify(modifiers ...func(s *sql.Selector)) *MatchSelect {
|
||||
_q.modifiers = append(_q.modifiers, modifiers...)
|
||||
return _q.Select()
|
||||
}
|
||||
|
||||
// MatchGroupBy is the group-by builder for Match entities.
|
||||
@@ -642,41 +644,41 @@ type MatchGroupBy struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (mgb *MatchGroupBy) Aggregate(fns ...AggregateFunc) *MatchGroupBy {
|
||||
mgb.fns = append(mgb.fns, fns...)
|
||||
return mgb
|
||||
func (_g *MatchGroupBy) Aggregate(fns ...AggregateFunc) *MatchGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (mgb *MatchGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, mgb.build.ctx, "GroupBy")
|
||||
if err := mgb.build.prepareQuery(ctx); err != nil {
|
||||
func (_g *MatchGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*MatchQuery, *MatchGroupBy](ctx, mgb.build, mgb, mgb.build.inters, v)
|
||||
return scanWithInterceptors[*MatchQuery, *MatchGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (mgb *MatchGroupBy) sqlScan(ctx context.Context, root *MatchQuery, v any) error {
|
||||
func (_g *MatchGroupBy) sqlScan(ctx context.Context, root *MatchQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(mgb.fns))
|
||||
for _, fn := range mgb.fns {
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*mgb.flds)+len(mgb.fns))
|
||||
for _, f := range *mgb.flds {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*mgb.flds...)...)
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := mgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -690,27 +692,27 @@ type MatchSelect struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (ms *MatchSelect) Aggregate(fns ...AggregateFunc) *MatchSelect {
|
||||
ms.fns = append(ms.fns, fns...)
|
||||
return ms
|
||||
func (_s *MatchSelect) Aggregate(fns ...AggregateFunc) *MatchSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ms *MatchSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, ms.ctx, "Select")
|
||||
if err := ms.prepareQuery(ctx); err != nil {
|
||||
func (_s *MatchSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*MatchQuery, *MatchSelect](ctx, ms.MatchQuery, ms, ms.inters, v)
|
||||
return scanWithInterceptors[*MatchQuery, *MatchSelect](ctx, _s.MatchQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (ms *MatchSelect) sqlScan(ctx context.Context, root *MatchQuery, v any) error {
|
||||
func (_s *MatchSelect) sqlScan(ctx context.Context, root *MatchQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(ms.fns))
|
||||
for _, fn := range ms.fns {
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*ms.selector.flds); {
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
@@ -718,7 +720,7 @@ func (ms *MatchSelect) sqlScan(ctx context.Context, root *MatchQuery, v any) err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := ms.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -726,7 +728,7 @@ func (ms *MatchSelect) sqlScan(ctx context.Context, root *MatchQuery, v any) err
|
||||
}
|
||||
|
||||
// Modify adds a query modifier for attaching custom logic to queries.
|
||||
func (ms *MatchSelect) Modify(modifiers ...func(s *sql.Selector)) *MatchSelect {
|
||||
ms.modifiers = append(ms.modifiers, modifiers...)
|
||||
return ms
|
||||
func (_s *MatchSelect) Modify(modifiers ...func(s *sql.Selector)) *MatchSelect {
|
||||
_s.modifiers = append(_s.modifiers, modifiers...)
|
||||
return _s
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -112,12 +112,10 @@ type MatchPlayerEdges struct {
|
||||
// MatchesOrErr returns the Matches value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e MatchPlayerEdges) MatchesOrErr() (*Match, error) {
|
||||
if e.loadedTypes[0] {
|
||||
if e.Matches == nil {
|
||||
// Edge was loaded but was not found.
|
||||
return nil, &NotFoundError{label: match.Label}
|
||||
}
|
||||
if e.Matches != nil {
|
||||
return e.Matches, nil
|
||||
} else if e.loadedTypes[0] {
|
||||
return nil, &NotFoundError{label: match.Label}
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "matches"}
|
||||
}
|
||||
@@ -125,12 +123,10 @@ func (e MatchPlayerEdges) MatchesOrErr() (*Match, error) {
|
||||
// PlayersOrErr returns the Players value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e MatchPlayerEdges) PlayersOrErr() (*Player, error) {
|
||||
if e.loadedTypes[1] {
|
||||
if e.Players == nil {
|
||||
// Edge was loaded but was not found.
|
||||
return nil, &NotFoundError{label: player.Label}
|
||||
}
|
||||
if e.Players != nil {
|
||||
return e.Players, nil
|
||||
} else if e.loadedTypes[1] {
|
||||
return nil, &NotFoundError{label: player.Label}
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "players"}
|
||||
}
|
||||
@@ -191,7 +187,7 @@ func (*MatchPlayer) scanValues(columns []string) ([]any, error) {
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the MatchPlayer fields.
|
||||
func (mp *MatchPlayer) assignValues(columns []string, values []any) error {
|
||||
func (_m *MatchPlayer) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
@@ -202,207 +198,207 @@ func (mp *MatchPlayer) assignValues(columns []string, values []any) error {
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
mp.ID = int(value.Int64)
|
||||
_m.ID = int(value.Int64)
|
||||
case matchplayer.FieldTeamID:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field team_id", values[i])
|
||||
} else if value.Valid {
|
||||
mp.TeamID = int(value.Int64)
|
||||
_m.TeamID = int(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldKills:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field kills", values[i])
|
||||
} else if value.Valid {
|
||||
mp.Kills = int(value.Int64)
|
||||
_m.Kills = int(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldDeaths:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field deaths", values[i])
|
||||
} else if value.Valid {
|
||||
mp.Deaths = int(value.Int64)
|
||||
_m.Deaths = int(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldAssists:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field assists", values[i])
|
||||
} else if value.Valid {
|
||||
mp.Assists = int(value.Int64)
|
||||
_m.Assists = int(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldHeadshot:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field headshot", values[i])
|
||||
} else if value.Valid {
|
||||
mp.Headshot = int(value.Int64)
|
||||
_m.Headshot = int(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldMvp:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field mvp", values[i])
|
||||
} else if value.Valid {
|
||||
mp.Mvp = uint(value.Int64)
|
||||
_m.Mvp = uint(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldScore:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field score", values[i])
|
||||
} else if value.Valid {
|
||||
mp.Score = int(value.Int64)
|
||||
_m.Score = int(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldRankNew:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field rank_new", values[i])
|
||||
} else if value.Valid {
|
||||
mp.RankNew = int(value.Int64)
|
||||
_m.RankNew = int(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldRankOld:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field rank_old", values[i])
|
||||
} else if value.Valid {
|
||||
mp.RankOld = int(value.Int64)
|
||||
_m.RankOld = int(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldMk2:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field mk_2", values[i])
|
||||
} else if value.Valid {
|
||||
mp.Mk2 = uint(value.Int64)
|
||||
_m.Mk2 = uint(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldMk3:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field mk_3", values[i])
|
||||
} else if value.Valid {
|
||||
mp.Mk3 = uint(value.Int64)
|
||||
_m.Mk3 = uint(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldMk4:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field mk_4", values[i])
|
||||
} else if value.Valid {
|
||||
mp.Mk4 = uint(value.Int64)
|
||||
_m.Mk4 = uint(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldMk5:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field mk_5", values[i])
|
||||
} else if value.Valid {
|
||||
mp.Mk5 = uint(value.Int64)
|
||||
_m.Mk5 = uint(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldDmgEnemy:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field dmg_enemy", values[i])
|
||||
} else if value.Valid {
|
||||
mp.DmgEnemy = uint(value.Int64)
|
||||
_m.DmgEnemy = uint(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldDmgTeam:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field dmg_team", values[i])
|
||||
} else if value.Valid {
|
||||
mp.DmgTeam = uint(value.Int64)
|
||||
_m.DmgTeam = uint(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldUdHe:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field ud_he", values[i])
|
||||
} else if value.Valid {
|
||||
mp.UdHe = uint(value.Int64)
|
||||
_m.UdHe = uint(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldUdFlames:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field ud_flames", values[i])
|
||||
} else if value.Valid {
|
||||
mp.UdFlames = uint(value.Int64)
|
||||
_m.UdFlames = uint(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldUdFlash:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field ud_flash", values[i])
|
||||
} else if value.Valid {
|
||||
mp.UdFlash = uint(value.Int64)
|
||||
_m.UdFlash = uint(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldUdDecoy:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field ud_decoy", values[i])
|
||||
} else if value.Valid {
|
||||
mp.UdDecoy = uint(value.Int64)
|
||||
_m.UdDecoy = uint(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldUdSmoke:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field ud_smoke", values[i])
|
||||
} else if value.Valid {
|
||||
mp.UdSmoke = uint(value.Int64)
|
||||
_m.UdSmoke = uint(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldCrosshair:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field crosshair", values[i])
|
||||
} else if value.Valid {
|
||||
mp.Crosshair = value.String
|
||||
_m.Crosshair = value.String
|
||||
}
|
||||
case matchplayer.FieldColor:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field color", values[i])
|
||||
} else if value.Valid {
|
||||
mp.Color = matchplayer.Color(value.String)
|
||||
_m.Color = matchplayer.Color(value.String)
|
||||
}
|
||||
case matchplayer.FieldKast:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field kast", values[i])
|
||||
} else if value.Valid {
|
||||
mp.Kast = int(value.Int64)
|
||||
_m.Kast = int(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldFlashDurationSelf:
|
||||
if value, ok := values[i].(*sql.NullFloat64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field flash_duration_self", values[i])
|
||||
} else if value.Valid {
|
||||
mp.FlashDurationSelf = float32(value.Float64)
|
||||
_m.FlashDurationSelf = float32(value.Float64)
|
||||
}
|
||||
case matchplayer.FieldFlashDurationTeam:
|
||||
if value, ok := values[i].(*sql.NullFloat64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field flash_duration_team", values[i])
|
||||
} else if value.Valid {
|
||||
mp.FlashDurationTeam = float32(value.Float64)
|
||||
_m.FlashDurationTeam = float32(value.Float64)
|
||||
}
|
||||
case matchplayer.FieldFlashDurationEnemy:
|
||||
if value, ok := values[i].(*sql.NullFloat64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field flash_duration_enemy", values[i])
|
||||
} else if value.Valid {
|
||||
mp.FlashDurationEnemy = float32(value.Float64)
|
||||
_m.FlashDurationEnemy = float32(value.Float64)
|
||||
}
|
||||
case matchplayer.FieldFlashTotalSelf:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field flash_total_self", values[i])
|
||||
} else if value.Valid {
|
||||
mp.FlashTotalSelf = uint(value.Int64)
|
||||
_m.FlashTotalSelf = uint(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldFlashTotalTeam:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field flash_total_team", values[i])
|
||||
} else if value.Valid {
|
||||
mp.FlashTotalTeam = uint(value.Int64)
|
||||
_m.FlashTotalTeam = uint(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldFlashTotalEnemy:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field flash_total_enemy", values[i])
|
||||
} else if value.Valid {
|
||||
mp.FlashTotalEnemy = uint(value.Int64)
|
||||
_m.FlashTotalEnemy = uint(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldMatchStats:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field match_stats", values[i])
|
||||
} else if value.Valid {
|
||||
mp.MatchStats = uint64(value.Int64)
|
||||
_m.MatchStats = uint64(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldPlayerStats:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field player_stats", values[i])
|
||||
} else if value.Valid {
|
||||
mp.PlayerStats = uint64(value.Int64)
|
||||
_m.PlayerStats = uint64(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldFlashAssists:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field flash_assists", values[i])
|
||||
} else if value.Valid {
|
||||
mp.FlashAssists = int(value.Int64)
|
||||
_m.FlashAssists = int(value.Int64)
|
||||
}
|
||||
case matchplayer.FieldAvgPing:
|
||||
if value, ok := values[i].(*sql.NullFloat64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field avg_ping", values[i])
|
||||
} else if value.Valid {
|
||||
mp.AvgPing = value.Float64
|
||||
_m.AvgPing = value.Float64
|
||||
}
|
||||
default:
|
||||
mp.selectValues.Set(columns[i], values[i])
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -410,161 +406,161 @@ func (mp *MatchPlayer) assignValues(columns []string, values []any) error {
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the MatchPlayer.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (mp *MatchPlayer) Value(name string) (ent.Value, error) {
|
||||
return mp.selectValues.Get(name)
|
||||
func (_m *MatchPlayer) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryMatches queries the "matches" edge of the MatchPlayer entity.
|
||||
func (mp *MatchPlayer) QueryMatches() *MatchQuery {
|
||||
return NewMatchPlayerClient(mp.config).QueryMatches(mp)
|
||||
func (_m *MatchPlayer) QueryMatches() *MatchQuery {
|
||||
return NewMatchPlayerClient(_m.config).QueryMatches(_m)
|
||||
}
|
||||
|
||||
// QueryPlayers queries the "players" edge of the MatchPlayer entity.
|
||||
func (mp *MatchPlayer) QueryPlayers() *PlayerQuery {
|
||||
return NewMatchPlayerClient(mp.config).QueryPlayers(mp)
|
||||
func (_m *MatchPlayer) QueryPlayers() *PlayerQuery {
|
||||
return NewMatchPlayerClient(_m.config).QueryPlayers(_m)
|
||||
}
|
||||
|
||||
// QueryWeaponStats queries the "weapon_stats" edge of the MatchPlayer entity.
|
||||
func (mp *MatchPlayer) QueryWeaponStats() *WeaponQuery {
|
||||
return NewMatchPlayerClient(mp.config).QueryWeaponStats(mp)
|
||||
func (_m *MatchPlayer) QueryWeaponStats() *WeaponQuery {
|
||||
return NewMatchPlayerClient(_m.config).QueryWeaponStats(_m)
|
||||
}
|
||||
|
||||
// QueryRoundStats queries the "round_stats" edge of the MatchPlayer entity.
|
||||
func (mp *MatchPlayer) QueryRoundStats() *RoundStatsQuery {
|
||||
return NewMatchPlayerClient(mp.config).QueryRoundStats(mp)
|
||||
func (_m *MatchPlayer) QueryRoundStats() *RoundStatsQuery {
|
||||
return NewMatchPlayerClient(_m.config).QueryRoundStats(_m)
|
||||
}
|
||||
|
||||
// QuerySpray queries the "spray" edge of the MatchPlayer entity.
|
||||
func (mp *MatchPlayer) QuerySpray() *SprayQuery {
|
||||
return NewMatchPlayerClient(mp.config).QuerySpray(mp)
|
||||
func (_m *MatchPlayer) QuerySpray() *SprayQuery {
|
||||
return NewMatchPlayerClient(_m.config).QuerySpray(_m)
|
||||
}
|
||||
|
||||
// QueryMessages queries the "messages" edge of the MatchPlayer entity.
|
||||
func (mp *MatchPlayer) QueryMessages() *MessagesQuery {
|
||||
return NewMatchPlayerClient(mp.config).QueryMessages(mp)
|
||||
func (_m *MatchPlayer) QueryMessages() *MessagesQuery {
|
||||
return NewMatchPlayerClient(_m.config).QueryMessages(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this MatchPlayer.
|
||||
// Note that you need to call MatchPlayer.Unwrap() before calling this method if this MatchPlayer
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (mp *MatchPlayer) Update() *MatchPlayerUpdateOne {
|
||||
return NewMatchPlayerClient(mp.config).UpdateOne(mp)
|
||||
func (_m *MatchPlayer) Update() *MatchPlayerUpdateOne {
|
||||
return NewMatchPlayerClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the MatchPlayer entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (mp *MatchPlayer) Unwrap() *MatchPlayer {
|
||||
_tx, ok := mp.config.driver.(*txDriver)
|
||||
func (_m *MatchPlayer) Unwrap() *MatchPlayer {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: MatchPlayer is not a transactional entity")
|
||||
}
|
||||
mp.config.driver = _tx.drv
|
||||
return mp
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (mp *MatchPlayer) String() string {
|
||||
func (_m *MatchPlayer) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("MatchPlayer(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", mp.ID))
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("team_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.TeamID))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.TeamID))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("kills=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.Kills))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Kills))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("deaths=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.Deaths))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Deaths))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("assists=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.Assists))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Assists))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("headshot=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.Headshot))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Headshot))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("mvp=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.Mvp))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Mvp))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("score=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.Score))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Score))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("rank_new=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.RankNew))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.RankNew))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("rank_old=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.RankOld))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.RankOld))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("mk_2=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.Mk2))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Mk2))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("mk_3=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.Mk3))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Mk3))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("mk_4=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.Mk4))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Mk4))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("mk_5=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.Mk5))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Mk5))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("dmg_enemy=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.DmgEnemy))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.DmgEnemy))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("dmg_team=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.DmgTeam))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.DmgTeam))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("ud_he=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.UdHe))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.UdHe))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("ud_flames=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.UdFlames))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.UdFlames))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("ud_flash=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.UdFlash))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.UdFlash))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("ud_decoy=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.UdDecoy))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.UdDecoy))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("ud_smoke=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.UdSmoke))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.UdSmoke))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("crosshair=")
|
||||
builder.WriteString(mp.Crosshair)
|
||||
builder.WriteString(_m.Crosshair)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("color=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.Color))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Color))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("kast=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.Kast))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Kast))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("flash_duration_self=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.FlashDurationSelf))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.FlashDurationSelf))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("flash_duration_team=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.FlashDurationTeam))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.FlashDurationTeam))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("flash_duration_enemy=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.FlashDurationEnemy))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.FlashDurationEnemy))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("flash_total_self=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.FlashTotalSelf))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.FlashTotalSelf))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("flash_total_team=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.FlashTotalTeam))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.FlashTotalTeam))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("flash_total_enemy=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.FlashTotalEnemy))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.FlashTotalEnemy))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("match_stats=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.MatchStats))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.MatchStats))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("player_stats=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.PlayerStats))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.PlayerStats))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("flash_assists=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.FlashAssists))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.FlashAssists))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("avg_ping=")
|
||||
builder.WriteString(fmt.Sprintf("%v", mp.AvgPing))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.AvgPing))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -1898,32 +1898,15 @@ func HasMessagesWith(preds ...predicate.Messages) predicate.MatchPlayer {
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.MatchPlayer) predicate.MatchPlayer {
|
||||
return predicate.MatchPlayer(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for _, p := range predicates {
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
return predicate.MatchPlayer(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.MatchPlayer) predicate.MatchPlayer {
|
||||
return predicate.MatchPlayer(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for i, p := range predicates {
|
||||
if i > 0 {
|
||||
s1.Or()
|
||||
}
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
return predicate.MatchPlayer(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.MatchPlayer) predicate.MatchPlayer {
|
||||
return predicate.MatchPlayer(func(s *sql.Selector) {
|
||||
p(s.Not())
|
||||
})
|
||||
return predicate.MatchPlayer(sql.NotPredicates(p))
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,56 +20,56 @@ type MatchPlayerDelete struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the MatchPlayerDelete builder.
|
||||
func (mpd *MatchPlayerDelete) Where(ps ...predicate.MatchPlayer) *MatchPlayerDelete {
|
||||
mpd.mutation.Where(ps...)
|
||||
return mpd
|
||||
func (_d *MatchPlayerDelete) Where(ps ...predicate.MatchPlayer) *MatchPlayerDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (mpd *MatchPlayerDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, mpd.sqlExec, mpd.mutation, mpd.hooks)
|
||||
func (_d *MatchPlayerDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (mpd *MatchPlayerDelete) ExecX(ctx context.Context) int {
|
||||
n, err := mpd.Exec(ctx)
|
||||
func (_d *MatchPlayerDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (mpd *MatchPlayerDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
func (_d *MatchPlayerDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(matchplayer.Table, sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt))
|
||||
if ps := mpd.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, mpd.driver, _spec)
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
mpd.mutation.done = true
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// MatchPlayerDeleteOne is the builder for deleting a single MatchPlayer entity.
|
||||
type MatchPlayerDeleteOne struct {
|
||||
mpd *MatchPlayerDelete
|
||||
_d *MatchPlayerDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the MatchPlayerDelete builder.
|
||||
func (mpdo *MatchPlayerDeleteOne) Where(ps ...predicate.MatchPlayer) *MatchPlayerDeleteOne {
|
||||
mpdo.mpd.mutation.Where(ps...)
|
||||
return mpdo
|
||||
func (_d *MatchPlayerDeleteOne) Where(ps ...predicate.MatchPlayer) *MatchPlayerDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (mpdo *MatchPlayerDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := mpdo.mpd.Exec(ctx)
|
||||
func (_d *MatchPlayerDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
@@ -81,8 +81,8 @@ func (mpdo *MatchPlayerDeleteOne) Exec(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (mpdo *MatchPlayerDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := mpdo.Exec(ctx); err != nil {
|
||||
func (_d *MatchPlayerDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
@@ -41,44 +42,44 @@ type MatchPlayerQuery struct {
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the MatchPlayerQuery builder.
|
||||
func (mpq *MatchPlayerQuery) Where(ps ...predicate.MatchPlayer) *MatchPlayerQuery {
|
||||
mpq.predicates = append(mpq.predicates, ps...)
|
||||
return mpq
|
||||
func (_q *MatchPlayerQuery) Where(ps ...predicate.MatchPlayer) *MatchPlayerQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (mpq *MatchPlayerQuery) Limit(limit int) *MatchPlayerQuery {
|
||||
mpq.ctx.Limit = &limit
|
||||
return mpq
|
||||
func (_q *MatchPlayerQuery) Limit(limit int) *MatchPlayerQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (mpq *MatchPlayerQuery) Offset(offset int) *MatchPlayerQuery {
|
||||
mpq.ctx.Offset = &offset
|
||||
return mpq
|
||||
func (_q *MatchPlayerQuery) Offset(offset int) *MatchPlayerQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (mpq *MatchPlayerQuery) Unique(unique bool) *MatchPlayerQuery {
|
||||
mpq.ctx.Unique = &unique
|
||||
return mpq
|
||||
func (_q *MatchPlayerQuery) Unique(unique bool) *MatchPlayerQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (mpq *MatchPlayerQuery) Order(o ...matchplayer.OrderOption) *MatchPlayerQuery {
|
||||
mpq.order = append(mpq.order, o...)
|
||||
return mpq
|
||||
func (_q *MatchPlayerQuery) Order(o ...matchplayer.OrderOption) *MatchPlayerQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryMatches chains the current query on the "matches" edge.
|
||||
func (mpq *MatchPlayerQuery) QueryMatches() *MatchQuery {
|
||||
query := (&MatchClient{config: mpq.config}).Query()
|
||||
func (_q *MatchPlayerQuery) QueryMatches() *MatchQuery {
|
||||
query := (&MatchClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := mpq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := mpq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -87,20 +88,20 @@ func (mpq *MatchPlayerQuery) QueryMatches() *MatchQuery {
|
||||
sqlgraph.To(match.Table, match.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, matchplayer.MatchesTable, matchplayer.MatchesColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(mpq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryPlayers chains the current query on the "players" edge.
|
||||
func (mpq *MatchPlayerQuery) QueryPlayers() *PlayerQuery {
|
||||
query := (&PlayerClient{config: mpq.config}).Query()
|
||||
func (_q *MatchPlayerQuery) QueryPlayers() *PlayerQuery {
|
||||
query := (&PlayerClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := mpq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := mpq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -109,20 +110,20 @@ func (mpq *MatchPlayerQuery) QueryPlayers() *PlayerQuery {
|
||||
sqlgraph.To(player.Table, player.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, matchplayer.PlayersTable, matchplayer.PlayersColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(mpq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryWeaponStats chains the current query on the "weapon_stats" edge.
|
||||
func (mpq *MatchPlayerQuery) QueryWeaponStats() *WeaponQuery {
|
||||
query := (&WeaponClient{config: mpq.config}).Query()
|
||||
func (_q *MatchPlayerQuery) QueryWeaponStats() *WeaponQuery {
|
||||
query := (&WeaponClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := mpq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := mpq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -131,20 +132,20 @@ func (mpq *MatchPlayerQuery) QueryWeaponStats() *WeaponQuery {
|
||||
sqlgraph.To(weapon.Table, weapon.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.WeaponStatsTable, matchplayer.WeaponStatsColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(mpq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryRoundStats chains the current query on the "round_stats" edge.
|
||||
func (mpq *MatchPlayerQuery) QueryRoundStats() *RoundStatsQuery {
|
||||
query := (&RoundStatsClient{config: mpq.config}).Query()
|
||||
func (_q *MatchPlayerQuery) QueryRoundStats() *RoundStatsQuery {
|
||||
query := (&RoundStatsClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := mpq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := mpq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -153,20 +154,20 @@ func (mpq *MatchPlayerQuery) QueryRoundStats() *RoundStatsQuery {
|
||||
sqlgraph.To(roundstats.Table, roundstats.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.RoundStatsTable, matchplayer.RoundStatsColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(mpq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QuerySpray chains the current query on the "spray" edge.
|
||||
func (mpq *MatchPlayerQuery) QuerySpray() *SprayQuery {
|
||||
query := (&SprayClient{config: mpq.config}).Query()
|
||||
func (_q *MatchPlayerQuery) QuerySpray() *SprayQuery {
|
||||
query := (&SprayClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := mpq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := mpq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -175,20 +176,20 @@ func (mpq *MatchPlayerQuery) QuerySpray() *SprayQuery {
|
||||
sqlgraph.To(spray.Table, spray.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.SprayTable, matchplayer.SprayColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(mpq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryMessages chains the current query on the "messages" edge.
|
||||
func (mpq *MatchPlayerQuery) QueryMessages() *MessagesQuery {
|
||||
query := (&MessagesClient{config: mpq.config}).Query()
|
||||
func (_q *MatchPlayerQuery) QueryMessages() *MessagesQuery {
|
||||
query := (&MessagesClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := mpq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := mpq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -197,7 +198,7 @@ func (mpq *MatchPlayerQuery) QueryMessages() *MessagesQuery {
|
||||
sqlgraph.To(messages.Table, messages.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, matchplayer.MessagesTable, matchplayer.MessagesColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(mpq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
@@ -205,8 +206,8 @@ func (mpq *MatchPlayerQuery) QueryMessages() *MessagesQuery {
|
||||
|
||||
// First returns the first MatchPlayer entity from the query.
|
||||
// Returns a *NotFoundError when no MatchPlayer was found.
|
||||
func (mpq *MatchPlayerQuery) First(ctx context.Context) (*MatchPlayer, error) {
|
||||
nodes, err := mpq.Limit(1).All(setContextOp(ctx, mpq.ctx, "First"))
|
||||
func (_q *MatchPlayerQuery) First(ctx context.Context) (*MatchPlayer, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -217,8 +218,8 @@ func (mpq *MatchPlayerQuery) First(ctx context.Context) (*MatchPlayer, error) {
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (mpq *MatchPlayerQuery) FirstX(ctx context.Context) *MatchPlayer {
|
||||
node, err := mpq.First(ctx)
|
||||
func (_q *MatchPlayerQuery) FirstX(ctx context.Context) *MatchPlayer {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -227,9 +228,9 @@ func (mpq *MatchPlayerQuery) FirstX(ctx context.Context) *MatchPlayer {
|
||||
|
||||
// FirstID returns the first MatchPlayer ID from the query.
|
||||
// Returns a *NotFoundError when no MatchPlayer ID was found.
|
||||
func (mpq *MatchPlayerQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
func (_q *MatchPlayerQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = mpq.Limit(1).IDs(setContextOp(ctx, mpq.ctx, "FirstID")); err != nil {
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
@@ -240,8 +241,8 @@ func (mpq *MatchPlayerQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (mpq *MatchPlayerQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := mpq.FirstID(ctx)
|
||||
func (_q *MatchPlayerQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -251,8 +252,8 @@ func (mpq *MatchPlayerQuery) FirstIDX(ctx context.Context) int {
|
||||
// Only returns a single MatchPlayer entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one MatchPlayer entity is found.
|
||||
// Returns a *NotFoundError when no MatchPlayer entities are found.
|
||||
func (mpq *MatchPlayerQuery) Only(ctx context.Context) (*MatchPlayer, error) {
|
||||
nodes, err := mpq.Limit(2).All(setContextOp(ctx, mpq.ctx, "Only"))
|
||||
func (_q *MatchPlayerQuery) Only(ctx context.Context) (*MatchPlayer, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -267,8 +268,8 @@ func (mpq *MatchPlayerQuery) Only(ctx context.Context) (*MatchPlayer, error) {
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (mpq *MatchPlayerQuery) OnlyX(ctx context.Context) *MatchPlayer {
|
||||
node, err := mpq.Only(ctx)
|
||||
func (_q *MatchPlayerQuery) OnlyX(ctx context.Context) *MatchPlayer {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -278,9 +279,9 @@ func (mpq *MatchPlayerQuery) OnlyX(ctx context.Context) *MatchPlayer {
|
||||
// OnlyID is like Only, but returns the only MatchPlayer ID in the query.
|
||||
// Returns a *NotSingularError when more than one MatchPlayer ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (mpq *MatchPlayerQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
func (_q *MatchPlayerQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = mpq.Limit(2).IDs(setContextOp(ctx, mpq.ctx, "OnlyID")); err != nil {
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
@@ -295,8 +296,8 @@ func (mpq *MatchPlayerQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (mpq *MatchPlayerQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := mpq.OnlyID(ctx)
|
||||
func (_q *MatchPlayerQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -304,18 +305,18 @@ func (mpq *MatchPlayerQuery) OnlyIDX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of MatchPlayers.
|
||||
func (mpq *MatchPlayerQuery) All(ctx context.Context) ([]*MatchPlayer, error) {
|
||||
ctx = setContextOp(ctx, mpq.ctx, "All")
|
||||
if err := mpq.prepareQuery(ctx); err != nil {
|
||||
func (_q *MatchPlayerQuery) All(ctx context.Context) ([]*MatchPlayer, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*MatchPlayer, *MatchPlayerQuery]()
|
||||
return withInterceptors[[]*MatchPlayer](ctx, mpq, qr, mpq.inters)
|
||||
return withInterceptors[[]*MatchPlayer](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (mpq *MatchPlayerQuery) AllX(ctx context.Context) []*MatchPlayer {
|
||||
nodes, err := mpq.All(ctx)
|
||||
func (_q *MatchPlayerQuery) AllX(ctx context.Context) []*MatchPlayer {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -323,20 +324,20 @@ func (mpq *MatchPlayerQuery) AllX(ctx context.Context) []*MatchPlayer {
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of MatchPlayer IDs.
|
||||
func (mpq *MatchPlayerQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if mpq.ctx.Unique == nil && mpq.path != nil {
|
||||
mpq.Unique(true)
|
||||
func (_q *MatchPlayerQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, mpq.ctx, "IDs")
|
||||
if err = mpq.Select(matchplayer.FieldID).Scan(ctx, &ids); err != nil {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(matchplayer.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (mpq *MatchPlayerQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := mpq.IDs(ctx)
|
||||
func (_q *MatchPlayerQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -344,17 +345,17 @@ func (mpq *MatchPlayerQuery) IDsX(ctx context.Context) []int {
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (mpq *MatchPlayerQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, mpq.ctx, "Count")
|
||||
if err := mpq.prepareQuery(ctx); err != nil {
|
||||
func (_q *MatchPlayerQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, mpq, querierCount[*MatchPlayerQuery](), mpq.inters)
|
||||
return withInterceptors[int](ctx, _q, querierCount[*MatchPlayerQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (mpq *MatchPlayerQuery) CountX(ctx context.Context) int {
|
||||
count, err := mpq.Count(ctx)
|
||||
func (_q *MatchPlayerQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -362,9 +363,9 @@ func (mpq *MatchPlayerQuery) CountX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (mpq *MatchPlayerQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, mpq.ctx, "Exist")
|
||||
switch _, err := mpq.FirstID(ctx); {
|
||||
func (_q *MatchPlayerQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
@@ -375,8 +376,8 @@ func (mpq *MatchPlayerQuery) Exist(ctx context.Context) (bool, error) {
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (mpq *MatchPlayerQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := mpq.Exist(ctx)
|
||||
func (_q *MatchPlayerQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -385,92 +386,93 @@ func (mpq *MatchPlayerQuery) ExistX(ctx context.Context) bool {
|
||||
|
||||
// Clone returns a duplicate of the MatchPlayerQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (mpq *MatchPlayerQuery) Clone() *MatchPlayerQuery {
|
||||
if mpq == nil {
|
||||
func (_q *MatchPlayerQuery) Clone() *MatchPlayerQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &MatchPlayerQuery{
|
||||
config: mpq.config,
|
||||
ctx: mpq.ctx.Clone(),
|
||||
order: append([]matchplayer.OrderOption{}, mpq.order...),
|
||||
inters: append([]Interceptor{}, mpq.inters...),
|
||||
predicates: append([]predicate.MatchPlayer{}, mpq.predicates...),
|
||||
withMatches: mpq.withMatches.Clone(),
|
||||
withPlayers: mpq.withPlayers.Clone(),
|
||||
withWeaponStats: mpq.withWeaponStats.Clone(),
|
||||
withRoundStats: mpq.withRoundStats.Clone(),
|
||||
withSpray: mpq.withSpray.Clone(),
|
||||
withMessages: mpq.withMessages.Clone(),
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]matchplayer.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.MatchPlayer{}, _q.predicates...),
|
||||
withMatches: _q.withMatches.Clone(),
|
||||
withPlayers: _q.withPlayers.Clone(),
|
||||
withWeaponStats: _q.withWeaponStats.Clone(),
|
||||
withRoundStats: _q.withRoundStats.Clone(),
|
||||
withSpray: _q.withSpray.Clone(),
|
||||
withMessages: _q.withMessages.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: mpq.sql.Clone(),
|
||||
path: mpq.path,
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
modifiers: append([]func(*sql.Selector){}, _q.modifiers...),
|
||||
}
|
||||
}
|
||||
|
||||
// WithMatches tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "matches" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (mpq *MatchPlayerQuery) WithMatches(opts ...func(*MatchQuery)) *MatchPlayerQuery {
|
||||
query := (&MatchClient{config: mpq.config}).Query()
|
||||
func (_q *MatchPlayerQuery) WithMatches(opts ...func(*MatchQuery)) *MatchPlayerQuery {
|
||||
query := (&MatchClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
mpq.withMatches = query
|
||||
return mpq
|
||||
_q.withMatches = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithPlayers tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "players" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (mpq *MatchPlayerQuery) WithPlayers(opts ...func(*PlayerQuery)) *MatchPlayerQuery {
|
||||
query := (&PlayerClient{config: mpq.config}).Query()
|
||||
func (_q *MatchPlayerQuery) WithPlayers(opts ...func(*PlayerQuery)) *MatchPlayerQuery {
|
||||
query := (&PlayerClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
mpq.withPlayers = query
|
||||
return mpq
|
||||
_q.withPlayers = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithWeaponStats tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "weapon_stats" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (mpq *MatchPlayerQuery) WithWeaponStats(opts ...func(*WeaponQuery)) *MatchPlayerQuery {
|
||||
query := (&WeaponClient{config: mpq.config}).Query()
|
||||
func (_q *MatchPlayerQuery) WithWeaponStats(opts ...func(*WeaponQuery)) *MatchPlayerQuery {
|
||||
query := (&WeaponClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
mpq.withWeaponStats = query
|
||||
return mpq
|
||||
_q.withWeaponStats = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithRoundStats tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "round_stats" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (mpq *MatchPlayerQuery) WithRoundStats(opts ...func(*RoundStatsQuery)) *MatchPlayerQuery {
|
||||
query := (&RoundStatsClient{config: mpq.config}).Query()
|
||||
func (_q *MatchPlayerQuery) WithRoundStats(opts ...func(*RoundStatsQuery)) *MatchPlayerQuery {
|
||||
query := (&RoundStatsClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
mpq.withRoundStats = query
|
||||
return mpq
|
||||
_q.withRoundStats = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithSpray tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "spray" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (mpq *MatchPlayerQuery) WithSpray(opts ...func(*SprayQuery)) *MatchPlayerQuery {
|
||||
query := (&SprayClient{config: mpq.config}).Query()
|
||||
func (_q *MatchPlayerQuery) WithSpray(opts ...func(*SprayQuery)) *MatchPlayerQuery {
|
||||
query := (&SprayClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
mpq.withSpray = query
|
||||
return mpq
|
||||
_q.withSpray = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithMessages tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "messages" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (mpq *MatchPlayerQuery) WithMessages(opts ...func(*MessagesQuery)) *MatchPlayerQuery {
|
||||
query := (&MessagesClient{config: mpq.config}).Query()
|
||||
func (_q *MatchPlayerQuery) WithMessages(opts ...func(*MessagesQuery)) *MatchPlayerQuery {
|
||||
query := (&MessagesClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
mpq.withMessages = query
|
||||
return mpq
|
||||
_q.withMessages = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
@@ -487,10 +489,10 @@ func (mpq *MatchPlayerQuery) WithMessages(opts ...func(*MessagesQuery)) *MatchPl
|
||||
// GroupBy(matchplayer.FieldTeamID).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (mpq *MatchPlayerQuery) GroupBy(field string, fields ...string) *MatchPlayerGroupBy {
|
||||
mpq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &MatchPlayerGroupBy{build: mpq}
|
||||
grbuild.flds = &mpq.ctx.Fields
|
||||
func (_q *MatchPlayerQuery) GroupBy(field string, fields ...string) *MatchPlayerGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &MatchPlayerGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = matchplayer.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
@@ -508,114 +510,114 @@ func (mpq *MatchPlayerQuery) GroupBy(field string, fields ...string) *MatchPlaye
|
||||
// client.MatchPlayer.Query().
|
||||
// Select(matchplayer.FieldTeamID).
|
||||
// Scan(ctx, &v)
|
||||
func (mpq *MatchPlayerQuery) Select(fields ...string) *MatchPlayerSelect {
|
||||
mpq.ctx.Fields = append(mpq.ctx.Fields, fields...)
|
||||
sbuild := &MatchPlayerSelect{MatchPlayerQuery: mpq}
|
||||
func (_q *MatchPlayerQuery) Select(fields ...string) *MatchPlayerSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &MatchPlayerSelect{MatchPlayerQuery: _q}
|
||||
sbuild.label = matchplayer.Label
|
||||
sbuild.flds, sbuild.scan = &mpq.ctx.Fields, sbuild.Scan
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a MatchPlayerSelect configured with the given aggregations.
|
||||
func (mpq *MatchPlayerQuery) Aggregate(fns ...AggregateFunc) *MatchPlayerSelect {
|
||||
return mpq.Select().Aggregate(fns...)
|
||||
func (_q *MatchPlayerQuery) Aggregate(fns ...AggregateFunc) *MatchPlayerSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (mpq *MatchPlayerQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range mpq.inters {
|
||||
func (_q *MatchPlayerQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, mpq); err != nil {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range mpq.ctx.Fields {
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !matchplayer.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if mpq.path != nil {
|
||||
prev, err := mpq.path(ctx)
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mpq.sql = prev
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mpq *MatchPlayerQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*MatchPlayer, error) {
|
||||
func (_q *MatchPlayerQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*MatchPlayer, error) {
|
||||
var (
|
||||
nodes = []*MatchPlayer{}
|
||||
_spec = mpq.querySpec()
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [6]bool{
|
||||
mpq.withMatches != nil,
|
||||
mpq.withPlayers != nil,
|
||||
mpq.withWeaponStats != nil,
|
||||
mpq.withRoundStats != nil,
|
||||
mpq.withSpray != nil,
|
||||
mpq.withMessages != nil,
|
||||
_q.withMatches != nil,
|
||||
_q.withPlayers != nil,
|
||||
_q.withWeaponStats != nil,
|
||||
_q.withRoundStats != nil,
|
||||
_q.withSpray != nil,
|
||||
_q.withMessages != nil,
|
||||
}
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*MatchPlayer).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &MatchPlayer{config: mpq.config}
|
||||
node := &MatchPlayer{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
if len(mpq.modifiers) > 0 {
|
||||
_spec.Modifiers = mpq.modifiers
|
||||
if len(_q.modifiers) > 0 {
|
||||
_spec.Modifiers = _q.modifiers
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, mpq.driver, _spec); err != nil {
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := mpq.withMatches; query != nil {
|
||||
if err := mpq.loadMatches(ctx, query, nodes, nil,
|
||||
if query := _q.withMatches; query != nil {
|
||||
if err := _q.loadMatches(ctx, query, nodes, nil,
|
||||
func(n *MatchPlayer, e *Match) { n.Edges.Matches = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := mpq.withPlayers; query != nil {
|
||||
if err := mpq.loadPlayers(ctx, query, nodes, nil,
|
||||
if query := _q.withPlayers; query != nil {
|
||||
if err := _q.loadPlayers(ctx, query, nodes, nil,
|
||||
func(n *MatchPlayer, e *Player) { n.Edges.Players = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := mpq.withWeaponStats; query != nil {
|
||||
if err := mpq.loadWeaponStats(ctx, query, nodes,
|
||||
if query := _q.withWeaponStats; query != nil {
|
||||
if err := _q.loadWeaponStats(ctx, query, nodes,
|
||||
func(n *MatchPlayer) { n.Edges.WeaponStats = []*Weapon{} },
|
||||
func(n *MatchPlayer, e *Weapon) { n.Edges.WeaponStats = append(n.Edges.WeaponStats, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := mpq.withRoundStats; query != nil {
|
||||
if err := mpq.loadRoundStats(ctx, query, nodes,
|
||||
if query := _q.withRoundStats; query != nil {
|
||||
if err := _q.loadRoundStats(ctx, query, nodes,
|
||||
func(n *MatchPlayer) { n.Edges.RoundStats = []*RoundStats{} },
|
||||
func(n *MatchPlayer, e *RoundStats) { n.Edges.RoundStats = append(n.Edges.RoundStats, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := mpq.withSpray; query != nil {
|
||||
if err := mpq.loadSpray(ctx, query, nodes,
|
||||
if query := _q.withSpray; query != nil {
|
||||
if err := _q.loadSpray(ctx, query, nodes,
|
||||
func(n *MatchPlayer) { n.Edges.Spray = []*Spray{} },
|
||||
func(n *MatchPlayer, e *Spray) { n.Edges.Spray = append(n.Edges.Spray, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := mpq.withMessages; query != nil {
|
||||
if err := mpq.loadMessages(ctx, query, nodes,
|
||||
if query := _q.withMessages; query != nil {
|
||||
if err := _q.loadMessages(ctx, query, nodes,
|
||||
func(n *MatchPlayer) { n.Edges.Messages = []*Messages{} },
|
||||
func(n *MatchPlayer, e *Messages) { n.Edges.Messages = append(n.Edges.Messages, e) }); err != nil {
|
||||
return nil, err
|
||||
@@ -624,7 +626,7 @@ func (mpq *MatchPlayerQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (mpq *MatchPlayerQuery) loadMatches(ctx context.Context, query *MatchQuery, nodes []*MatchPlayer, init func(*MatchPlayer), assign func(*MatchPlayer, *Match)) error {
|
||||
func (_q *MatchPlayerQuery) loadMatches(ctx context.Context, query *MatchQuery, nodes []*MatchPlayer, init func(*MatchPlayer), assign func(*MatchPlayer, *Match)) error {
|
||||
ids := make([]uint64, 0, len(nodes))
|
||||
nodeids := make(map[uint64][]*MatchPlayer)
|
||||
for i := range nodes {
|
||||
@@ -653,7 +655,7 @@ func (mpq *MatchPlayerQuery) loadMatches(ctx context.Context, query *MatchQuery,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (mpq *MatchPlayerQuery) loadPlayers(ctx context.Context, query *PlayerQuery, nodes []*MatchPlayer, init func(*MatchPlayer), assign func(*MatchPlayer, *Player)) error {
|
||||
func (_q *MatchPlayerQuery) loadPlayers(ctx context.Context, query *PlayerQuery, nodes []*MatchPlayer, init func(*MatchPlayer), assign func(*MatchPlayer, *Player)) error {
|
||||
ids := make([]uint64, 0, len(nodes))
|
||||
nodeids := make(map[uint64][]*MatchPlayer)
|
||||
for i := range nodes {
|
||||
@@ -682,7 +684,7 @@ func (mpq *MatchPlayerQuery) loadPlayers(ctx context.Context, query *PlayerQuery
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (mpq *MatchPlayerQuery) loadWeaponStats(ctx context.Context, query *WeaponQuery, nodes []*MatchPlayer, init func(*MatchPlayer), assign func(*MatchPlayer, *Weapon)) error {
|
||||
func (_q *MatchPlayerQuery) loadWeaponStats(ctx context.Context, query *WeaponQuery, nodes []*MatchPlayer, init func(*MatchPlayer), assign func(*MatchPlayer, *Weapon)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[int]*MatchPlayer)
|
||||
for i := range nodes {
|
||||
@@ -713,7 +715,7 @@ func (mpq *MatchPlayerQuery) loadWeaponStats(ctx context.Context, query *WeaponQ
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (mpq *MatchPlayerQuery) loadRoundStats(ctx context.Context, query *RoundStatsQuery, nodes []*MatchPlayer, init func(*MatchPlayer), assign func(*MatchPlayer, *RoundStats)) error {
|
||||
func (_q *MatchPlayerQuery) loadRoundStats(ctx context.Context, query *RoundStatsQuery, nodes []*MatchPlayer, init func(*MatchPlayer), assign func(*MatchPlayer, *RoundStats)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[int]*MatchPlayer)
|
||||
for i := range nodes {
|
||||
@@ -744,7 +746,7 @@ func (mpq *MatchPlayerQuery) loadRoundStats(ctx context.Context, query *RoundSta
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (mpq *MatchPlayerQuery) loadSpray(ctx context.Context, query *SprayQuery, nodes []*MatchPlayer, init func(*MatchPlayer), assign func(*MatchPlayer, *Spray)) error {
|
||||
func (_q *MatchPlayerQuery) loadSpray(ctx context.Context, query *SprayQuery, nodes []*MatchPlayer, init func(*MatchPlayer), assign func(*MatchPlayer, *Spray)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[int]*MatchPlayer)
|
||||
for i := range nodes {
|
||||
@@ -775,7 +777,7 @@ func (mpq *MatchPlayerQuery) loadSpray(ctx context.Context, query *SprayQuery, n
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (mpq *MatchPlayerQuery) loadMessages(ctx context.Context, query *MessagesQuery, nodes []*MatchPlayer, init func(*MatchPlayer), assign func(*MatchPlayer, *Messages)) error {
|
||||
func (_q *MatchPlayerQuery) loadMessages(ctx context.Context, query *MessagesQuery, nodes []*MatchPlayer, init func(*MatchPlayer), assign func(*MatchPlayer, *Messages)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[int]*MatchPlayer)
|
||||
for i := range nodes {
|
||||
@@ -807,27 +809,27 @@ func (mpq *MatchPlayerQuery) loadMessages(ctx context.Context, query *MessagesQu
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mpq *MatchPlayerQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := mpq.querySpec()
|
||||
if len(mpq.modifiers) > 0 {
|
||||
_spec.Modifiers = mpq.modifiers
|
||||
func (_q *MatchPlayerQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
if len(_q.modifiers) > 0 {
|
||||
_spec.Modifiers = _q.modifiers
|
||||
}
|
||||
_spec.Node.Columns = mpq.ctx.Fields
|
||||
if len(mpq.ctx.Fields) > 0 {
|
||||
_spec.Unique = mpq.ctx.Unique != nil && *mpq.ctx.Unique
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, mpq.driver, _spec)
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (mpq *MatchPlayerQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
func (_q *MatchPlayerQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(matchplayer.Table, matchplayer.Columns, sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt))
|
||||
_spec.From = mpq.sql
|
||||
if unique := mpq.ctx.Unique; unique != nil {
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if mpq.path != nil {
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := mpq.ctx.Fields; len(fields) > 0 {
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, matchplayer.FieldID)
|
||||
for i := range fields {
|
||||
@@ -835,27 +837,27 @@ func (mpq *MatchPlayerQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, fields[i])
|
||||
}
|
||||
}
|
||||
if mpq.withMatches != nil {
|
||||
if _q.withMatches != nil {
|
||||
_spec.Node.AddColumnOnce(matchplayer.FieldMatchStats)
|
||||
}
|
||||
if mpq.withPlayers != nil {
|
||||
if _q.withPlayers != nil {
|
||||
_spec.Node.AddColumnOnce(matchplayer.FieldPlayerStats)
|
||||
}
|
||||
}
|
||||
if ps := mpq.predicates; len(ps) > 0 {
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := mpq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := mpq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := mpq.order; len(ps) > 0 {
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
@@ -865,45 +867,45 @@ func (mpq *MatchPlayerQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (mpq *MatchPlayerQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(mpq.driver.Dialect())
|
||||
func (_q *MatchPlayerQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(matchplayer.Table)
|
||||
columns := mpq.ctx.Fields
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = matchplayer.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if mpq.sql != nil {
|
||||
selector = mpq.sql
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if mpq.ctx.Unique != nil && *mpq.ctx.Unique {
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, m := range mpq.modifiers {
|
||||
for _, m := range _q.modifiers {
|
||||
m(selector)
|
||||
}
|
||||
for _, p := range mpq.predicates {
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range mpq.order {
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := mpq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := mpq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// Modify adds a query modifier for attaching custom logic to queries.
|
||||
func (mpq *MatchPlayerQuery) Modify(modifiers ...func(s *sql.Selector)) *MatchPlayerSelect {
|
||||
mpq.modifiers = append(mpq.modifiers, modifiers...)
|
||||
return mpq.Select()
|
||||
func (_q *MatchPlayerQuery) Modify(modifiers ...func(s *sql.Selector)) *MatchPlayerSelect {
|
||||
_q.modifiers = append(_q.modifiers, modifiers...)
|
||||
return _q.Select()
|
||||
}
|
||||
|
||||
// MatchPlayerGroupBy is the group-by builder for MatchPlayer entities.
|
||||
@@ -913,41 +915,41 @@ type MatchPlayerGroupBy struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (mpgb *MatchPlayerGroupBy) Aggregate(fns ...AggregateFunc) *MatchPlayerGroupBy {
|
||||
mpgb.fns = append(mpgb.fns, fns...)
|
||||
return mpgb
|
||||
func (_g *MatchPlayerGroupBy) Aggregate(fns ...AggregateFunc) *MatchPlayerGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (mpgb *MatchPlayerGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, mpgb.build.ctx, "GroupBy")
|
||||
if err := mpgb.build.prepareQuery(ctx); err != nil {
|
||||
func (_g *MatchPlayerGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*MatchPlayerQuery, *MatchPlayerGroupBy](ctx, mpgb.build, mpgb, mpgb.build.inters, v)
|
||||
return scanWithInterceptors[*MatchPlayerQuery, *MatchPlayerGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (mpgb *MatchPlayerGroupBy) sqlScan(ctx context.Context, root *MatchPlayerQuery, v any) error {
|
||||
func (_g *MatchPlayerGroupBy) sqlScan(ctx context.Context, root *MatchPlayerQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(mpgb.fns))
|
||||
for _, fn := range mpgb.fns {
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*mpgb.flds)+len(mpgb.fns))
|
||||
for _, f := range *mpgb.flds {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*mpgb.flds...)...)
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := mpgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -961,27 +963,27 @@ type MatchPlayerSelect struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (mps *MatchPlayerSelect) Aggregate(fns ...AggregateFunc) *MatchPlayerSelect {
|
||||
mps.fns = append(mps.fns, fns...)
|
||||
return mps
|
||||
func (_s *MatchPlayerSelect) Aggregate(fns ...AggregateFunc) *MatchPlayerSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (mps *MatchPlayerSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, mps.ctx, "Select")
|
||||
if err := mps.prepareQuery(ctx); err != nil {
|
||||
func (_s *MatchPlayerSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*MatchPlayerQuery, *MatchPlayerSelect](ctx, mps.MatchPlayerQuery, mps, mps.inters, v)
|
||||
return scanWithInterceptors[*MatchPlayerQuery, *MatchPlayerSelect](ctx, _s.MatchPlayerQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (mps *MatchPlayerSelect) sqlScan(ctx context.Context, root *MatchPlayerQuery, v any) error {
|
||||
func (_s *MatchPlayerSelect) sqlScan(ctx context.Context, root *MatchPlayerQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(mps.fns))
|
||||
for _, fn := range mps.fns {
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*mps.selector.flds); {
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
@@ -989,7 +991,7 @@ func (mps *MatchPlayerSelect) sqlScan(ctx context.Context, root *MatchPlayerQuer
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := mps.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -997,7 +999,7 @@ func (mps *MatchPlayerSelect) sqlScan(ctx context.Context, root *MatchPlayerQuer
|
||||
}
|
||||
|
||||
// Modify adds a query modifier for attaching custom logic to queries.
|
||||
func (mps *MatchPlayerSelect) Modify(modifiers ...func(s *sql.Selector)) *MatchPlayerSelect {
|
||||
mps.modifiers = append(mps.modifiers, modifiers...)
|
||||
return mps
|
||||
func (_s *MatchPlayerSelect) Modify(modifiers ...func(s *sql.Selector)) *MatchPlayerSelect {
|
||||
_s.modifiers = append(_s.modifiers, modifiers...)
|
||||
return _s
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -42,12 +42,10 @@ type MessagesEdges struct {
|
||||
// MatchPlayerOrErr returns the MatchPlayer value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e MessagesEdges) MatchPlayerOrErr() (*MatchPlayer, error) {
|
||||
if e.loadedTypes[0] {
|
||||
if e.MatchPlayer == nil {
|
||||
// Edge was loaded but was not found.
|
||||
return nil, &NotFoundError{label: matchplayer.Label}
|
||||
}
|
||||
if e.MatchPlayer != nil {
|
||||
return e.MatchPlayer, nil
|
||||
} else if e.loadedTypes[0] {
|
||||
return nil, &NotFoundError{label: matchplayer.Label}
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "match_player"}
|
||||
}
|
||||
@@ -74,7 +72,7 @@ func (*Messages) scanValues(columns []string) ([]any, error) {
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Messages fields.
|
||||
func (m *Messages) assignValues(columns []string, values []any) error {
|
||||
func (_m *Messages) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
@@ -85,34 +83,34 @@ func (m *Messages) assignValues(columns []string, values []any) error {
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
m.ID = int(value.Int64)
|
||||
_m.ID = int(value.Int64)
|
||||
case messages.FieldMessage:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field message", values[i])
|
||||
} else if value.Valid {
|
||||
m.Message = value.String
|
||||
_m.Message = value.String
|
||||
}
|
||||
case messages.FieldAllChat:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field all_chat", values[i])
|
||||
} else if value.Valid {
|
||||
m.AllChat = value.Bool
|
||||
_m.AllChat = value.Bool
|
||||
}
|
||||
case messages.FieldTick:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field tick", values[i])
|
||||
} else if value.Valid {
|
||||
m.Tick = int(value.Int64)
|
||||
_m.Tick = int(value.Int64)
|
||||
}
|
||||
case messages.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for edge-field match_player_messages", value)
|
||||
} else if value.Valid {
|
||||
m.match_player_messages = new(int)
|
||||
*m.match_player_messages = int(value.Int64)
|
||||
_m.match_player_messages = new(int)
|
||||
*_m.match_player_messages = int(value.Int64)
|
||||
}
|
||||
default:
|
||||
m.selectValues.Set(columns[i], values[i])
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -120,46 +118,46 @@ func (m *Messages) assignValues(columns []string, values []any) error {
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Messages.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (m *Messages) Value(name string) (ent.Value, error) {
|
||||
return m.selectValues.Get(name)
|
||||
func (_m *Messages) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryMatchPlayer queries the "match_player" edge of the Messages entity.
|
||||
func (m *Messages) QueryMatchPlayer() *MatchPlayerQuery {
|
||||
return NewMessagesClient(m.config).QueryMatchPlayer(m)
|
||||
func (_m *Messages) QueryMatchPlayer() *MatchPlayerQuery {
|
||||
return NewMessagesClient(_m.config).QueryMatchPlayer(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Messages.
|
||||
// Note that you need to call Messages.Unwrap() before calling this method if this Messages
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (m *Messages) Update() *MessagesUpdateOne {
|
||||
return NewMessagesClient(m.config).UpdateOne(m)
|
||||
func (_m *Messages) Update() *MessagesUpdateOne {
|
||||
return NewMessagesClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Messages entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (m *Messages) Unwrap() *Messages {
|
||||
_tx, ok := m.config.driver.(*txDriver)
|
||||
func (_m *Messages) Unwrap() *Messages {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Messages is not a transactional entity")
|
||||
}
|
||||
m.config.driver = _tx.drv
|
||||
return m
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (m *Messages) String() string {
|
||||
func (_m *Messages) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Messages(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", m.ID))
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("message=")
|
||||
builder.WriteString(m.Message)
|
||||
builder.WriteString(_m.Message)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("all_chat=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.AllChat))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.AllChat))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("tick=")
|
||||
builder.WriteString(fmt.Sprintf("%v", m.Tick))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Tick))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -208,32 +208,15 @@ func HasMatchPlayerWith(preds ...predicate.MatchPlayer) predicate.Messages {
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Messages) predicate.Messages {
|
||||
return predicate.Messages(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for _, p := range predicates {
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
return predicate.Messages(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.Messages) predicate.Messages {
|
||||
return predicate.Messages(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for i, p := range predicates {
|
||||
if i > 0 {
|
||||
s1.Or()
|
||||
}
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
return predicate.Messages(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.Messages) predicate.Messages {
|
||||
return predicate.Messages(func(s *sql.Selector) {
|
||||
p(s.Not())
|
||||
})
|
||||
return predicate.Messages(sql.NotPredicates(p))
|
||||
}
|
||||
|
||||
@@ -21,55 +21,55 @@ type MessagesCreate struct {
|
||||
}
|
||||
|
||||
// SetMessage sets the "message" field.
|
||||
func (mc *MessagesCreate) SetMessage(s string) *MessagesCreate {
|
||||
mc.mutation.SetMessage(s)
|
||||
return mc
|
||||
func (_c *MessagesCreate) SetMessage(v string) *MessagesCreate {
|
||||
_c.mutation.SetMessage(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetAllChat sets the "all_chat" field.
|
||||
func (mc *MessagesCreate) SetAllChat(b bool) *MessagesCreate {
|
||||
mc.mutation.SetAllChat(b)
|
||||
return mc
|
||||
func (_c *MessagesCreate) SetAllChat(v bool) *MessagesCreate {
|
||||
_c.mutation.SetAllChat(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetTick sets the "tick" field.
|
||||
func (mc *MessagesCreate) SetTick(i int) *MessagesCreate {
|
||||
mc.mutation.SetTick(i)
|
||||
return mc
|
||||
func (_c *MessagesCreate) SetTick(v int) *MessagesCreate {
|
||||
_c.mutation.SetTick(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID.
|
||||
func (mc *MessagesCreate) SetMatchPlayerID(id int) *MessagesCreate {
|
||||
mc.mutation.SetMatchPlayerID(id)
|
||||
return mc
|
||||
func (_c *MessagesCreate) SetMatchPlayerID(id int) *MessagesCreate {
|
||||
_c.mutation.SetMatchPlayerID(id)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID if the given value is not nil.
|
||||
func (mc *MessagesCreate) SetNillableMatchPlayerID(id *int) *MessagesCreate {
|
||||
func (_c *MessagesCreate) SetNillableMatchPlayerID(id *int) *MessagesCreate {
|
||||
if id != nil {
|
||||
mc = mc.SetMatchPlayerID(*id)
|
||||
_c = _c.SetMatchPlayerID(*id)
|
||||
}
|
||||
return mc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetMatchPlayer sets the "match_player" edge to the MatchPlayer entity.
|
||||
func (mc *MessagesCreate) SetMatchPlayer(m *MatchPlayer) *MessagesCreate {
|
||||
return mc.SetMatchPlayerID(m.ID)
|
||||
func (_c *MessagesCreate) SetMatchPlayer(v *MatchPlayer) *MessagesCreate {
|
||||
return _c.SetMatchPlayerID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the MessagesMutation object of the builder.
|
||||
func (mc *MessagesCreate) Mutation() *MessagesMutation {
|
||||
return mc.mutation
|
||||
func (_c *MessagesCreate) Mutation() *MessagesMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the Messages in the database.
|
||||
func (mc *MessagesCreate) Save(ctx context.Context) (*Messages, error) {
|
||||
return withHooks(ctx, mc.sqlSave, mc.mutation, mc.hooks)
|
||||
func (_c *MessagesCreate) Save(ctx context.Context) (*Messages, error) {
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (mc *MessagesCreate) SaveX(ctx context.Context) *Messages {
|
||||
v, err := mc.Save(ctx)
|
||||
func (_c *MessagesCreate) SaveX(ctx context.Context) *Messages {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -77,38 +77,38 @@ func (mc *MessagesCreate) SaveX(ctx context.Context) *Messages {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (mc *MessagesCreate) Exec(ctx context.Context) error {
|
||||
_, err := mc.Save(ctx)
|
||||
func (_c *MessagesCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (mc *MessagesCreate) ExecX(ctx context.Context) {
|
||||
if err := mc.Exec(ctx); err != nil {
|
||||
func (_c *MessagesCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (mc *MessagesCreate) check() error {
|
||||
if _, ok := mc.mutation.Message(); !ok {
|
||||
func (_c *MessagesCreate) check() error {
|
||||
if _, ok := _c.mutation.Message(); !ok {
|
||||
return &ValidationError{Name: "message", err: errors.New(`ent: missing required field "Messages.message"`)}
|
||||
}
|
||||
if _, ok := mc.mutation.AllChat(); !ok {
|
||||
if _, ok := _c.mutation.AllChat(); !ok {
|
||||
return &ValidationError{Name: "all_chat", err: errors.New(`ent: missing required field "Messages.all_chat"`)}
|
||||
}
|
||||
if _, ok := mc.mutation.Tick(); !ok {
|
||||
if _, ok := _c.mutation.Tick(); !ok {
|
||||
return &ValidationError{Name: "tick", err: errors.New(`ent: missing required field "Messages.tick"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mc *MessagesCreate) sqlSave(ctx context.Context) (*Messages, error) {
|
||||
if err := mc.check(); err != nil {
|
||||
func (_c *MessagesCreate) sqlSave(ctx context.Context) (*Messages, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := mc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, mc.driver, _spec); err != nil {
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -116,29 +116,29 @@ func (mc *MessagesCreate) sqlSave(ctx context.Context) (*Messages, error) {
|
||||
}
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = int(id)
|
||||
mc.mutation.id = &_node.ID
|
||||
mc.mutation.done = true
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (mc *MessagesCreate) createSpec() (*Messages, *sqlgraph.CreateSpec) {
|
||||
func (_c *MessagesCreate) createSpec() (*Messages, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Messages{config: mc.config}
|
||||
_node = &Messages{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(messages.Table, sqlgraph.NewFieldSpec(messages.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := mc.mutation.Message(); ok {
|
||||
if value, ok := _c.mutation.Message(); ok {
|
||||
_spec.SetField(messages.FieldMessage, field.TypeString, value)
|
||||
_node.Message = value
|
||||
}
|
||||
if value, ok := mc.mutation.AllChat(); ok {
|
||||
if value, ok := _c.mutation.AllChat(); ok {
|
||||
_spec.SetField(messages.FieldAllChat, field.TypeBool, value)
|
||||
_node.AllChat = value
|
||||
}
|
||||
if value, ok := mc.mutation.Tick(); ok {
|
||||
if value, ok := _c.mutation.Tick(); ok {
|
||||
_spec.SetField(messages.FieldTick, field.TypeInt, value)
|
||||
_node.Tick = value
|
||||
}
|
||||
if nodes := mc.mutation.MatchPlayerIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.MatchPlayerIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -161,17 +161,21 @@ func (mc *MessagesCreate) createSpec() (*Messages, *sqlgraph.CreateSpec) {
|
||||
// MessagesCreateBulk is the builder for creating many Messages entities in bulk.
|
||||
type MessagesCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*MessagesCreate
|
||||
}
|
||||
|
||||
// Save creates the Messages entities in the database.
|
||||
func (mcb *MessagesCreateBulk) Save(ctx context.Context) ([]*Messages, error) {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(mcb.builders))
|
||||
nodes := make([]*Messages, len(mcb.builders))
|
||||
mutators := make([]Mutator, len(mcb.builders))
|
||||
for i := range mcb.builders {
|
||||
func (_c *MessagesCreateBulk) Save(ctx context.Context) ([]*Messages, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*Messages, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := mcb.builders[i]
|
||||
builder := _c.builders[i]
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*MessagesMutation)
|
||||
if !ok {
|
||||
@@ -184,11 +188,11 @@ func (mcb *MessagesCreateBulk) Save(ctx context.Context) ([]*Messages, error) {
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, mcb.builders[i+1].mutation)
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, mcb.driver, spec); err != nil {
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -212,7 +216,7 @@ func (mcb *MessagesCreateBulk) Save(ctx context.Context) ([]*Messages, error) {
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, mcb.builders[0].mutation); err != nil {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -220,8 +224,8 @@ func (mcb *MessagesCreateBulk) Save(ctx context.Context) ([]*Messages, error) {
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (mcb *MessagesCreateBulk) SaveX(ctx context.Context) []*Messages {
|
||||
v, err := mcb.Save(ctx)
|
||||
func (_c *MessagesCreateBulk) SaveX(ctx context.Context) []*Messages {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -229,14 +233,14 @@ func (mcb *MessagesCreateBulk) SaveX(ctx context.Context) []*Messages {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (mcb *MessagesCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := mcb.Save(ctx)
|
||||
func (_c *MessagesCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (mcb *MessagesCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := mcb.Exec(ctx); err != nil {
|
||||
func (_c *MessagesCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,56 +20,56 @@ type MessagesDelete struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the MessagesDelete builder.
|
||||
func (md *MessagesDelete) Where(ps ...predicate.Messages) *MessagesDelete {
|
||||
md.mutation.Where(ps...)
|
||||
return md
|
||||
func (_d *MessagesDelete) Where(ps ...predicate.Messages) *MessagesDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (md *MessagesDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, md.sqlExec, md.mutation, md.hooks)
|
||||
func (_d *MessagesDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (md *MessagesDelete) ExecX(ctx context.Context) int {
|
||||
n, err := md.Exec(ctx)
|
||||
func (_d *MessagesDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (md *MessagesDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
func (_d *MessagesDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(messages.Table, sqlgraph.NewFieldSpec(messages.FieldID, field.TypeInt))
|
||||
if ps := md.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, md.driver, _spec)
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
md.mutation.done = true
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// MessagesDeleteOne is the builder for deleting a single Messages entity.
|
||||
type MessagesDeleteOne struct {
|
||||
md *MessagesDelete
|
||||
_d *MessagesDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the MessagesDelete builder.
|
||||
func (mdo *MessagesDeleteOne) Where(ps ...predicate.Messages) *MessagesDeleteOne {
|
||||
mdo.md.mutation.Where(ps...)
|
||||
return mdo
|
||||
func (_d *MessagesDeleteOne) Where(ps ...predicate.Messages) *MessagesDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (mdo *MessagesDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := mdo.md.Exec(ctx)
|
||||
func (_d *MessagesDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
@@ -81,8 +81,8 @@ func (mdo *MessagesDeleteOne) Exec(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (mdo *MessagesDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := mdo.Exec(ctx); err != nil {
|
||||
func (_d *MessagesDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
@@ -31,44 +32,44 @@ type MessagesQuery struct {
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the MessagesQuery builder.
|
||||
func (mq *MessagesQuery) Where(ps ...predicate.Messages) *MessagesQuery {
|
||||
mq.predicates = append(mq.predicates, ps...)
|
||||
return mq
|
||||
func (_q *MessagesQuery) Where(ps ...predicate.Messages) *MessagesQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (mq *MessagesQuery) Limit(limit int) *MessagesQuery {
|
||||
mq.ctx.Limit = &limit
|
||||
return mq
|
||||
func (_q *MessagesQuery) Limit(limit int) *MessagesQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (mq *MessagesQuery) Offset(offset int) *MessagesQuery {
|
||||
mq.ctx.Offset = &offset
|
||||
return mq
|
||||
func (_q *MessagesQuery) Offset(offset int) *MessagesQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (mq *MessagesQuery) Unique(unique bool) *MessagesQuery {
|
||||
mq.ctx.Unique = &unique
|
||||
return mq
|
||||
func (_q *MessagesQuery) Unique(unique bool) *MessagesQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (mq *MessagesQuery) Order(o ...messages.OrderOption) *MessagesQuery {
|
||||
mq.order = append(mq.order, o...)
|
||||
return mq
|
||||
func (_q *MessagesQuery) Order(o ...messages.OrderOption) *MessagesQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryMatchPlayer chains the current query on the "match_player" edge.
|
||||
func (mq *MessagesQuery) QueryMatchPlayer() *MatchPlayerQuery {
|
||||
query := (&MatchPlayerClient{config: mq.config}).Query()
|
||||
func (_q *MessagesQuery) QueryMatchPlayer() *MatchPlayerQuery {
|
||||
query := (&MatchPlayerClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := mq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := mq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -77,7 +78,7 @@ func (mq *MessagesQuery) QueryMatchPlayer() *MatchPlayerQuery {
|
||||
sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, messages.MatchPlayerTable, messages.MatchPlayerColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(mq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
@@ -85,8 +86,8 @@ func (mq *MessagesQuery) QueryMatchPlayer() *MatchPlayerQuery {
|
||||
|
||||
// First returns the first Messages entity from the query.
|
||||
// Returns a *NotFoundError when no Messages was found.
|
||||
func (mq *MessagesQuery) First(ctx context.Context) (*Messages, error) {
|
||||
nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, "First"))
|
||||
func (_q *MessagesQuery) First(ctx context.Context) (*Messages, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -97,8 +98,8 @@ func (mq *MessagesQuery) First(ctx context.Context) (*Messages, error) {
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (mq *MessagesQuery) FirstX(ctx context.Context) *Messages {
|
||||
node, err := mq.First(ctx)
|
||||
func (_q *MessagesQuery) FirstX(ctx context.Context) *Messages {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -107,9 +108,9 @@ func (mq *MessagesQuery) FirstX(ctx context.Context) *Messages {
|
||||
|
||||
// FirstID returns the first Messages ID from the query.
|
||||
// Returns a *NotFoundError when no Messages ID was found.
|
||||
func (mq *MessagesQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
func (_q *MessagesQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, "FirstID")); err != nil {
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
@@ -120,8 +121,8 @@ func (mq *MessagesQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (mq *MessagesQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := mq.FirstID(ctx)
|
||||
func (_q *MessagesQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -131,8 +132,8 @@ func (mq *MessagesQuery) FirstIDX(ctx context.Context) int {
|
||||
// Only returns a single Messages entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one Messages entity is found.
|
||||
// Returns a *NotFoundError when no Messages entities are found.
|
||||
func (mq *MessagesQuery) Only(ctx context.Context) (*Messages, error) {
|
||||
nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, "Only"))
|
||||
func (_q *MessagesQuery) Only(ctx context.Context) (*Messages, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -147,8 +148,8 @@ func (mq *MessagesQuery) Only(ctx context.Context) (*Messages, error) {
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (mq *MessagesQuery) OnlyX(ctx context.Context) *Messages {
|
||||
node, err := mq.Only(ctx)
|
||||
func (_q *MessagesQuery) OnlyX(ctx context.Context) *Messages {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -158,9 +159,9 @@ func (mq *MessagesQuery) OnlyX(ctx context.Context) *Messages {
|
||||
// OnlyID is like Only, but returns the only Messages ID in the query.
|
||||
// Returns a *NotSingularError when more than one Messages ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (mq *MessagesQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
func (_q *MessagesQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, "OnlyID")); err != nil {
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
@@ -175,8 +176,8 @@ func (mq *MessagesQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (mq *MessagesQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := mq.OnlyID(ctx)
|
||||
func (_q *MessagesQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -184,18 +185,18 @@ func (mq *MessagesQuery) OnlyIDX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of MessagesSlice.
|
||||
func (mq *MessagesQuery) All(ctx context.Context) ([]*Messages, error) {
|
||||
ctx = setContextOp(ctx, mq.ctx, "All")
|
||||
if err := mq.prepareQuery(ctx); err != nil {
|
||||
func (_q *MessagesQuery) All(ctx context.Context) ([]*Messages, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*Messages, *MessagesQuery]()
|
||||
return withInterceptors[[]*Messages](ctx, mq, qr, mq.inters)
|
||||
return withInterceptors[[]*Messages](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (mq *MessagesQuery) AllX(ctx context.Context) []*Messages {
|
||||
nodes, err := mq.All(ctx)
|
||||
func (_q *MessagesQuery) AllX(ctx context.Context) []*Messages {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -203,20 +204,20 @@ func (mq *MessagesQuery) AllX(ctx context.Context) []*Messages {
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Messages IDs.
|
||||
func (mq *MessagesQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if mq.ctx.Unique == nil && mq.path != nil {
|
||||
mq.Unique(true)
|
||||
func (_q *MessagesQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, mq.ctx, "IDs")
|
||||
if err = mq.Select(messages.FieldID).Scan(ctx, &ids); err != nil {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(messages.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (mq *MessagesQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := mq.IDs(ctx)
|
||||
func (_q *MessagesQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -224,17 +225,17 @@ func (mq *MessagesQuery) IDsX(ctx context.Context) []int {
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (mq *MessagesQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, mq.ctx, "Count")
|
||||
if err := mq.prepareQuery(ctx); err != nil {
|
||||
func (_q *MessagesQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, mq, querierCount[*MessagesQuery](), mq.inters)
|
||||
return withInterceptors[int](ctx, _q, querierCount[*MessagesQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (mq *MessagesQuery) CountX(ctx context.Context) int {
|
||||
count, err := mq.Count(ctx)
|
||||
func (_q *MessagesQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -242,9 +243,9 @@ func (mq *MessagesQuery) CountX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (mq *MessagesQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, mq.ctx, "Exist")
|
||||
switch _, err := mq.FirstID(ctx); {
|
||||
func (_q *MessagesQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
@@ -255,8 +256,8 @@ func (mq *MessagesQuery) Exist(ctx context.Context) (bool, error) {
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (mq *MessagesQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := mq.Exist(ctx)
|
||||
func (_q *MessagesQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -265,32 +266,33 @@ func (mq *MessagesQuery) ExistX(ctx context.Context) bool {
|
||||
|
||||
// Clone returns a duplicate of the MessagesQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (mq *MessagesQuery) Clone() *MessagesQuery {
|
||||
if mq == nil {
|
||||
func (_q *MessagesQuery) Clone() *MessagesQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &MessagesQuery{
|
||||
config: mq.config,
|
||||
ctx: mq.ctx.Clone(),
|
||||
order: append([]messages.OrderOption{}, mq.order...),
|
||||
inters: append([]Interceptor{}, mq.inters...),
|
||||
predicates: append([]predicate.Messages{}, mq.predicates...),
|
||||
withMatchPlayer: mq.withMatchPlayer.Clone(),
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]messages.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.Messages{}, _q.predicates...),
|
||||
withMatchPlayer: _q.withMatchPlayer.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: mq.sql.Clone(),
|
||||
path: mq.path,
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
modifiers: append([]func(*sql.Selector){}, _q.modifiers...),
|
||||
}
|
||||
}
|
||||
|
||||
// WithMatchPlayer tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "match_player" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (mq *MessagesQuery) WithMatchPlayer(opts ...func(*MatchPlayerQuery)) *MessagesQuery {
|
||||
query := (&MatchPlayerClient{config: mq.config}).Query()
|
||||
func (_q *MessagesQuery) WithMatchPlayer(opts ...func(*MatchPlayerQuery)) *MessagesQuery {
|
||||
query := (&MatchPlayerClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
mq.withMatchPlayer = query
|
||||
return mq
|
||||
_q.withMatchPlayer = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
@@ -307,10 +309,10 @@ func (mq *MessagesQuery) WithMatchPlayer(opts ...func(*MatchPlayerQuery)) *Messa
|
||||
// GroupBy(messages.FieldMessage).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (mq *MessagesQuery) GroupBy(field string, fields ...string) *MessagesGroupBy {
|
||||
mq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &MessagesGroupBy{build: mq}
|
||||
grbuild.flds = &mq.ctx.Fields
|
||||
func (_q *MessagesQuery) GroupBy(field string, fields ...string) *MessagesGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &MessagesGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = messages.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
@@ -328,55 +330,55 @@ func (mq *MessagesQuery) GroupBy(field string, fields ...string) *MessagesGroupB
|
||||
// client.Messages.Query().
|
||||
// Select(messages.FieldMessage).
|
||||
// Scan(ctx, &v)
|
||||
func (mq *MessagesQuery) Select(fields ...string) *MessagesSelect {
|
||||
mq.ctx.Fields = append(mq.ctx.Fields, fields...)
|
||||
sbuild := &MessagesSelect{MessagesQuery: mq}
|
||||
func (_q *MessagesQuery) Select(fields ...string) *MessagesSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &MessagesSelect{MessagesQuery: _q}
|
||||
sbuild.label = messages.Label
|
||||
sbuild.flds, sbuild.scan = &mq.ctx.Fields, sbuild.Scan
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a MessagesSelect configured with the given aggregations.
|
||||
func (mq *MessagesQuery) Aggregate(fns ...AggregateFunc) *MessagesSelect {
|
||||
return mq.Select().Aggregate(fns...)
|
||||
func (_q *MessagesQuery) Aggregate(fns ...AggregateFunc) *MessagesSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (mq *MessagesQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range mq.inters {
|
||||
func (_q *MessagesQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, mq); err != nil {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range mq.ctx.Fields {
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !messages.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if mq.path != nil {
|
||||
prev, err := mq.path(ctx)
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
mq.sql = prev
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mq *MessagesQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Messages, error) {
|
||||
func (_q *MessagesQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Messages, error) {
|
||||
var (
|
||||
nodes = []*Messages{}
|
||||
withFKs = mq.withFKs
|
||||
_spec = mq.querySpec()
|
||||
withFKs = _q.withFKs
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
mq.withMatchPlayer != nil,
|
||||
_q.withMatchPlayer != nil,
|
||||
}
|
||||
)
|
||||
if mq.withMatchPlayer != nil {
|
||||
if _q.withMatchPlayer != nil {
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
@@ -386,25 +388,25 @@ func (mq *MessagesQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Mes
|
||||
return (*Messages).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &Messages{config: mq.config}
|
||||
node := &Messages{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
if len(mq.modifiers) > 0 {
|
||||
_spec.Modifiers = mq.modifiers
|
||||
if len(_q.modifiers) > 0 {
|
||||
_spec.Modifiers = _q.modifiers
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, mq.driver, _spec); err != nil {
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := mq.withMatchPlayer; query != nil {
|
||||
if err := mq.loadMatchPlayer(ctx, query, nodes, nil,
|
||||
if query := _q.withMatchPlayer; query != nil {
|
||||
if err := _q.loadMatchPlayer(ctx, query, nodes, nil,
|
||||
func(n *Messages, e *MatchPlayer) { n.Edges.MatchPlayer = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -412,7 +414,7 @@ func (mq *MessagesQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Mes
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (mq *MessagesQuery) loadMatchPlayer(ctx context.Context, query *MatchPlayerQuery, nodes []*Messages, init func(*Messages), assign func(*Messages, *MatchPlayer)) error {
|
||||
func (_q *MessagesQuery) loadMatchPlayer(ctx context.Context, query *MatchPlayerQuery, nodes []*Messages, init func(*Messages), assign func(*Messages, *MatchPlayer)) error {
|
||||
ids := make([]int, 0, len(nodes))
|
||||
nodeids := make(map[int][]*Messages)
|
||||
for i := range nodes {
|
||||
@@ -445,27 +447,27 @@ func (mq *MessagesQuery) loadMatchPlayer(ctx context.Context, query *MatchPlayer
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mq *MessagesQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := mq.querySpec()
|
||||
if len(mq.modifiers) > 0 {
|
||||
_spec.Modifiers = mq.modifiers
|
||||
func (_q *MessagesQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
if len(_q.modifiers) > 0 {
|
||||
_spec.Modifiers = _q.modifiers
|
||||
}
|
||||
_spec.Node.Columns = mq.ctx.Fields
|
||||
if len(mq.ctx.Fields) > 0 {
|
||||
_spec.Unique = mq.ctx.Unique != nil && *mq.ctx.Unique
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, mq.driver, _spec)
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (mq *MessagesQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
func (_q *MessagesQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(messages.Table, messages.Columns, sqlgraph.NewFieldSpec(messages.FieldID, field.TypeInt))
|
||||
_spec.From = mq.sql
|
||||
if unique := mq.ctx.Unique; unique != nil {
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if mq.path != nil {
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := mq.ctx.Fields; len(fields) > 0 {
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, messages.FieldID)
|
||||
for i := range fields {
|
||||
@@ -474,20 +476,20 @@ func (mq *MessagesQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := mq.predicates; len(ps) > 0 {
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := mq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := mq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := mq.order; len(ps) > 0 {
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
@@ -497,45 +499,45 @@ func (mq *MessagesQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (mq *MessagesQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(mq.driver.Dialect())
|
||||
func (_q *MessagesQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(messages.Table)
|
||||
columns := mq.ctx.Fields
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = messages.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if mq.sql != nil {
|
||||
selector = mq.sql
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if mq.ctx.Unique != nil && *mq.ctx.Unique {
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, m := range mq.modifiers {
|
||||
for _, m := range _q.modifiers {
|
||||
m(selector)
|
||||
}
|
||||
for _, p := range mq.predicates {
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range mq.order {
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := mq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := mq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// Modify adds a query modifier for attaching custom logic to queries.
|
||||
func (mq *MessagesQuery) Modify(modifiers ...func(s *sql.Selector)) *MessagesSelect {
|
||||
mq.modifiers = append(mq.modifiers, modifiers...)
|
||||
return mq.Select()
|
||||
func (_q *MessagesQuery) Modify(modifiers ...func(s *sql.Selector)) *MessagesSelect {
|
||||
_q.modifiers = append(_q.modifiers, modifiers...)
|
||||
return _q.Select()
|
||||
}
|
||||
|
||||
// MessagesGroupBy is the group-by builder for Messages entities.
|
||||
@@ -545,41 +547,41 @@ type MessagesGroupBy struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (mgb *MessagesGroupBy) Aggregate(fns ...AggregateFunc) *MessagesGroupBy {
|
||||
mgb.fns = append(mgb.fns, fns...)
|
||||
return mgb
|
||||
func (_g *MessagesGroupBy) Aggregate(fns ...AggregateFunc) *MessagesGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (mgb *MessagesGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, mgb.build.ctx, "GroupBy")
|
||||
if err := mgb.build.prepareQuery(ctx); err != nil {
|
||||
func (_g *MessagesGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*MessagesQuery, *MessagesGroupBy](ctx, mgb.build, mgb, mgb.build.inters, v)
|
||||
return scanWithInterceptors[*MessagesQuery, *MessagesGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (mgb *MessagesGroupBy) sqlScan(ctx context.Context, root *MessagesQuery, v any) error {
|
||||
func (_g *MessagesGroupBy) sqlScan(ctx context.Context, root *MessagesQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(mgb.fns))
|
||||
for _, fn := range mgb.fns {
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*mgb.flds)+len(mgb.fns))
|
||||
for _, f := range *mgb.flds {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*mgb.flds...)...)
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := mgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -593,27 +595,27 @@ type MessagesSelect struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (ms *MessagesSelect) Aggregate(fns ...AggregateFunc) *MessagesSelect {
|
||||
ms.fns = append(ms.fns, fns...)
|
||||
return ms
|
||||
func (_s *MessagesSelect) Aggregate(fns ...AggregateFunc) *MessagesSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ms *MessagesSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, ms.ctx, "Select")
|
||||
if err := ms.prepareQuery(ctx); err != nil {
|
||||
func (_s *MessagesSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*MessagesQuery, *MessagesSelect](ctx, ms.MessagesQuery, ms, ms.inters, v)
|
||||
return scanWithInterceptors[*MessagesQuery, *MessagesSelect](ctx, _s.MessagesQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (ms *MessagesSelect) sqlScan(ctx context.Context, root *MessagesQuery, v any) error {
|
||||
func (_s *MessagesSelect) sqlScan(ctx context.Context, root *MessagesQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(ms.fns))
|
||||
for _, fn := range ms.fns {
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*ms.selector.flds); {
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
@@ -621,7 +623,7 @@ func (ms *MessagesSelect) sqlScan(ctx context.Context, root *MessagesQuery, v an
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := ms.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -629,7 +631,7 @@ func (ms *MessagesSelect) sqlScan(ctx context.Context, root *MessagesQuery, v an
|
||||
}
|
||||
|
||||
// Modify adds a query modifier for attaching custom logic to queries.
|
||||
func (ms *MessagesSelect) Modify(modifiers ...func(s *sql.Selector)) *MessagesSelect {
|
||||
ms.modifiers = append(ms.modifiers, modifiers...)
|
||||
return ms
|
||||
func (_s *MessagesSelect) Modify(modifiers ...func(s *sql.Selector)) *MessagesSelect {
|
||||
_s.modifiers = append(_s.modifiers, modifiers...)
|
||||
return _s
|
||||
}
|
||||
|
||||
@@ -24,74 +24,98 @@ type MessagesUpdate struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the MessagesUpdate builder.
|
||||
func (mu *MessagesUpdate) Where(ps ...predicate.Messages) *MessagesUpdate {
|
||||
mu.mutation.Where(ps...)
|
||||
return mu
|
||||
func (_u *MessagesUpdate) Where(ps ...predicate.Messages) *MessagesUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetMessage sets the "message" field.
|
||||
func (mu *MessagesUpdate) SetMessage(s string) *MessagesUpdate {
|
||||
mu.mutation.SetMessage(s)
|
||||
return mu
|
||||
func (_u *MessagesUpdate) SetMessage(v string) *MessagesUpdate {
|
||||
_u.mutation.SetMessage(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableMessage sets the "message" field if the given value is not nil.
|
||||
func (_u *MessagesUpdate) SetNillableMessage(v *string) *MessagesUpdate {
|
||||
if v != nil {
|
||||
_u.SetMessage(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetAllChat sets the "all_chat" field.
|
||||
func (mu *MessagesUpdate) SetAllChat(b bool) *MessagesUpdate {
|
||||
mu.mutation.SetAllChat(b)
|
||||
return mu
|
||||
func (_u *MessagesUpdate) SetAllChat(v bool) *MessagesUpdate {
|
||||
_u.mutation.SetAllChat(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableAllChat sets the "all_chat" field if the given value is not nil.
|
||||
func (_u *MessagesUpdate) SetNillableAllChat(v *bool) *MessagesUpdate {
|
||||
if v != nil {
|
||||
_u.SetAllChat(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetTick sets the "tick" field.
|
||||
func (mu *MessagesUpdate) SetTick(i int) *MessagesUpdate {
|
||||
mu.mutation.ResetTick()
|
||||
mu.mutation.SetTick(i)
|
||||
return mu
|
||||
func (_u *MessagesUpdate) SetTick(v int) *MessagesUpdate {
|
||||
_u.mutation.ResetTick()
|
||||
_u.mutation.SetTick(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddTick adds i to the "tick" field.
|
||||
func (mu *MessagesUpdate) AddTick(i int) *MessagesUpdate {
|
||||
mu.mutation.AddTick(i)
|
||||
return mu
|
||||
// SetNillableTick sets the "tick" field if the given value is not nil.
|
||||
func (_u *MessagesUpdate) SetNillableTick(v *int) *MessagesUpdate {
|
||||
if v != nil {
|
||||
_u.SetTick(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddTick adds value to the "tick" field.
|
||||
func (_u *MessagesUpdate) AddTick(v int) *MessagesUpdate {
|
||||
_u.mutation.AddTick(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID.
|
||||
func (mu *MessagesUpdate) SetMatchPlayerID(id int) *MessagesUpdate {
|
||||
mu.mutation.SetMatchPlayerID(id)
|
||||
return mu
|
||||
func (_u *MessagesUpdate) SetMatchPlayerID(id int) *MessagesUpdate {
|
||||
_u.mutation.SetMatchPlayerID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID if the given value is not nil.
|
||||
func (mu *MessagesUpdate) SetNillableMatchPlayerID(id *int) *MessagesUpdate {
|
||||
func (_u *MessagesUpdate) SetNillableMatchPlayerID(id *int) *MessagesUpdate {
|
||||
if id != nil {
|
||||
mu = mu.SetMatchPlayerID(*id)
|
||||
_u = _u.SetMatchPlayerID(*id)
|
||||
}
|
||||
return mu
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetMatchPlayer sets the "match_player" edge to the MatchPlayer entity.
|
||||
func (mu *MessagesUpdate) SetMatchPlayer(m *MatchPlayer) *MessagesUpdate {
|
||||
return mu.SetMatchPlayerID(m.ID)
|
||||
func (_u *MessagesUpdate) SetMatchPlayer(v *MatchPlayer) *MessagesUpdate {
|
||||
return _u.SetMatchPlayerID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the MessagesMutation object of the builder.
|
||||
func (mu *MessagesUpdate) Mutation() *MessagesMutation {
|
||||
return mu.mutation
|
||||
func (_u *MessagesUpdate) Mutation() *MessagesMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearMatchPlayer clears the "match_player" edge to the MatchPlayer entity.
|
||||
func (mu *MessagesUpdate) ClearMatchPlayer() *MessagesUpdate {
|
||||
mu.mutation.ClearMatchPlayer()
|
||||
return mu
|
||||
func (_u *MessagesUpdate) ClearMatchPlayer() *MessagesUpdate {
|
||||
_u.mutation.ClearMatchPlayer()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (mu *MessagesUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, mu.sqlSave, mu.mutation, mu.hooks)
|
||||
func (_u *MessagesUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (mu *MessagesUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := mu.Save(ctx)
|
||||
func (_u *MessagesUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -99,46 +123,46 @@ func (mu *MessagesUpdate) SaveX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (mu *MessagesUpdate) Exec(ctx context.Context) error {
|
||||
_, err := mu.Save(ctx)
|
||||
func (_u *MessagesUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (mu *MessagesUpdate) ExecX(ctx context.Context) {
|
||||
if err := mu.Exec(ctx); err != nil {
|
||||
func (_u *MessagesUpdate) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
||||
func (mu *MessagesUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MessagesUpdate {
|
||||
mu.modifiers = append(mu.modifiers, modifiers...)
|
||||
return mu
|
||||
func (_u *MessagesUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MessagesUpdate {
|
||||
_u.modifiers = append(_u.modifiers, modifiers...)
|
||||
return _u
|
||||
}
|
||||
|
||||
func (mu *MessagesUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
func (_u *MessagesUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(messages.Table, messages.Columns, sqlgraph.NewFieldSpec(messages.FieldID, field.TypeInt))
|
||||
if ps := mu.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := mu.mutation.Message(); ok {
|
||||
if value, ok := _u.mutation.Message(); ok {
|
||||
_spec.SetField(messages.FieldMessage, field.TypeString, value)
|
||||
}
|
||||
if value, ok := mu.mutation.AllChat(); ok {
|
||||
if value, ok := _u.mutation.AllChat(); ok {
|
||||
_spec.SetField(messages.FieldAllChat, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := mu.mutation.Tick(); ok {
|
||||
if value, ok := _u.mutation.Tick(); ok {
|
||||
_spec.SetField(messages.FieldTick, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := mu.mutation.AddedTick(); ok {
|
||||
if value, ok := _u.mutation.AddedTick(); ok {
|
||||
_spec.AddField(messages.FieldTick, field.TypeInt, value)
|
||||
}
|
||||
if mu.mutation.MatchPlayerCleared() {
|
||||
if _u.mutation.MatchPlayerCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -151,7 +175,7 @@ func (mu *MessagesUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := mu.mutation.MatchPlayerIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.MatchPlayerIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -167,8 +191,8 @@ func (mu *MessagesUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_spec.AddModifiers(mu.modifiers...)
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, mu.driver, _spec); err != nil {
|
||||
_spec.AddModifiers(_u.modifiers...)
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{messages.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -176,8 +200,8 @@ func (mu *MessagesUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
mu.mutation.done = true
|
||||
return n, nil
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// MessagesUpdateOne is the builder for updating a single Messages entity.
|
||||
@@ -190,81 +214,105 @@ type MessagesUpdateOne struct {
|
||||
}
|
||||
|
||||
// SetMessage sets the "message" field.
|
||||
func (muo *MessagesUpdateOne) SetMessage(s string) *MessagesUpdateOne {
|
||||
muo.mutation.SetMessage(s)
|
||||
return muo
|
||||
func (_u *MessagesUpdateOne) SetMessage(v string) *MessagesUpdateOne {
|
||||
_u.mutation.SetMessage(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableMessage sets the "message" field if the given value is not nil.
|
||||
func (_u *MessagesUpdateOne) SetNillableMessage(v *string) *MessagesUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetMessage(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetAllChat sets the "all_chat" field.
|
||||
func (muo *MessagesUpdateOne) SetAllChat(b bool) *MessagesUpdateOne {
|
||||
muo.mutation.SetAllChat(b)
|
||||
return muo
|
||||
func (_u *MessagesUpdateOne) SetAllChat(v bool) *MessagesUpdateOne {
|
||||
_u.mutation.SetAllChat(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableAllChat sets the "all_chat" field if the given value is not nil.
|
||||
func (_u *MessagesUpdateOne) SetNillableAllChat(v *bool) *MessagesUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetAllChat(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetTick sets the "tick" field.
|
||||
func (muo *MessagesUpdateOne) SetTick(i int) *MessagesUpdateOne {
|
||||
muo.mutation.ResetTick()
|
||||
muo.mutation.SetTick(i)
|
||||
return muo
|
||||
func (_u *MessagesUpdateOne) SetTick(v int) *MessagesUpdateOne {
|
||||
_u.mutation.ResetTick()
|
||||
_u.mutation.SetTick(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddTick adds i to the "tick" field.
|
||||
func (muo *MessagesUpdateOne) AddTick(i int) *MessagesUpdateOne {
|
||||
muo.mutation.AddTick(i)
|
||||
return muo
|
||||
// SetNillableTick sets the "tick" field if the given value is not nil.
|
||||
func (_u *MessagesUpdateOne) SetNillableTick(v *int) *MessagesUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetTick(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddTick adds value to the "tick" field.
|
||||
func (_u *MessagesUpdateOne) AddTick(v int) *MessagesUpdateOne {
|
||||
_u.mutation.AddTick(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID.
|
||||
func (muo *MessagesUpdateOne) SetMatchPlayerID(id int) *MessagesUpdateOne {
|
||||
muo.mutation.SetMatchPlayerID(id)
|
||||
return muo
|
||||
func (_u *MessagesUpdateOne) SetMatchPlayerID(id int) *MessagesUpdateOne {
|
||||
_u.mutation.SetMatchPlayerID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID if the given value is not nil.
|
||||
func (muo *MessagesUpdateOne) SetNillableMatchPlayerID(id *int) *MessagesUpdateOne {
|
||||
func (_u *MessagesUpdateOne) SetNillableMatchPlayerID(id *int) *MessagesUpdateOne {
|
||||
if id != nil {
|
||||
muo = muo.SetMatchPlayerID(*id)
|
||||
_u = _u.SetMatchPlayerID(*id)
|
||||
}
|
||||
return muo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetMatchPlayer sets the "match_player" edge to the MatchPlayer entity.
|
||||
func (muo *MessagesUpdateOne) SetMatchPlayer(m *MatchPlayer) *MessagesUpdateOne {
|
||||
return muo.SetMatchPlayerID(m.ID)
|
||||
func (_u *MessagesUpdateOne) SetMatchPlayer(v *MatchPlayer) *MessagesUpdateOne {
|
||||
return _u.SetMatchPlayerID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the MessagesMutation object of the builder.
|
||||
func (muo *MessagesUpdateOne) Mutation() *MessagesMutation {
|
||||
return muo.mutation
|
||||
func (_u *MessagesUpdateOne) Mutation() *MessagesMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearMatchPlayer clears the "match_player" edge to the MatchPlayer entity.
|
||||
func (muo *MessagesUpdateOne) ClearMatchPlayer() *MessagesUpdateOne {
|
||||
muo.mutation.ClearMatchPlayer()
|
||||
return muo
|
||||
func (_u *MessagesUpdateOne) ClearMatchPlayer() *MessagesUpdateOne {
|
||||
_u.mutation.ClearMatchPlayer()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the MessagesUpdate builder.
|
||||
func (muo *MessagesUpdateOne) Where(ps ...predicate.Messages) *MessagesUpdateOne {
|
||||
muo.mutation.Where(ps...)
|
||||
return muo
|
||||
func (_u *MessagesUpdateOne) Where(ps ...predicate.Messages) *MessagesUpdateOne {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (muo *MessagesUpdateOne) Select(field string, fields ...string) *MessagesUpdateOne {
|
||||
muo.fields = append([]string{field}, fields...)
|
||||
return muo
|
||||
func (_u *MessagesUpdateOne) Select(field string, fields ...string) *MessagesUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated Messages entity.
|
||||
func (muo *MessagesUpdateOne) Save(ctx context.Context) (*Messages, error) {
|
||||
return withHooks(ctx, muo.sqlSave, muo.mutation, muo.hooks)
|
||||
func (_u *MessagesUpdateOne) Save(ctx context.Context) (*Messages, error) {
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (muo *MessagesUpdateOne) SaveX(ctx context.Context) *Messages {
|
||||
node, err := muo.Save(ctx)
|
||||
func (_u *MessagesUpdateOne) SaveX(ctx context.Context) *Messages {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -272,32 +320,32 @@ func (muo *MessagesUpdateOne) SaveX(ctx context.Context) *Messages {
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (muo *MessagesUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := muo.Save(ctx)
|
||||
func (_u *MessagesUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (muo *MessagesUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := muo.Exec(ctx); err != nil {
|
||||
func (_u *MessagesUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
||||
func (muo *MessagesUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MessagesUpdateOne {
|
||||
muo.modifiers = append(muo.modifiers, modifiers...)
|
||||
return muo
|
||||
func (_u *MessagesUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MessagesUpdateOne {
|
||||
_u.modifiers = append(_u.modifiers, modifiers...)
|
||||
return _u
|
||||
}
|
||||
|
||||
func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err error) {
|
||||
func (_u *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(messages.Table, messages.Columns, sqlgraph.NewFieldSpec(messages.FieldID, field.TypeInt))
|
||||
id, ok := muo.mutation.ID()
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Messages.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := muo.fields; len(fields) > 0 {
|
||||
if fields := _u.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, messages.FieldID)
|
||||
for _, f := range fields {
|
||||
@@ -309,26 +357,26 @@ func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := muo.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := muo.mutation.Message(); ok {
|
||||
if value, ok := _u.mutation.Message(); ok {
|
||||
_spec.SetField(messages.FieldMessage, field.TypeString, value)
|
||||
}
|
||||
if value, ok := muo.mutation.AllChat(); ok {
|
||||
if value, ok := _u.mutation.AllChat(); ok {
|
||||
_spec.SetField(messages.FieldAllChat, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := muo.mutation.Tick(); ok {
|
||||
if value, ok := _u.mutation.Tick(); ok {
|
||||
_spec.SetField(messages.FieldTick, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := muo.mutation.AddedTick(); ok {
|
||||
if value, ok := _u.mutation.AddedTick(); ok {
|
||||
_spec.AddField(messages.FieldTick, field.TypeInt, value)
|
||||
}
|
||||
if muo.mutation.MatchPlayerCleared() {
|
||||
if _u.mutation.MatchPlayerCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -341,7 +389,7 @@ func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := muo.mutation.MatchPlayerIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.MatchPlayerIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -357,11 +405,11 @@ func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_spec.AddModifiers(muo.modifiers...)
|
||||
_node = &Messages{config: muo.config}
|
||||
_spec.AddModifiers(_u.modifiers...)
|
||||
_node = &Messages{config: _u.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, muo.driver, _spec); err != nil {
|
||||
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{messages.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -369,6 +417,6 @@ func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
muo.mutation.done = true
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
@@ -3852,6 +3852,7 @@ func (m *MatchPlayerMutation) SetMatchesID(id uint64) {
|
||||
// ClearMatches clears the "matches" edge to the Match entity.
|
||||
func (m *MatchPlayerMutation) ClearMatches() {
|
||||
m.clearedmatches = true
|
||||
m.clearedFields[matchplayer.FieldMatchStats] = struct{}{}
|
||||
}
|
||||
|
||||
// MatchesCleared reports if the "matches" edge to the Match entity was cleared.
|
||||
@@ -3891,6 +3892,7 @@ func (m *MatchPlayerMutation) SetPlayersID(id uint64) {
|
||||
// ClearPlayers clears the "players" edge to the Player entity.
|
||||
func (m *MatchPlayerMutation) ClearPlayers() {
|
||||
m.clearedplayers = true
|
||||
m.clearedFields[matchplayer.FieldPlayerStats] = struct{}{}
|
||||
}
|
||||
|
||||
// PlayersCleared reports if the "players" edge to the Player entity was cleared.
|
||||
|
||||
@@ -104,7 +104,7 @@ func (*Player) scanValues(columns []string) ([]any, error) {
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Player fields.
|
||||
func (pl *Player) assignValues(columns []string, values []any) error {
|
||||
func (_m *Player) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
@@ -115,105 +115,105 @@ func (pl *Player) assignValues(columns []string, values []any) error {
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
pl.ID = uint64(value.Int64)
|
||||
_m.ID = uint64(value.Int64)
|
||||
case player.FieldName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||
} else if value.Valid {
|
||||
pl.Name = value.String
|
||||
_m.Name = value.String
|
||||
}
|
||||
case player.FieldAvatar:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field avatar", values[i])
|
||||
} else if value.Valid {
|
||||
pl.Avatar = value.String
|
||||
_m.Avatar = value.String
|
||||
}
|
||||
case player.FieldVanityURL:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field vanity_url", values[i])
|
||||
} else if value.Valid {
|
||||
pl.VanityURL = value.String
|
||||
_m.VanityURL = value.String
|
||||
}
|
||||
case player.FieldVanityURLReal:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field vanity_url_real", values[i])
|
||||
} else if value.Valid {
|
||||
pl.VanityURLReal = value.String
|
||||
_m.VanityURLReal = value.String
|
||||
}
|
||||
case player.FieldVacDate:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field vac_date", values[i])
|
||||
} else if value.Valid {
|
||||
pl.VacDate = value.Time
|
||||
_m.VacDate = value.Time
|
||||
}
|
||||
case player.FieldVacCount:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field vac_count", values[i])
|
||||
} else if value.Valid {
|
||||
pl.VacCount = int(value.Int64)
|
||||
_m.VacCount = int(value.Int64)
|
||||
}
|
||||
case player.FieldGameBanDate:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field game_ban_date", values[i])
|
||||
} else if value.Valid {
|
||||
pl.GameBanDate = value.Time
|
||||
_m.GameBanDate = value.Time
|
||||
}
|
||||
case player.FieldGameBanCount:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field game_ban_count", values[i])
|
||||
} else if value.Valid {
|
||||
pl.GameBanCount = int(value.Int64)
|
||||
_m.GameBanCount = int(value.Int64)
|
||||
}
|
||||
case player.FieldSteamUpdated:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field steam_updated", values[i])
|
||||
} else if value.Valid {
|
||||
pl.SteamUpdated = value.Time
|
||||
_m.SteamUpdated = value.Time
|
||||
}
|
||||
case player.FieldSharecodeUpdated:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field sharecode_updated", values[i])
|
||||
} else if value.Valid {
|
||||
pl.SharecodeUpdated = value.Time
|
||||
_m.SharecodeUpdated = value.Time
|
||||
}
|
||||
case player.FieldAuthCode:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field auth_code", values[i])
|
||||
} else if value.Valid {
|
||||
pl.AuthCode = value.String
|
||||
_m.AuthCode = value.String
|
||||
}
|
||||
case player.FieldProfileCreated:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field profile_created", values[i])
|
||||
} else if value.Valid {
|
||||
pl.ProfileCreated = value.Time
|
||||
_m.ProfileCreated = value.Time
|
||||
}
|
||||
case player.FieldOldestSharecodeSeen:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field oldest_sharecode_seen", values[i])
|
||||
} else if value.Valid {
|
||||
pl.OldestSharecodeSeen = value.String
|
||||
_m.OldestSharecodeSeen = value.String
|
||||
}
|
||||
case player.FieldWins:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field wins", values[i])
|
||||
} else if value.Valid {
|
||||
pl.Wins = int(value.Int64)
|
||||
_m.Wins = int(value.Int64)
|
||||
}
|
||||
case player.FieldLooses:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field looses", values[i])
|
||||
} else if value.Valid {
|
||||
pl.Looses = int(value.Int64)
|
||||
_m.Looses = int(value.Int64)
|
||||
}
|
||||
case player.FieldTies:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field ties", values[i])
|
||||
} else if value.Valid {
|
||||
pl.Ties = int(value.Int64)
|
||||
_m.Ties = int(value.Int64)
|
||||
}
|
||||
default:
|
||||
pl.selectValues.Set(columns[i], values[i])
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -221,89 +221,89 @@ func (pl *Player) assignValues(columns []string, values []any) error {
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Player.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (pl *Player) Value(name string) (ent.Value, error) {
|
||||
return pl.selectValues.Get(name)
|
||||
func (_m *Player) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryStats queries the "stats" edge of the Player entity.
|
||||
func (pl *Player) QueryStats() *MatchPlayerQuery {
|
||||
return NewPlayerClient(pl.config).QueryStats(pl)
|
||||
func (_m *Player) QueryStats() *MatchPlayerQuery {
|
||||
return NewPlayerClient(_m.config).QueryStats(_m)
|
||||
}
|
||||
|
||||
// QueryMatches queries the "matches" edge of the Player entity.
|
||||
func (pl *Player) QueryMatches() *MatchQuery {
|
||||
return NewPlayerClient(pl.config).QueryMatches(pl)
|
||||
func (_m *Player) QueryMatches() *MatchQuery {
|
||||
return NewPlayerClient(_m.config).QueryMatches(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Player.
|
||||
// Note that you need to call Player.Unwrap() before calling this method if this Player
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (pl *Player) Update() *PlayerUpdateOne {
|
||||
return NewPlayerClient(pl.config).UpdateOne(pl)
|
||||
func (_m *Player) Update() *PlayerUpdateOne {
|
||||
return NewPlayerClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Player entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (pl *Player) Unwrap() *Player {
|
||||
_tx, ok := pl.config.driver.(*txDriver)
|
||||
func (_m *Player) Unwrap() *Player {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Player is not a transactional entity")
|
||||
}
|
||||
pl.config.driver = _tx.drv
|
||||
return pl
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (pl *Player) String() string {
|
||||
func (_m *Player) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Player(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", pl.ID))
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("name=")
|
||||
builder.WriteString(pl.Name)
|
||||
builder.WriteString(_m.Name)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("avatar=")
|
||||
builder.WriteString(pl.Avatar)
|
||||
builder.WriteString(_m.Avatar)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("vanity_url=")
|
||||
builder.WriteString(pl.VanityURL)
|
||||
builder.WriteString(_m.VanityURL)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("vanity_url_real=")
|
||||
builder.WriteString(pl.VanityURLReal)
|
||||
builder.WriteString(_m.VanityURLReal)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("vac_date=")
|
||||
builder.WriteString(pl.VacDate.Format(time.ANSIC))
|
||||
builder.WriteString(_m.VacDate.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("vac_count=")
|
||||
builder.WriteString(fmt.Sprintf("%v", pl.VacCount))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.VacCount))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("game_ban_date=")
|
||||
builder.WriteString(pl.GameBanDate.Format(time.ANSIC))
|
||||
builder.WriteString(_m.GameBanDate.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("game_ban_count=")
|
||||
builder.WriteString(fmt.Sprintf("%v", pl.GameBanCount))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.GameBanCount))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("steam_updated=")
|
||||
builder.WriteString(pl.SteamUpdated.Format(time.ANSIC))
|
||||
builder.WriteString(_m.SteamUpdated.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("sharecode_updated=")
|
||||
builder.WriteString(pl.SharecodeUpdated.Format(time.ANSIC))
|
||||
builder.WriteString(_m.SharecodeUpdated.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("auth_code=<sensitive>")
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("profile_created=")
|
||||
builder.WriteString(pl.ProfileCreated.Format(time.ANSIC))
|
||||
builder.WriteString(_m.ProfileCreated.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("oldest_sharecode_seen=")
|
||||
builder.WriteString(pl.OldestSharecodeSeen)
|
||||
builder.WriteString(_m.OldestSharecodeSeen)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("wins=")
|
||||
builder.WriteString(fmt.Sprintf("%v", pl.Wins))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Wins))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("looses=")
|
||||
builder.WriteString(fmt.Sprintf("%v", pl.Looses))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Looses))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("ties=")
|
||||
builder.WriteString(fmt.Sprintf("%v", pl.Ties))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Ties))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -1123,32 +1123,15 @@ func HasMatchesWith(preds ...predicate.Match) predicate.Player {
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Player) predicate.Player {
|
||||
return predicate.Player(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for _, p := range predicates {
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
return predicate.Player(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.Player) predicate.Player {
|
||||
return predicate.Player(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for i, p := range predicates {
|
||||
if i > 0 {
|
||||
s1.Or()
|
||||
}
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
return predicate.Player(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.Player) predicate.Player {
|
||||
return predicate.Player(func(s *sql.Selector) {
|
||||
p(s.Not())
|
||||
})
|
||||
return predicate.Player(sql.NotPredicates(p))
|
||||
}
|
||||
|
||||
@@ -23,279 +23,279 @@ type PlayerCreate struct {
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (pc *PlayerCreate) SetName(s string) *PlayerCreate {
|
||||
pc.mutation.SetName(s)
|
||||
return pc
|
||||
func (_c *PlayerCreate) SetName(v string) *PlayerCreate {
|
||||
_c.mutation.SetName(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableName sets the "name" field if the given value is not nil.
|
||||
func (pc *PlayerCreate) SetNillableName(s *string) *PlayerCreate {
|
||||
if s != nil {
|
||||
pc.SetName(*s)
|
||||
func (_c *PlayerCreate) SetNillableName(v *string) *PlayerCreate {
|
||||
if v != nil {
|
||||
_c.SetName(*v)
|
||||
}
|
||||
return pc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetAvatar sets the "avatar" field.
|
||||
func (pc *PlayerCreate) SetAvatar(s string) *PlayerCreate {
|
||||
pc.mutation.SetAvatar(s)
|
||||
return pc
|
||||
func (_c *PlayerCreate) SetAvatar(v string) *PlayerCreate {
|
||||
_c.mutation.SetAvatar(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableAvatar sets the "avatar" field if the given value is not nil.
|
||||
func (pc *PlayerCreate) SetNillableAvatar(s *string) *PlayerCreate {
|
||||
if s != nil {
|
||||
pc.SetAvatar(*s)
|
||||
func (_c *PlayerCreate) SetNillableAvatar(v *string) *PlayerCreate {
|
||||
if v != nil {
|
||||
_c.SetAvatar(*v)
|
||||
}
|
||||
return pc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetVanityURL sets the "vanity_url" field.
|
||||
func (pc *PlayerCreate) SetVanityURL(s string) *PlayerCreate {
|
||||
pc.mutation.SetVanityURL(s)
|
||||
return pc
|
||||
func (_c *PlayerCreate) SetVanityURL(v string) *PlayerCreate {
|
||||
_c.mutation.SetVanityURL(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableVanityURL sets the "vanity_url" field if the given value is not nil.
|
||||
func (pc *PlayerCreate) SetNillableVanityURL(s *string) *PlayerCreate {
|
||||
if s != nil {
|
||||
pc.SetVanityURL(*s)
|
||||
func (_c *PlayerCreate) SetNillableVanityURL(v *string) *PlayerCreate {
|
||||
if v != nil {
|
||||
_c.SetVanityURL(*v)
|
||||
}
|
||||
return pc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetVanityURLReal sets the "vanity_url_real" field.
|
||||
func (pc *PlayerCreate) SetVanityURLReal(s string) *PlayerCreate {
|
||||
pc.mutation.SetVanityURLReal(s)
|
||||
return pc
|
||||
func (_c *PlayerCreate) SetVanityURLReal(v string) *PlayerCreate {
|
||||
_c.mutation.SetVanityURLReal(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableVanityURLReal sets the "vanity_url_real" field if the given value is not nil.
|
||||
func (pc *PlayerCreate) SetNillableVanityURLReal(s *string) *PlayerCreate {
|
||||
if s != nil {
|
||||
pc.SetVanityURLReal(*s)
|
||||
func (_c *PlayerCreate) SetNillableVanityURLReal(v *string) *PlayerCreate {
|
||||
if v != nil {
|
||||
_c.SetVanityURLReal(*v)
|
||||
}
|
||||
return pc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetVacDate sets the "vac_date" field.
|
||||
func (pc *PlayerCreate) SetVacDate(t time.Time) *PlayerCreate {
|
||||
pc.mutation.SetVacDate(t)
|
||||
return pc
|
||||
func (_c *PlayerCreate) SetVacDate(v time.Time) *PlayerCreate {
|
||||
_c.mutation.SetVacDate(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableVacDate sets the "vac_date" field if the given value is not nil.
|
||||
func (pc *PlayerCreate) SetNillableVacDate(t *time.Time) *PlayerCreate {
|
||||
if t != nil {
|
||||
pc.SetVacDate(*t)
|
||||
func (_c *PlayerCreate) SetNillableVacDate(v *time.Time) *PlayerCreate {
|
||||
if v != nil {
|
||||
_c.SetVacDate(*v)
|
||||
}
|
||||
return pc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetVacCount sets the "vac_count" field.
|
||||
func (pc *PlayerCreate) SetVacCount(i int) *PlayerCreate {
|
||||
pc.mutation.SetVacCount(i)
|
||||
return pc
|
||||
func (_c *PlayerCreate) SetVacCount(v int) *PlayerCreate {
|
||||
_c.mutation.SetVacCount(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableVacCount sets the "vac_count" field if the given value is not nil.
|
||||
func (pc *PlayerCreate) SetNillableVacCount(i *int) *PlayerCreate {
|
||||
if i != nil {
|
||||
pc.SetVacCount(*i)
|
||||
func (_c *PlayerCreate) SetNillableVacCount(v *int) *PlayerCreate {
|
||||
if v != nil {
|
||||
_c.SetVacCount(*v)
|
||||
}
|
||||
return pc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetGameBanDate sets the "game_ban_date" field.
|
||||
func (pc *PlayerCreate) SetGameBanDate(t time.Time) *PlayerCreate {
|
||||
pc.mutation.SetGameBanDate(t)
|
||||
return pc
|
||||
func (_c *PlayerCreate) SetGameBanDate(v time.Time) *PlayerCreate {
|
||||
_c.mutation.SetGameBanDate(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableGameBanDate sets the "game_ban_date" field if the given value is not nil.
|
||||
func (pc *PlayerCreate) SetNillableGameBanDate(t *time.Time) *PlayerCreate {
|
||||
if t != nil {
|
||||
pc.SetGameBanDate(*t)
|
||||
func (_c *PlayerCreate) SetNillableGameBanDate(v *time.Time) *PlayerCreate {
|
||||
if v != nil {
|
||||
_c.SetGameBanDate(*v)
|
||||
}
|
||||
return pc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetGameBanCount sets the "game_ban_count" field.
|
||||
func (pc *PlayerCreate) SetGameBanCount(i int) *PlayerCreate {
|
||||
pc.mutation.SetGameBanCount(i)
|
||||
return pc
|
||||
func (_c *PlayerCreate) SetGameBanCount(v int) *PlayerCreate {
|
||||
_c.mutation.SetGameBanCount(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableGameBanCount sets the "game_ban_count" field if the given value is not nil.
|
||||
func (pc *PlayerCreate) SetNillableGameBanCount(i *int) *PlayerCreate {
|
||||
if i != nil {
|
||||
pc.SetGameBanCount(*i)
|
||||
func (_c *PlayerCreate) SetNillableGameBanCount(v *int) *PlayerCreate {
|
||||
if v != nil {
|
||||
_c.SetGameBanCount(*v)
|
||||
}
|
||||
return pc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetSteamUpdated sets the "steam_updated" field.
|
||||
func (pc *PlayerCreate) SetSteamUpdated(t time.Time) *PlayerCreate {
|
||||
pc.mutation.SetSteamUpdated(t)
|
||||
return pc
|
||||
func (_c *PlayerCreate) SetSteamUpdated(v time.Time) *PlayerCreate {
|
||||
_c.mutation.SetSteamUpdated(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableSteamUpdated sets the "steam_updated" field if the given value is not nil.
|
||||
func (pc *PlayerCreate) SetNillableSteamUpdated(t *time.Time) *PlayerCreate {
|
||||
if t != nil {
|
||||
pc.SetSteamUpdated(*t)
|
||||
func (_c *PlayerCreate) SetNillableSteamUpdated(v *time.Time) *PlayerCreate {
|
||||
if v != nil {
|
||||
_c.SetSteamUpdated(*v)
|
||||
}
|
||||
return pc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetSharecodeUpdated sets the "sharecode_updated" field.
|
||||
func (pc *PlayerCreate) SetSharecodeUpdated(t time.Time) *PlayerCreate {
|
||||
pc.mutation.SetSharecodeUpdated(t)
|
||||
return pc
|
||||
func (_c *PlayerCreate) SetSharecodeUpdated(v time.Time) *PlayerCreate {
|
||||
_c.mutation.SetSharecodeUpdated(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableSharecodeUpdated sets the "sharecode_updated" field if the given value is not nil.
|
||||
func (pc *PlayerCreate) SetNillableSharecodeUpdated(t *time.Time) *PlayerCreate {
|
||||
if t != nil {
|
||||
pc.SetSharecodeUpdated(*t)
|
||||
func (_c *PlayerCreate) SetNillableSharecodeUpdated(v *time.Time) *PlayerCreate {
|
||||
if v != nil {
|
||||
_c.SetSharecodeUpdated(*v)
|
||||
}
|
||||
return pc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetAuthCode sets the "auth_code" field.
|
||||
func (pc *PlayerCreate) SetAuthCode(s string) *PlayerCreate {
|
||||
pc.mutation.SetAuthCode(s)
|
||||
return pc
|
||||
func (_c *PlayerCreate) SetAuthCode(v string) *PlayerCreate {
|
||||
_c.mutation.SetAuthCode(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableAuthCode sets the "auth_code" field if the given value is not nil.
|
||||
func (pc *PlayerCreate) SetNillableAuthCode(s *string) *PlayerCreate {
|
||||
if s != nil {
|
||||
pc.SetAuthCode(*s)
|
||||
func (_c *PlayerCreate) SetNillableAuthCode(v *string) *PlayerCreate {
|
||||
if v != nil {
|
||||
_c.SetAuthCode(*v)
|
||||
}
|
||||
return pc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetProfileCreated sets the "profile_created" field.
|
||||
func (pc *PlayerCreate) SetProfileCreated(t time.Time) *PlayerCreate {
|
||||
pc.mutation.SetProfileCreated(t)
|
||||
return pc
|
||||
func (_c *PlayerCreate) SetProfileCreated(v time.Time) *PlayerCreate {
|
||||
_c.mutation.SetProfileCreated(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableProfileCreated sets the "profile_created" field if the given value is not nil.
|
||||
func (pc *PlayerCreate) SetNillableProfileCreated(t *time.Time) *PlayerCreate {
|
||||
if t != nil {
|
||||
pc.SetProfileCreated(*t)
|
||||
func (_c *PlayerCreate) SetNillableProfileCreated(v *time.Time) *PlayerCreate {
|
||||
if v != nil {
|
||||
_c.SetProfileCreated(*v)
|
||||
}
|
||||
return pc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetOldestSharecodeSeen sets the "oldest_sharecode_seen" field.
|
||||
func (pc *PlayerCreate) SetOldestSharecodeSeen(s string) *PlayerCreate {
|
||||
pc.mutation.SetOldestSharecodeSeen(s)
|
||||
return pc
|
||||
func (_c *PlayerCreate) SetOldestSharecodeSeen(v string) *PlayerCreate {
|
||||
_c.mutation.SetOldestSharecodeSeen(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableOldestSharecodeSeen sets the "oldest_sharecode_seen" field if the given value is not nil.
|
||||
func (pc *PlayerCreate) SetNillableOldestSharecodeSeen(s *string) *PlayerCreate {
|
||||
if s != nil {
|
||||
pc.SetOldestSharecodeSeen(*s)
|
||||
func (_c *PlayerCreate) SetNillableOldestSharecodeSeen(v *string) *PlayerCreate {
|
||||
if v != nil {
|
||||
_c.SetOldestSharecodeSeen(*v)
|
||||
}
|
||||
return pc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetWins sets the "wins" field.
|
||||
func (pc *PlayerCreate) SetWins(i int) *PlayerCreate {
|
||||
pc.mutation.SetWins(i)
|
||||
return pc
|
||||
func (_c *PlayerCreate) SetWins(v int) *PlayerCreate {
|
||||
_c.mutation.SetWins(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableWins sets the "wins" field if the given value is not nil.
|
||||
func (pc *PlayerCreate) SetNillableWins(i *int) *PlayerCreate {
|
||||
if i != nil {
|
||||
pc.SetWins(*i)
|
||||
func (_c *PlayerCreate) SetNillableWins(v *int) *PlayerCreate {
|
||||
if v != nil {
|
||||
_c.SetWins(*v)
|
||||
}
|
||||
return pc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetLooses sets the "looses" field.
|
||||
func (pc *PlayerCreate) SetLooses(i int) *PlayerCreate {
|
||||
pc.mutation.SetLooses(i)
|
||||
return pc
|
||||
func (_c *PlayerCreate) SetLooses(v int) *PlayerCreate {
|
||||
_c.mutation.SetLooses(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableLooses sets the "looses" field if the given value is not nil.
|
||||
func (pc *PlayerCreate) SetNillableLooses(i *int) *PlayerCreate {
|
||||
if i != nil {
|
||||
pc.SetLooses(*i)
|
||||
func (_c *PlayerCreate) SetNillableLooses(v *int) *PlayerCreate {
|
||||
if v != nil {
|
||||
_c.SetLooses(*v)
|
||||
}
|
||||
return pc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetTies sets the "ties" field.
|
||||
func (pc *PlayerCreate) SetTies(i int) *PlayerCreate {
|
||||
pc.mutation.SetTies(i)
|
||||
return pc
|
||||
func (_c *PlayerCreate) SetTies(v int) *PlayerCreate {
|
||||
_c.mutation.SetTies(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableTies sets the "ties" field if the given value is not nil.
|
||||
func (pc *PlayerCreate) SetNillableTies(i *int) *PlayerCreate {
|
||||
if i != nil {
|
||||
pc.SetTies(*i)
|
||||
func (_c *PlayerCreate) SetNillableTies(v *int) *PlayerCreate {
|
||||
if v != nil {
|
||||
_c.SetTies(*v)
|
||||
}
|
||||
return pc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetID sets the "id" field.
|
||||
func (pc *PlayerCreate) SetID(u uint64) *PlayerCreate {
|
||||
pc.mutation.SetID(u)
|
||||
return pc
|
||||
func (_c *PlayerCreate) SetID(v uint64) *PlayerCreate {
|
||||
_c.mutation.SetID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs.
|
||||
func (pc *PlayerCreate) AddStatIDs(ids ...int) *PlayerCreate {
|
||||
pc.mutation.AddStatIDs(ids...)
|
||||
return pc
|
||||
func (_c *PlayerCreate) AddStatIDs(ids ...int) *PlayerCreate {
|
||||
_c.mutation.AddStatIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddStats adds the "stats" edges to the MatchPlayer entity.
|
||||
func (pc *PlayerCreate) AddStats(m ...*MatchPlayer) *PlayerCreate {
|
||||
ids := make([]int, len(m))
|
||||
for i := range m {
|
||||
ids[i] = m[i].ID
|
||||
func (_c *PlayerCreate) AddStats(v ...*MatchPlayer) *PlayerCreate {
|
||||
ids := make([]int, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return pc.AddStatIDs(ids...)
|
||||
return _c.AddStatIDs(ids...)
|
||||
}
|
||||
|
||||
// AddMatchIDs adds the "matches" edge to the Match entity by IDs.
|
||||
func (pc *PlayerCreate) AddMatchIDs(ids ...uint64) *PlayerCreate {
|
||||
pc.mutation.AddMatchIDs(ids...)
|
||||
return pc
|
||||
func (_c *PlayerCreate) AddMatchIDs(ids ...uint64) *PlayerCreate {
|
||||
_c.mutation.AddMatchIDs(ids...)
|
||||
return _c
|
||||
}
|
||||
|
||||
// AddMatches adds the "matches" edges to the Match entity.
|
||||
func (pc *PlayerCreate) AddMatches(m ...*Match) *PlayerCreate {
|
||||
ids := make([]uint64, len(m))
|
||||
for i := range m {
|
||||
ids[i] = m[i].ID
|
||||
func (_c *PlayerCreate) AddMatches(v ...*Match) *PlayerCreate {
|
||||
ids := make([]uint64, len(v))
|
||||
for i := range v {
|
||||
ids[i] = v[i].ID
|
||||
}
|
||||
return pc.AddMatchIDs(ids...)
|
||||
return _c.AddMatchIDs(ids...)
|
||||
}
|
||||
|
||||
// Mutation returns the PlayerMutation object of the builder.
|
||||
func (pc *PlayerCreate) Mutation() *PlayerMutation {
|
||||
return pc.mutation
|
||||
func (_c *PlayerCreate) Mutation() *PlayerMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the Player in the database.
|
||||
func (pc *PlayerCreate) Save(ctx context.Context) (*Player, error) {
|
||||
pc.defaults()
|
||||
return withHooks(ctx, pc.sqlSave, pc.mutation, pc.hooks)
|
||||
func (_c *PlayerCreate) Save(ctx context.Context) (*Player, error) {
|
||||
_c.defaults()
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (pc *PlayerCreate) SaveX(ctx context.Context) *Player {
|
||||
v, err := pc.Save(ctx)
|
||||
func (_c *PlayerCreate) SaveX(ctx context.Context) *Player {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -303,40 +303,40 @@ func (pc *PlayerCreate) SaveX(ctx context.Context) *Player {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (pc *PlayerCreate) Exec(ctx context.Context) error {
|
||||
_, err := pc.Save(ctx)
|
||||
func (_c *PlayerCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (pc *PlayerCreate) ExecX(ctx context.Context) {
|
||||
if err := pc.Exec(ctx); err != nil {
|
||||
func (_c *PlayerCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (pc *PlayerCreate) defaults() {
|
||||
if _, ok := pc.mutation.SteamUpdated(); !ok {
|
||||
func (_c *PlayerCreate) defaults() {
|
||||
if _, ok := _c.mutation.SteamUpdated(); !ok {
|
||||
v := player.DefaultSteamUpdated()
|
||||
pc.mutation.SetSteamUpdated(v)
|
||||
_c.mutation.SetSteamUpdated(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (pc *PlayerCreate) check() error {
|
||||
if _, ok := pc.mutation.SteamUpdated(); !ok {
|
||||
func (_c *PlayerCreate) check() error {
|
||||
if _, ok := _c.mutation.SteamUpdated(); !ok {
|
||||
return &ValidationError{Name: "steam_updated", err: errors.New(`ent: missing required field "Player.steam_updated"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pc *PlayerCreate) sqlSave(ctx context.Context) (*Player, error) {
|
||||
if err := pc.check(); err != nil {
|
||||
func (_c *PlayerCreate) sqlSave(ctx context.Context) (*Player, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := pc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, pc.driver, _spec); err != nil {
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -346,85 +346,85 @@ func (pc *PlayerCreate) sqlSave(ctx context.Context) (*Player, error) {
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = uint64(id)
|
||||
}
|
||||
pc.mutation.id = &_node.ID
|
||||
pc.mutation.done = true
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (pc *PlayerCreate) createSpec() (*Player, *sqlgraph.CreateSpec) {
|
||||
func (_c *PlayerCreate) createSpec() (*Player, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Player{config: pc.config}
|
||||
_node = &Player{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(player.Table, sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64))
|
||||
)
|
||||
if id, ok := pc.mutation.ID(); ok {
|
||||
if id, ok := _c.mutation.ID(); ok {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = id
|
||||
}
|
||||
if value, ok := pc.mutation.Name(); ok {
|
||||
if value, ok := _c.mutation.Name(); ok {
|
||||
_spec.SetField(player.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
}
|
||||
if value, ok := pc.mutation.Avatar(); ok {
|
||||
if value, ok := _c.mutation.Avatar(); ok {
|
||||
_spec.SetField(player.FieldAvatar, field.TypeString, value)
|
||||
_node.Avatar = value
|
||||
}
|
||||
if value, ok := pc.mutation.VanityURL(); ok {
|
||||
if value, ok := _c.mutation.VanityURL(); ok {
|
||||
_spec.SetField(player.FieldVanityURL, field.TypeString, value)
|
||||
_node.VanityURL = value
|
||||
}
|
||||
if value, ok := pc.mutation.VanityURLReal(); ok {
|
||||
if value, ok := _c.mutation.VanityURLReal(); ok {
|
||||
_spec.SetField(player.FieldVanityURLReal, field.TypeString, value)
|
||||
_node.VanityURLReal = value
|
||||
}
|
||||
if value, ok := pc.mutation.VacDate(); ok {
|
||||
if value, ok := _c.mutation.VacDate(); ok {
|
||||
_spec.SetField(player.FieldVacDate, field.TypeTime, value)
|
||||
_node.VacDate = value
|
||||
}
|
||||
if value, ok := pc.mutation.VacCount(); ok {
|
||||
if value, ok := _c.mutation.VacCount(); ok {
|
||||
_spec.SetField(player.FieldVacCount, field.TypeInt, value)
|
||||
_node.VacCount = value
|
||||
}
|
||||
if value, ok := pc.mutation.GameBanDate(); ok {
|
||||
if value, ok := _c.mutation.GameBanDate(); ok {
|
||||
_spec.SetField(player.FieldGameBanDate, field.TypeTime, value)
|
||||
_node.GameBanDate = value
|
||||
}
|
||||
if value, ok := pc.mutation.GameBanCount(); ok {
|
||||
if value, ok := _c.mutation.GameBanCount(); ok {
|
||||
_spec.SetField(player.FieldGameBanCount, field.TypeInt, value)
|
||||
_node.GameBanCount = value
|
||||
}
|
||||
if value, ok := pc.mutation.SteamUpdated(); ok {
|
||||
if value, ok := _c.mutation.SteamUpdated(); ok {
|
||||
_spec.SetField(player.FieldSteamUpdated, field.TypeTime, value)
|
||||
_node.SteamUpdated = value
|
||||
}
|
||||
if value, ok := pc.mutation.SharecodeUpdated(); ok {
|
||||
if value, ok := _c.mutation.SharecodeUpdated(); ok {
|
||||
_spec.SetField(player.FieldSharecodeUpdated, field.TypeTime, value)
|
||||
_node.SharecodeUpdated = value
|
||||
}
|
||||
if value, ok := pc.mutation.AuthCode(); ok {
|
||||
if value, ok := _c.mutation.AuthCode(); ok {
|
||||
_spec.SetField(player.FieldAuthCode, field.TypeString, value)
|
||||
_node.AuthCode = value
|
||||
}
|
||||
if value, ok := pc.mutation.ProfileCreated(); ok {
|
||||
if value, ok := _c.mutation.ProfileCreated(); ok {
|
||||
_spec.SetField(player.FieldProfileCreated, field.TypeTime, value)
|
||||
_node.ProfileCreated = value
|
||||
}
|
||||
if value, ok := pc.mutation.OldestSharecodeSeen(); ok {
|
||||
if value, ok := _c.mutation.OldestSharecodeSeen(); ok {
|
||||
_spec.SetField(player.FieldOldestSharecodeSeen, field.TypeString, value)
|
||||
_node.OldestSharecodeSeen = value
|
||||
}
|
||||
if value, ok := pc.mutation.Wins(); ok {
|
||||
if value, ok := _c.mutation.Wins(); ok {
|
||||
_spec.SetField(player.FieldWins, field.TypeInt, value)
|
||||
_node.Wins = value
|
||||
}
|
||||
if value, ok := pc.mutation.Looses(); ok {
|
||||
if value, ok := _c.mutation.Looses(); ok {
|
||||
_spec.SetField(player.FieldLooses, field.TypeInt, value)
|
||||
_node.Looses = value
|
||||
}
|
||||
if value, ok := pc.mutation.Ties(); ok {
|
||||
if value, ok := _c.mutation.Ties(); ok {
|
||||
_spec.SetField(player.FieldTies, field.TypeInt, value)
|
||||
_node.Ties = value
|
||||
}
|
||||
if nodes := pc.mutation.StatsIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.StatsIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.O2M,
|
||||
Inverse: false,
|
||||
@@ -440,7 +440,7 @@ func (pc *PlayerCreate) createSpec() (*Player, *sqlgraph.CreateSpec) {
|
||||
}
|
||||
_spec.Edges = append(_spec.Edges, edge)
|
||||
}
|
||||
if nodes := pc.mutation.MatchesIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.MatchesIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2M,
|
||||
Inverse: false,
|
||||
@@ -462,17 +462,21 @@ func (pc *PlayerCreate) createSpec() (*Player, *sqlgraph.CreateSpec) {
|
||||
// PlayerCreateBulk is the builder for creating many Player entities in bulk.
|
||||
type PlayerCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*PlayerCreate
|
||||
}
|
||||
|
||||
// Save creates the Player entities in the database.
|
||||
func (pcb *PlayerCreateBulk) Save(ctx context.Context) ([]*Player, error) {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(pcb.builders))
|
||||
nodes := make([]*Player, len(pcb.builders))
|
||||
mutators := make([]Mutator, len(pcb.builders))
|
||||
for i := range pcb.builders {
|
||||
func (_c *PlayerCreateBulk) Save(ctx context.Context) ([]*Player, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*Player, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := pcb.builders[i]
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*PlayerMutation)
|
||||
@@ -486,11 +490,11 @@ func (pcb *PlayerCreateBulk) Save(ctx context.Context) ([]*Player, error) {
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, pcb.builders[i+1].mutation)
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, pcb.driver, spec); err != nil {
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -514,7 +518,7 @@ func (pcb *PlayerCreateBulk) Save(ctx context.Context) ([]*Player, error) {
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, pcb.builders[0].mutation); err != nil {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -522,8 +526,8 @@ func (pcb *PlayerCreateBulk) Save(ctx context.Context) ([]*Player, error) {
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (pcb *PlayerCreateBulk) SaveX(ctx context.Context) []*Player {
|
||||
v, err := pcb.Save(ctx)
|
||||
func (_c *PlayerCreateBulk) SaveX(ctx context.Context) []*Player {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -531,14 +535,14 @@ func (pcb *PlayerCreateBulk) SaveX(ctx context.Context) []*Player {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (pcb *PlayerCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := pcb.Save(ctx)
|
||||
func (_c *PlayerCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (pcb *PlayerCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := pcb.Exec(ctx); err != nil {
|
||||
func (_c *PlayerCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,56 +20,56 @@ type PlayerDelete struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the PlayerDelete builder.
|
||||
func (pd *PlayerDelete) Where(ps ...predicate.Player) *PlayerDelete {
|
||||
pd.mutation.Where(ps...)
|
||||
return pd
|
||||
func (_d *PlayerDelete) Where(ps ...predicate.Player) *PlayerDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (pd *PlayerDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, pd.sqlExec, pd.mutation, pd.hooks)
|
||||
func (_d *PlayerDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (pd *PlayerDelete) ExecX(ctx context.Context) int {
|
||||
n, err := pd.Exec(ctx)
|
||||
func (_d *PlayerDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (pd *PlayerDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
func (_d *PlayerDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(player.Table, sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64))
|
||||
if ps := pd.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, pd.driver, _spec)
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
pd.mutation.done = true
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// PlayerDeleteOne is the builder for deleting a single Player entity.
|
||||
type PlayerDeleteOne struct {
|
||||
pd *PlayerDelete
|
||||
_d *PlayerDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the PlayerDelete builder.
|
||||
func (pdo *PlayerDeleteOne) Where(ps ...predicate.Player) *PlayerDeleteOne {
|
||||
pdo.pd.mutation.Where(ps...)
|
||||
return pdo
|
||||
func (_d *PlayerDeleteOne) Where(ps ...predicate.Player) *PlayerDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (pdo *PlayerDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := pdo.pd.Exec(ctx)
|
||||
func (_d *PlayerDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
@@ -81,8 +81,8 @@ func (pdo *PlayerDeleteOne) Exec(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (pdo *PlayerDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := pdo.Exec(ctx); err != nil {
|
||||
func (_d *PlayerDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
@@ -33,44 +34,44 @@ type PlayerQuery struct {
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the PlayerQuery builder.
|
||||
func (pq *PlayerQuery) Where(ps ...predicate.Player) *PlayerQuery {
|
||||
pq.predicates = append(pq.predicates, ps...)
|
||||
return pq
|
||||
func (_q *PlayerQuery) Where(ps ...predicate.Player) *PlayerQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (pq *PlayerQuery) Limit(limit int) *PlayerQuery {
|
||||
pq.ctx.Limit = &limit
|
||||
return pq
|
||||
func (_q *PlayerQuery) Limit(limit int) *PlayerQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (pq *PlayerQuery) Offset(offset int) *PlayerQuery {
|
||||
pq.ctx.Offset = &offset
|
||||
return pq
|
||||
func (_q *PlayerQuery) Offset(offset int) *PlayerQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (pq *PlayerQuery) Unique(unique bool) *PlayerQuery {
|
||||
pq.ctx.Unique = &unique
|
||||
return pq
|
||||
func (_q *PlayerQuery) Unique(unique bool) *PlayerQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (pq *PlayerQuery) Order(o ...player.OrderOption) *PlayerQuery {
|
||||
pq.order = append(pq.order, o...)
|
||||
return pq
|
||||
func (_q *PlayerQuery) Order(o ...player.OrderOption) *PlayerQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryStats chains the current query on the "stats" edge.
|
||||
func (pq *PlayerQuery) QueryStats() *MatchPlayerQuery {
|
||||
query := (&MatchPlayerClient{config: pq.config}).Query()
|
||||
func (_q *PlayerQuery) QueryStats() *MatchPlayerQuery {
|
||||
query := (&MatchPlayerClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := pq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := pq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -79,20 +80,20 @@ func (pq *PlayerQuery) QueryStats() *MatchPlayerQuery {
|
||||
sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.O2M, false, player.StatsTable, player.StatsColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(pq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
// QueryMatches chains the current query on the "matches" edge.
|
||||
func (pq *PlayerQuery) QueryMatches() *MatchQuery {
|
||||
query := (&MatchClient{config: pq.config}).Query()
|
||||
func (_q *PlayerQuery) QueryMatches() *MatchQuery {
|
||||
query := (&MatchClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := pq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := pq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -101,7 +102,7 @@ func (pq *PlayerQuery) QueryMatches() *MatchQuery {
|
||||
sqlgraph.To(match.Table, match.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2M, false, player.MatchesTable, player.MatchesPrimaryKey...),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(pq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
@@ -109,8 +110,8 @@ func (pq *PlayerQuery) QueryMatches() *MatchQuery {
|
||||
|
||||
// First returns the first Player entity from the query.
|
||||
// Returns a *NotFoundError when no Player was found.
|
||||
func (pq *PlayerQuery) First(ctx context.Context) (*Player, error) {
|
||||
nodes, err := pq.Limit(1).All(setContextOp(ctx, pq.ctx, "First"))
|
||||
func (_q *PlayerQuery) First(ctx context.Context) (*Player, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -121,8 +122,8 @@ func (pq *PlayerQuery) First(ctx context.Context) (*Player, error) {
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (pq *PlayerQuery) FirstX(ctx context.Context) *Player {
|
||||
node, err := pq.First(ctx)
|
||||
func (_q *PlayerQuery) FirstX(ctx context.Context) *Player {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -131,9 +132,9 @@ func (pq *PlayerQuery) FirstX(ctx context.Context) *Player {
|
||||
|
||||
// FirstID returns the first Player ID from the query.
|
||||
// Returns a *NotFoundError when no Player ID was found.
|
||||
func (pq *PlayerQuery) FirstID(ctx context.Context) (id uint64, err error) {
|
||||
func (_q *PlayerQuery) FirstID(ctx context.Context) (id uint64, err error) {
|
||||
var ids []uint64
|
||||
if ids, err = pq.Limit(1).IDs(setContextOp(ctx, pq.ctx, "FirstID")); err != nil {
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
@@ -144,8 +145,8 @@ func (pq *PlayerQuery) FirstID(ctx context.Context) (id uint64, err error) {
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (pq *PlayerQuery) FirstIDX(ctx context.Context) uint64 {
|
||||
id, err := pq.FirstID(ctx)
|
||||
func (_q *PlayerQuery) FirstIDX(ctx context.Context) uint64 {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -155,8 +156,8 @@ func (pq *PlayerQuery) FirstIDX(ctx context.Context) uint64 {
|
||||
// Only returns a single Player entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one Player entity is found.
|
||||
// Returns a *NotFoundError when no Player entities are found.
|
||||
func (pq *PlayerQuery) Only(ctx context.Context) (*Player, error) {
|
||||
nodes, err := pq.Limit(2).All(setContextOp(ctx, pq.ctx, "Only"))
|
||||
func (_q *PlayerQuery) Only(ctx context.Context) (*Player, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -171,8 +172,8 @@ func (pq *PlayerQuery) Only(ctx context.Context) (*Player, error) {
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (pq *PlayerQuery) OnlyX(ctx context.Context) *Player {
|
||||
node, err := pq.Only(ctx)
|
||||
func (_q *PlayerQuery) OnlyX(ctx context.Context) *Player {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -182,9 +183,9 @@ func (pq *PlayerQuery) OnlyX(ctx context.Context) *Player {
|
||||
// OnlyID is like Only, but returns the only Player ID in the query.
|
||||
// Returns a *NotSingularError when more than one Player ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (pq *PlayerQuery) OnlyID(ctx context.Context) (id uint64, err error) {
|
||||
func (_q *PlayerQuery) OnlyID(ctx context.Context) (id uint64, err error) {
|
||||
var ids []uint64
|
||||
if ids, err = pq.Limit(2).IDs(setContextOp(ctx, pq.ctx, "OnlyID")); err != nil {
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
@@ -199,8 +200,8 @@ func (pq *PlayerQuery) OnlyID(ctx context.Context) (id uint64, err error) {
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (pq *PlayerQuery) OnlyIDX(ctx context.Context) uint64 {
|
||||
id, err := pq.OnlyID(ctx)
|
||||
func (_q *PlayerQuery) OnlyIDX(ctx context.Context) uint64 {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -208,18 +209,18 @@ func (pq *PlayerQuery) OnlyIDX(ctx context.Context) uint64 {
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of Players.
|
||||
func (pq *PlayerQuery) All(ctx context.Context) ([]*Player, error) {
|
||||
ctx = setContextOp(ctx, pq.ctx, "All")
|
||||
if err := pq.prepareQuery(ctx); err != nil {
|
||||
func (_q *PlayerQuery) All(ctx context.Context) ([]*Player, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*Player, *PlayerQuery]()
|
||||
return withInterceptors[[]*Player](ctx, pq, qr, pq.inters)
|
||||
return withInterceptors[[]*Player](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (pq *PlayerQuery) AllX(ctx context.Context) []*Player {
|
||||
nodes, err := pq.All(ctx)
|
||||
func (_q *PlayerQuery) AllX(ctx context.Context) []*Player {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -227,20 +228,20 @@ func (pq *PlayerQuery) AllX(ctx context.Context) []*Player {
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Player IDs.
|
||||
func (pq *PlayerQuery) IDs(ctx context.Context) (ids []uint64, err error) {
|
||||
if pq.ctx.Unique == nil && pq.path != nil {
|
||||
pq.Unique(true)
|
||||
func (_q *PlayerQuery) IDs(ctx context.Context) (ids []uint64, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, pq.ctx, "IDs")
|
||||
if err = pq.Select(player.FieldID).Scan(ctx, &ids); err != nil {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(player.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (pq *PlayerQuery) IDsX(ctx context.Context) []uint64 {
|
||||
ids, err := pq.IDs(ctx)
|
||||
func (_q *PlayerQuery) IDsX(ctx context.Context) []uint64 {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -248,17 +249,17 @@ func (pq *PlayerQuery) IDsX(ctx context.Context) []uint64 {
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (pq *PlayerQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, pq.ctx, "Count")
|
||||
if err := pq.prepareQuery(ctx); err != nil {
|
||||
func (_q *PlayerQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, pq, querierCount[*PlayerQuery](), pq.inters)
|
||||
return withInterceptors[int](ctx, _q, querierCount[*PlayerQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (pq *PlayerQuery) CountX(ctx context.Context) int {
|
||||
count, err := pq.Count(ctx)
|
||||
func (_q *PlayerQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -266,9 +267,9 @@ func (pq *PlayerQuery) CountX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (pq *PlayerQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, pq.ctx, "Exist")
|
||||
switch _, err := pq.FirstID(ctx); {
|
||||
func (_q *PlayerQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
@@ -279,8 +280,8 @@ func (pq *PlayerQuery) Exist(ctx context.Context) (bool, error) {
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (pq *PlayerQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := pq.Exist(ctx)
|
||||
func (_q *PlayerQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -289,44 +290,45 @@ func (pq *PlayerQuery) ExistX(ctx context.Context) bool {
|
||||
|
||||
// Clone returns a duplicate of the PlayerQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (pq *PlayerQuery) Clone() *PlayerQuery {
|
||||
if pq == nil {
|
||||
func (_q *PlayerQuery) Clone() *PlayerQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &PlayerQuery{
|
||||
config: pq.config,
|
||||
ctx: pq.ctx.Clone(),
|
||||
order: append([]player.OrderOption{}, pq.order...),
|
||||
inters: append([]Interceptor{}, pq.inters...),
|
||||
predicates: append([]predicate.Player{}, pq.predicates...),
|
||||
withStats: pq.withStats.Clone(),
|
||||
withMatches: pq.withMatches.Clone(),
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]player.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.Player{}, _q.predicates...),
|
||||
withStats: _q.withStats.Clone(),
|
||||
withMatches: _q.withMatches.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: pq.sql.Clone(),
|
||||
path: pq.path,
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
modifiers: append([]func(*sql.Selector){}, _q.modifiers...),
|
||||
}
|
||||
}
|
||||
|
||||
// WithStats tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "stats" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (pq *PlayerQuery) WithStats(opts ...func(*MatchPlayerQuery)) *PlayerQuery {
|
||||
query := (&MatchPlayerClient{config: pq.config}).Query()
|
||||
func (_q *PlayerQuery) WithStats(opts ...func(*MatchPlayerQuery)) *PlayerQuery {
|
||||
query := (&MatchPlayerClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
pq.withStats = query
|
||||
return pq
|
||||
_q.withStats = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// WithMatches tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "matches" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (pq *PlayerQuery) WithMatches(opts ...func(*MatchQuery)) *PlayerQuery {
|
||||
query := (&MatchClient{config: pq.config}).Query()
|
||||
func (_q *PlayerQuery) WithMatches(opts ...func(*MatchQuery)) *PlayerQuery {
|
||||
query := (&MatchClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
pq.withMatches = query
|
||||
return pq
|
||||
_q.withMatches = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
@@ -343,10 +345,10 @@ func (pq *PlayerQuery) WithMatches(opts ...func(*MatchQuery)) *PlayerQuery {
|
||||
// GroupBy(player.FieldName).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (pq *PlayerQuery) GroupBy(field string, fields ...string) *PlayerGroupBy {
|
||||
pq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &PlayerGroupBy{build: pq}
|
||||
grbuild.flds = &pq.ctx.Fields
|
||||
func (_q *PlayerQuery) GroupBy(field string, fields ...string) *PlayerGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &PlayerGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = player.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
@@ -364,84 +366,84 @@ func (pq *PlayerQuery) GroupBy(field string, fields ...string) *PlayerGroupBy {
|
||||
// client.Player.Query().
|
||||
// Select(player.FieldName).
|
||||
// Scan(ctx, &v)
|
||||
func (pq *PlayerQuery) Select(fields ...string) *PlayerSelect {
|
||||
pq.ctx.Fields = append(pq.ctx.Fields, fields...)
|
||||
sbuild := &PlayerSelect{PlayerQuery: pq}
|
||||
func (_q *PlayerQuery) Select(fields ...string) *PlayerSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &PlayerSelect{PlayerQuery: _q}
|
||||
sbuild.label = player.Label
|
||||
sbuild.flds, sbuild.scan = &pq.ctx.Fields, sbuild.Scan
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a PlayerSelect configured with the given aggregations.
|
||||
func (pq *PlayerQuery) Aggregate(fns ...AggregateFunc) *PlayerSelect {
|
||||
return pq.Select().Aggregate(fns...)
|
||||
func (_q *PlayerQuery) Aggregate(fns ...AggregateFunc) *PlayerSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (pq *PlayerQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range pq.inters {
|
||||
func (_q *PlayerQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, pq); err != nil {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range pq.ctx.Fields {
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !player.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if pq.path != nil {
|
||||
prev, err := pq.path(ctx)
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pq.sql = prev
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pq *PlayerQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Player, error) {
|
||||
func (_q *PlayerQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Player, error) {
|
||||
var (
|
||||
nodes = []*Player{}
|
||||
_spec = pq.querySpec()
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [2]bool{
|
||||
pq.withStats != nil,
|
||||
pq.withMatches != nil,
|
||||
_q.withStats != nil,
|
||||
_q.withMatches != nil,
|
||||
}
|
||||
)
|
||||
_spec.ScanValues = func(columns []string) ([]any, error) {
|
||||
return (*Player).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &Player{config: pq.config}
|
||||
node := &Player{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
if len(pq.modifiers) > 0 {
|
||||
_spec.Modifiers = pq.modifiers
|
||||
if len(_q.modifiers) > 0 {
|
||||
_spec.Modifiers = _q.modifiers
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, pq.driver, _spec); err != nil {
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := pq.withStats; query != nil {
|
||||
if err := pq.loadStats(ctx, query, nodes,
|
||||
if query := _q.withStats; query != nil {
|
||||
if err := _q.loadStats(ctx, query, nodes,
|
||||
func(n *Player) { n.Edges.Stats = []*MatchPlayer{} },
|
||||
func(n *Player, e *MatchPlayer) { n.Edges.Stats = append(n.Edges.Stats, e) }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if query := pq.withMatches; query != nil {
|
||||
if err := pq.loadMatches(ctx, query, nodes,
|
||||
if query := _q.withMatches; query != nil {
|
||||
if err := _q.loadMatches(ctx, query, nodes,
|
||||
func(n *Player) { n.Edges.Matches = []*Match{} },
|
||||
func(n *Player, e *Match) { n.Edges.Matches = append(n.Edges.Matches, e) }); err != nil {
|
||||
return nil, err
|
||||
@@ -450,7 +452,7 @@ func (pq *PlayerQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Playe
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (pq *PlayerQuery) loadStats(ctx context.Context, query *MatchPlayerQuery, nodes []*Player, init func(*Player), assign func(*Player, *MatchPlayer)) error {
|
||||
func (_q *PlayerQuery) loadStats(ctx context.Context, query *MatchPlayerQuery, nodes []*Player, init func(*Player), assign func(*Player, *MatchPlayer)) error {
|
||||
fks := make([]driver.Value, 0, len(nodes))
|
||||
nodeids := make(map[uint64]*Player)
|
||||
for i := range nodes {
|
||||
@@ -480,7 +482,7 @@ func (pq *PlayerQuery) loadStats(ctx context.Context, query *MatchPlayerQuery, n
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (pq *PlayerQuery) loadMatches(ctx context.Context, query *MatchQuery, nodes []*Player, init func(*Player), assign func(*Player, *Match)) error {
|
||||
func (_q *PlayerQuery) loadMatches(ctx context.Context, query *MatchQuery, nodes []*Player, init func(*Player), assign func(*Player, *Match)) error {
|
||||
edgeIDs := make([]driver.Value, len(nodes))
|
||||
byID := make(map[uint64]*Player)
|
||||
nids := make(map[uint64]map[*Player]struct{})
|
||||
@@ -542,27 +544,27 @@ func (pq *PlayerQuery) loadMatches(ctx context.Context, query *MatchQuery, nodes
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pq *PlayerQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := pq.querySpec()
|
||||
if len(pq.modifiers) > 0 {
|
||||
_spec.Modifiers = pq.modifiers
|
||||
func (_q *PlayerQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
if len(_q.modifiers) > 0 {
|
||||
_spec.Modifiers = _q.modifiers
|
||||
}
|
||||
_spec.Node.Columns = pq.ctx.Fields
|
||||
if len(pq.ctx.Fields) > 0 {
|
||||
_spec.Unique = pq.ctx.Unique != nil && *pq.ctx.Unique
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, pq.driver, _spec)
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (pq *PlayerQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
func (_q *PlayerQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(player.Table, player.Columns, sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64))
|
||||
_spec.From = pq.sql
|
||||
if unique := pq.ctx.Unique; unique != nil {
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if pq.path != nil {
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := pq.ctx.Fields; len(fields) > 0 {
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, player.FieldID)
|
||||
for i := range fields {
|
||||
@@ -571,20 +573,20 @@ func (pq *PlayerQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := pq.predicates; len(ps) > 0 {
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := pq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := pq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := pq.order; len(ps) > 0 {
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
@@ -594,45 +596,45 @@ func (pq *PlayerQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (pq *PlayerQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(pq.driver.Dialect())
|
||||
func (_q *PlayerQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(player.Table)
|
||||
columns := pq.ctx.Fields
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = player.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if pq.sql != nil {
|
||||
selector = pq.sql
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if pq.ctx.Unique != nil && *pq.ctx.Unique {
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, m := range pq.modifiers {
|
||||
for _, m := range _q.modifiers {
|
||||
m(selector)
|
||||
}
|
||||
for _, p := range pq.predicates {
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range pq.order {
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := pq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := pq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// Modify adds a query modifier for attaching custom logic to queries.
|
||||
func (pq *PlayerQuery) Modify(modifiers ...func(s *sql.Selector)) *PlayerSelect {
|
||||
pq.modifiers = append(pq.modifiers, modifiers...)
|
||||
return pq.Select()
|
||||
func (_q *PlayerQuery) Modify(modifiers ...func(s *sql.Selector)) *PlayerSelect {
|
||||
_q.modifiers = append(_q.modifiers, modifiers...)
|
||||
return _q.Select()
|
||||
}
|
||||
|
||||
// PlayerGroupBy is the group-by builder for Player entities.
|
||||
@@ -642,41 +644,41 @@ type PlayerGroupBy struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (pgb *PlayerGroupBy) Aggregate(fns ...AggregateFunc) *PlayerGroupBy {
|
||||
pgb.fns = append(pgb.fns, fns...)
|
||||
return pgb
|
||||
func (_g *PlayerGroupBy) Aggregate(fns ...AggregateFunc) *PlayerGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (pgb *PlayerGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, pgb.build.ctx, "GroupBy")
|
||||
if err := pgb.build.prepareQuery(ctx); err != nil {
|
||||
func (_g *PlayerGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*PlayerQuery, *PlayerGroupBy](ctx, pgb.build, pgb, pgb.build.inters, v)
|
||||
return scanWithInterceptors[*PlayerQuery, *PlayerGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (pgb *PlayerGroupBy) sqlScan(ctx context.Context, root *PlayerQuery, v any) error {
|
||||
func (_g *PlayerGroupBy) sqlScan(ctx context.Context, root *PlayerQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(pgb.fns))
|
||||
for _, fn := range pgb.fns {
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*pgb.flds)+len(pgb.fns))
|
||||
for _, f := range *pgb.flds {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*pgb.flds...)...)
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := pgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -690,27 +692,27 @@ type PlayerSelect struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (ps *PlayerSelect) Aggregate(fns ...AggregateFunc) *PlayerSelect {
|
||||
ps.fns = append(ps.fns, fns...)
|
||||
return ps
|
||||
func (_s *PlayerSelect) Aggregate(fns ...AggregateFunc) *PlayerSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ps *PlayerSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, ps.ctx, "Select")
|
||||
if err := ps.prepareQuery(ctx); err != nil {
|
||||
func (_s *PlayerSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*PlayerQuery, *PlayerSelect](ctx, ps.PlayerQuery, ps, ps.inters, v)
|
||||
return scanWithInterceptors[*PlayerQuery, *PlayerSelect](ctx, _s.PlayerQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (ps *PlayerSelect) sqlScan(ctx context.Context, root *PlayerQuery, v any) error {
|
||||
func (_s *PlayerSelect) sqlScan(ctx context.Context, root *PlayerQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(ps.fns))
|
||||
for _, fn := range ps.fns {
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*ps.selector.flds); {
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
@@ -718,7 +720,7 @@ func (ps *PlayerSelect) sqlScan(ctx context.Context, root *PlayerQuery, v any) e
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := ps.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -726,7 +728,7 @@ func (ps *PlayerSelect) sqlScan(ctx context.Context, root *PlayerQuery, v any) e
|
||||
}
|
||||
|
||||
// Modify adds a query modifier for attaching custom logic to queries.
|
||||
func (ps *PlayerSelect) Modify(modifiers ...func(s *sql.Selector)) *PlayerSelect {
|
||||
ps.modifiers = append(ps.modifiers, modifiers...)
|
||||
return ps
|
||||
func (_s *PlayerSelect) Modify(modifiers ...func(s *sql.Selector)) *PlayerSelect {
|
||||
_s.modifiers = append(_s.modifiers, modifiers...)
|
||||
return _s
|
||||
}
|
||||
|
||||
1146
ent/player_update.go
1146
ent/player_update.go
File diff suppressed because it is too large
Load Diff
@@ -44,12 +44,10 @@ type RoundStatsEdges struct {
|
||||
// MatchPlayerOrErr returns the MatchPlayer value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e RoundStatsEdges) MatchPlayerOrErr() (*MatchPlayer, error) {
|
||||
if e.loadedTypes[0] {
|
||||
if e.MatchPlayer == nil {
|
||||
// Edge was loaded but was not found.
|
||||
return nil, &NotFoundError{label: matchplayer.Label}
|
||||
}
|
||||
if e.MatchPlayer != nil {
|
||||
return e.MatchPlayer, nil
|
||||
} else if e.loadedTypes[0] {
|
||||
return nil, &NotFoundError{label: matchplayer.Label}
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "match_player"}
|
||||
}
|
||||
@@ -72,7 +70,7 @@ func (*RoundStats) scanValues(columns []string) ([]any, error) {
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the RoundStats fields.
|
||||
func (rs *RoundStats) assignValues(columns []string, values []any) error {
|
||||
func (_m *RoundStats) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
@@ -83,40 +81,40 @@ func (rs *RoundStats) assignValues(columns []string, values []any) error {
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
rs.ID = int(value.Int64)
|
||||
_m.ID = int(value.Int64)
|
||||
case roundstats.FieldRound:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field round", values[i])
|
||||
} else if value.Valid {
|
||||
rs.Round = uint(value.Int64)
|
||||
_m.Round = uint(value.Int64)
|
||||
}
|
||||
case roundstats.FieldBank:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field bank", values[i])
|
||||
} else if value.Valid {
|
||||
rs.Bank = uint(value.Int64)
|
||||
_m.Bank = uint(value.Int64)
|
||||
}
|
||||
case roundstats.FieldEquipment:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field equipment", values[i])
|
||||
} else if value.Valid {
|
||||
rs.Equipment = uint(value.Int64)
|
||||
_m.Equipment = uint(value.Int64)
|
||||
}
|
||||
case roundstats.FieldSpent:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field spent", values[i])
|
||||
} else if value.Valid {
|
||||
rs.Spent = uint(value.Int64)
|
||||
_m.Spent = uint(value.Int64)
|
||||
}
|
||||
case roundstats.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for edge-field match_player_round_stats", value)
|
||||
} else if value.Valid {
|
||||
rs.match_player_round_stats = new(int)
|
||||
*rs.match_player_round_stats = int(value.Int64)
|
||||
_m.match_player_round_stats = new(int)
|
||||
*_m.match_player_round_stats = int(value.Int64)
|
||||
}
|
||||
default:
|
||||
rs.selectValues.Set(columns[i], values[i])
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -124,49 +122,49 @@ func (rs *RoundStats) assignValues(columns []string, values []any) error {
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the RoundStats.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (rs *RoundStats) Value(name string) (ent.Value, error) {
|
||||
return rs.selectValues.Get(name)
|
||||
func (_m *RoundStats) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryMatchPlayer queries the "match_player" edge of the RoundStats entity.
|
||||
func (rs *RoundStats) QueryMatchPlayer() *MatchPlayerQuery {
|
||||
return NewRoundStatsClient(rs.config).QueryMatchPlayer(rs)
|
||||
func (_m *RoundStats) QueryMatchPlayer() *MatchPlayerQuery {
|
||||
return NewRoundStatsClient(_m.config).QueryMatchPlayer(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this RoundStats.
|
||||
// Note that you need to call RoundStats.Unwrap() before calling this method if this RoundStats
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (rs *RoundStats) Update() *RoundStatsUpdateOne {
|
||||
return NewRoundStatsClient(rs.config).UpdateOne(rs)
|
||||
func (_m *RoundStats) Update() *RoundStatsUpdateOne {
|
||||
return NewRoundStatsClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the RoundStats entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (rs *RoundStats) Unwrap() *RoundStats {
|
||||
_tx, ok := rs.config.driver.(*txDriver)
|
||||
func (_m *RoundStats) Unwrap() *RoundStats {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: RoundStats is not a transactional entity")
|
||||
}
|
||||
rs.config.driver = _tx.drv
|
||||
return rs
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (rs *RoundStats) String() string {
|
||||
func (_m *RoundStats) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("RoundStats(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", rs.ID))
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("round=")
|
||||
builder.WriteString(fmt.Sprintf("%v", rs.Round))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Round))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("bank=")
|
||||
builder.WriteString(fmt.Sprintf("%v", rs.Bank))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Bank))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("equipment=")
|
||||
builder.WriteString(fmt.Sprintf("%v", rs.Equipment))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Equipment))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("spent=")
|
||||
builder.WriteString(fmt.Sprintf("%v", rs.Spent))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Spent))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -258,32 +258,15 @@ func HasMatchPlayerWith(preds ...predicate.MatchPlayer) predicate.RoundStats {
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.RoundStats) predicate.RoundStats {
|
||||
return predicate.RoundStats(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for _, p := range predicates {
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
return predicate.RoundStats(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.RoundStats) predicate.RoundStats {
|
||||
return predicate.RoundStats(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for i, p := range predicates {
|
||||
if i > 0 {
|
||||
s1.Or()
|
||||
}
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
return predicate.RoundStats(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.RoundStats) predicate.RoundStats {
|
||||
return predicate.RoundStats(func(s *sql.Selector) {
|
||||
p(s.Not())
|
||||
})
|
||||
return predicate.RoundStats(sql.NotPredicates(p))
|
||||
}
|
||||
|
||||
@@ -21,61 +21,61 @@ type RoundStatsCreate struct {
|
||||
}
|
||||
|
||||
// SetRound sets the "round" field.
|
||||
func (rsc *RoundStatsCreate) SetRound(u uint) *RoundStatsCreate {
|
||||
rsc.mutation.SetRound(u)
|
||||
return rsc
|
||||
func (_c *RoundStatsCreate) SetRound(v uint) *RoundStatsCreate {
|
||||
_c.mutation.SetRound(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetBank sets the "bank" field.
|
||||
func (rsc *RoundStatsCreate) SetBank(u uint) *RoundStatsCreate {
|
||||
rsc.mutation.SetBank(u)
|
||||
return rsc
|
||||
func (_c *RoundStatsCreate) SetBank(v uint) *RoundStatsCreate {
|
||||
_c.mutation.SetBank(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetEquipment sets the "equipment" field.
|
||||
func (rsc *RoundStatsCreate) SetEquipment(u uint) *RoundStatsCreate {
|
||||
rsc.mutation.SetEquipment(u)
|
||||
return rsc
|
||||
func (_c *RoundStatsCreate) SetEquipment(v uint) *RoundStatsCreate {
|
||||
_c.mutation.SetEquipment(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetSpent sets the "spent" field.
|
||||
func (rsc *RoundStatsCreate) SetSpent(u uint) *RoundStatsCreate {
|
||||
rsc.mutation.SetSpent(u)
|
||||
return rsc
|
||||
func (_c *RoundStatsCreate) SetSpent(v uint) *RoundStatsCreate {
|
||||
_c.mutation.SetSpent(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID.
|
||||
func (rsc *RoundStatsCreate) SetMatchPlayerID(id int) *RoundStatsCreate {
|
||||
rsc.mutation.SetMatchPlayerID(id)
|
||||
return rsc
|
||||
func (_c *RoundStatsCreate) SetMatchPlayerID(id int) *RoundStatsCreate {
|
||||
_c.mutation.SetMatchPlayerID(id)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID if the given value is not nil.
|
||||
func (rsc *RoundStatsCreate) SetNillableMatchPlayerID(id *int) *RoundStatsCreate {
|
||||
func (_c *RoundStatsCreate) SetNillableMatchPlayerID(id *int) *RoundStatsCreate {
|
||||
if id != nil {
|
||||
rsc = rsc.SetMatchPlayerID(*id)
|
||||
_c = _c.SetMatchPlayerID(*id)
|
||||
}
|
||||
return rsc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetMatchPlayer sets the "match_player" edge to the MatchPlayer entity.
|
||||
func (rsc *RoundStatsCreate) SetMatchPlayer(m *MatchPlayer) *RoundStatsCreate {
|
||||
return rsc.SetMatchPlayerID(m.ID)
|
||||
func (_c *RoundStatsCreate) SetMatchPlayer(v *MatchPlayer) *RoundStatsCreate {
|
||||
return _c.SetMatchPlayerID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the RoundStatsMutation object of the builder.
|
||||
func (rsc *RoundStatsCreate) Mutation() *RoundStatsMutation {
|
||||
return rsc.mutation
|
||||
func (_c *RoundStatsCreate) Mutation() *RoundStatsMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the RoundStats in the database.
|
||||
func (rsc *RoundStatsCreate) Save(ctx context.Context) (*RoundStats, error) {
|
||||
return withHooks(ctx, rsc.sqlSave, rsc.mutation, rsc.hooks)
|
||||
func (_c *RoundStatsCreate) Save(ctx context.Context) (*RoundStats, error) {
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (rsc *RoundStatsCreate) SaveX(ctx context.Context) *RoundStats {
|
||||
v, err := rsc.Save(ctx)
|
||||
func (_c *RoundStatsCreate) SaveX(ctx context.Context) *RoundStats {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -83,41 +83,41 @@ func (rsc *RoundStatsCreate) SaveX(ctx context.Context) *RoundStats {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (rsc *RoundStatsCreate) Exec(ctx context.Context) error {
|
||||
_, err := rsc.Save(ctx)
|
||||
func (_c *RoundStatsCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (rsc *RoundStatsCreate) ExecX(ctx context.Context) {
|
||||
if err := rsc.Exec(ctx); err != nil {
|
||||
func (_c *RoundStatsCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (rsc *RoundStatsCreate) check() error {
|
||||
if _, ok := rsc.mutation.Round(); !ok {
|
||||
func (_c *RoundStatsCreate) check() error {
|
||||
if _, ok := _c.mutation.Round(); !ok {
|
||||
return &ValidationError{Name: "round", err: errors.New(`ent: missing required field "RoundStats.round"`)}
|
||||
}
|
||||
if _, ok := rsc.mutation.Bank(); !ok {
|
||||
if _, ok := _c.mutation.Bank(); !ok {
|
||||
return &ValidationError{Name: "bank", err: errors.New(`ent: missing required field "RoundStats.bank"`)}
|
||||
}
|
||||
if _, ok := rsc.mutation.Equipment(); !ok {
|
||||
if _, ok := _c.mutation.Equipment(); !ok {
|
||||
return &ValidationError{Name: "equipment", err: errors.New(`ent: missing required field "RoundStats.equipment"`)}
|
||||
}
|
||||
if _, ok := rsc.mutation.Spent(); !ok {
|
||||
if _, ok := _c.mutation.Spent(); !ok {
|
||||
return &ValidationError{Name: "spent", err: errors.New(`ent: missing required field "RoundStats.spent"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rsc *RoundStatsCreate) sqlSave(ctx context.Context) (*RoundStats, error) {
|
||||
if err := rsc.check(); err != nil {
|
||||
func (_c *RoundStatsCreate) sqlSave(ctx context.Context) (*RoundStats, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := rsc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, rsc.driver, _spec); err != nil {
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -125,33 +125,33 @@ func (rsc *RoundStatsCreate) sqlSave(ctx context.Context) (*RoundStats, error) {
|
||||
}
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = int(id)
|
||||
rsc.mutation.id = &_node.ID
|
||||
rsc.mutation.done = true
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (rsc *RoundStatsCreate) createSpec() (*RoundStats, *sqlgraph.CreateSpec) {
|
||||
func (_c *RoundStatsCreate) createSpec() (*RoundStats, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &RoundStats{config: rsc.config}
|
||||
_node = &RoundStats{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(roundstats.Table, sqlgraph.NewFieldSpec(roundstats.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := rsc.mutation.Round(); ok {
|
||||
if value, ok := _c.mutation.Round(); ok {
|
||||
_spec.SetField(roundstats.FieldRound, field.TypeUint, value)
|
||||
_node.Round = value
|
||||
}
|
||||
if value, ok := rsc.mutation.Bank(); ok {
|
||||
if value, ok := _c.mutation.Bank(); ok {
|
||||
_spec.SetField(roundstats.FieldBank, field.TypeUint, value)
|
||||
_node.Bank = value
|
||||
}
|
||||
if value, ok := rsc.mutation.Equipment(); ok {
|
||||
if value, ok := _c.mutation.Equipment(); ok {
|
||||
_spec.SetField(roundstats.FieldEquipment, field.TypeUint, value)
|
||||
_node.Equipment = value
|
||||
}
|
||||
if value, ok := rsc.mutation.Spent(); ok {
|
||||
if value, ok := _c.mutation.Spent(); ok {
|
||||
_spec.SetField(roundstats.FieldSpent, field.TypeUint, value)
|
||||
_node.Spent = value
|
||||
}
|
||||
if nodes := rsc.mutation.MatchPlayerIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.MatchPlayerIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -174,17 +174,21 @@ func (rsc *RoundStatsCreate) createSpec() (*RoundStats, *sqlgraph.CreateSpec) {
|
||||
// RoundStatsCreateBulk is the builder for creating many RoundStats entities in bulk.
|
||||
type RoundStatsCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*RoundStatsCreate
|
||||
}
|
||||
|
||||
// Save creates the RoundStats entities in the database.
|
||||
func (rscb *RoundStatsCreateBulk) Save(ctx context.Context) ([]*RoundStats, error) {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(rscb.builders))
|
||||
nodes := make([]*RoundStats, len(rscb.builders))
|
||||
mutators := make([]Mutator, len(rscb.builders))
|
||||
for i := range rscb.builders {
|
||||
func (_c *RoundStatsCreateBulk) Save(ctx context.Context) ([]*RoundStats, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*RoundStats, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := rscb.builders[i]
|
||||
builder := _c.builders[i]
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*RoundStatsMutation)
|
||||
if !ok {
|
||||
@@ -197,11 +201,11 @@ func (rscb *RoundStatsCreateBulk) Save(ctx context.Context) ([]*RoundStats, erro
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, rscb.builders[i+1].mutation)
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, rscb.driver, spec); err != nil {
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -225,7 +229,7 @@ func (rscb *RoundStatsCreateBulk) Save(ctx context.Context) ([]*RoundStats, erro
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, rscb.builders[0].mutation); err != nil {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -233,8 +237,8 @@ func (rscb *RoundStatsCreateBulk) Save(ctx context.Context) ([]*RoundStats, erro
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (rscb *RoundStatsCreateBulk) SaveX(ctx context.Context) []*RoundStats {
|
||||
v, err := rscb.Save(ctx)
|
||||
func (_c *RoundStatsCreateBulk) SaveX(ctx context.Context) []*RoundStats {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -242,14 +246,14 @@ func (rscb *RoundStatsCreateBulk) SaveX(ctx context.Context) []*RoundStats {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (rscb *RoundStatsCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := rscb.Save(ctx)
|
||||
func (_c *RoundStatsCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (rscb *RoundStatsCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := rscb.Exec(ctx); err != nil {
|
||||
func (_c *RoundStatsCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,56 +20,56 @@ type RoundStatsDelete struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the RoundStatsDelete builder.
|
||||
func (rsd *RoundStatsDelete) Where(ps ...predicate.RoundStats) *RoundStatsDelete {
|
||||
rsd.mutation.Where(ps...)
|
||||
return rsd
|
||||
func (_d *RoundStatsDelete) Where(ps ...predicate.RoundStats) *RoundStatsDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (rsd *RoundStatsDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, rsd.sqlExec, rsd.mutation, rsd.hooks)
|
||||
func (_d *RoundStatsDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (rsd *RoundStatsDelete) ExecX(ctx context.Context) int {
|
||||
n, err := rsd.Exec(ctx)
|
||||
func (_d *RoundStatsDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (rsd *RoundStatsDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
func (_d *RoundStatsDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(roundstats.Table, sqlgraph.NewFieldSpec(roundstats.FieldID, field.TypeInt))
|
||||
if ps := rsd.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, rsd.driver, _spec)
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
rsd.mutation.done = true
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// RoundStatsDeleteOne is the builder for deleting a single RoundStats entity.
|
||||
type RoundStatsDeleteOne struct {
|
||||
rsd *RoundStatsDelete
|
||||
_d *RoundStatsDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the RoundStatsDelete builder.
|
||||
func (rsdo *RoundStatsDeleteOne) Where(ps ...predicate.RoundStats) *RoundStatsDeleteOne {
|
||||
rsdo.rsd.mutation.Where(ps...)
|
||||
return rsdo
|
||||
func (_d *RoundStatsDeleteOne) Where(ps ...predicate.RoundStats) *RoundStatsDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (rsdo *RoundStatsDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := rsdo.rsd.Exec(ctx)
|
||||
func (_d *RoundStatsDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
@@ -81,8 +81,8 @@ func (rsdo *RoundStatsDeleteOne) Exec(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (rsdo *RoundStatsDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := rsdo.Exec(ctx); err != nil {
|
||||
func (_d *RoundStatsDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
@@ -31,44 +32,44 @@ type RoundStatsQuery struct {
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the RoundStatsQuery builder.
|
||||
func (rsq *RoundStatsQuery) Where(ps ...predicate.RoundStats) *RoundStatsQuery {
|
||||
rsq.predicates = append(rsq.predicates, ps...)
|
||||
return rsq
|
||||
func (_q *RoundStatsQuery) Where(ps ...predicate.RoundStats) *RoundStatsQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (rsq *RoundStatsQuery) Limit(limit int) *RoundStatsQuery {
|
||||
rsq.ctx.Limit = &limit
|
||||
return rsq
|
||||
func (_q *RoundStatsQuery) Limit(limit int) *RoundStatsQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (rsq *RoundStatsQuery) Offset(offset int) *RoundStatsQuery {
|
||||
rsq.ctx.Offset = &offset
|
||||
return rsq
|
||||
func (_q *RoundStatsQuery) Offset(offset int) *RoundStatsQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (rsq *RoundStatsQuery) Unique(unique bool) *RoundStatsQuery {
|
||||
rsq.ctx.Unique = &unique
|
||||
return rsq
|
||||
func (_q *RoundStatsQuery) Unique(unique bool) *RoundStatsQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (rsq *RoundStatsQuery) Order(o ...roundstats.OrderOption) *RoundStatsQuery {
|
||||
rsq.order = append(rsq.order, o...)
|
||||
return rsq
|
||||
func (_q *RoundStatsQuery) Order(o ...roundstats.OrderOption) *RoundStatsQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryMatchPlayer chains the current query on the "match_player" edge.
|
||||
func (rsq *RoundStatsQuery) QueryMatchPlayer() *MatchPlayerQuery {
|
||||
query := (&MatchPlayerClient{config: rsq.config}).Query()
|
||||
func (_q *RoundStatsQuery) QueryMatchPlayer() *MatchPlayerQuery {
|
||||
query := (&MatchPlayerClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := rsq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := rsq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -77,7 +78,7 @@ func (rsq *RoundStatsQuery) QueryMatchPlayer() *MatchPlayerQuery {
|
||||
sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, roundstats.MatchPlayerTable, roundstats.MatchPlayerColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(rsq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
@@ -85,8 +86,8 @@ func (rsq *RoundStatsQuery) QueryMatchPlayer() *MatchPlayerQuery {
|
||||
|
||||
// First returns the first RoundStats entity from the query.
|
||||
// Returns a *NotFoundError when no RoundStats was found.
|
||||
func (rsq *RoundStatsQuery) First(ctx context.Context) (*RoundStats, error) {
|
||||
nodes, err := rsq.Limit(1).All(setContextOp(ctx, rsq.ctx, "First"))
|
||||
func (_q *RoundStatsQuery) First(ctx context.Context) (*RoundStats, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -97,8 +98,8 @@ func (rsq *RoundStatsQuery) First(ctx context.Context) (*RoundStats, error) {
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (rsq *RoundStatsQuery) FirstX(ctx context.Context) *RoundStats {
|
||||
node, err := rsq.First(ctx)
|
||||
func (_q *RoundStatsQuery) FirstX(ctx context.Context) *RoundStats {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -107,9 +108,9 @@ func (rsq *RoundStatsQuery) FirstX(ctx context.Context) *RoundStats {
|
||||
|
||||
// FirstID returns the first RoundStats ID from the query.
|
||||
// Returns a *NotFoundError when no RoundStats ID was found.
|
||||
func (rsq *RoundStatsQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
func (_q *RoundStatsQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = rsq.Limit(1).IDs(setContextOp(ctx, rsq.ctx, "FirstID")); err != nil {
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
@@ -120,8 +121,8 @@ func (rsq *RoundStatsQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (rsq *RoundStatsQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := rsq.FirstID(ctx)
|
||||
func (_q *RoundStatsQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -131,8 +132,8 @@ func (rsq *RoundStatsQuery) FirstIDX(ctx context.Context) int {
|
||||
// Only returns a single RoundStats entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one RoundStats entity is found.
|
||||
// Returns a *NotFoundError when no RoundStats entities are found.
|
||||
func (rsq *RoundStatsQuery) Only(ctx context.Context) (*RoundStats, error) {
|
||||
nodes, err := rsq.Limit(2).All(setContextOp(ctx, rsq.ctx, "Only"))
|
||||
func (_q *RoundStatsQuery) Only(ctx context.Context) (*RoundStats, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -147,8 +148,8 @@ func (rsq *RoundStatsQuery) Only(ctx context.Context) (*RoundStats, error) {
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (rsq *RoundStatsQuery) OnlyX(ctx context.Context) *RoundStats {
|
||||
node, err := rsq.Only(ctx)
|
||||
func (_q *RoundStatsQuery) OnlyX(ctx context.Context) *RoundStats {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -158,9 +159,9 @@ func (rsq *RoundStatsQuery) OnlyX(ctx context.Context) *RoundStats {
|
||||
// OnlyID is like Only, but returns the only RoundStats ID in the query.
|
||||
// Returns a *NotSingularError when more than one RoundStats ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (rsq *RoundStatsQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
func (_q *RoundStatsQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = rsq.Limit(2).IDs(setContextOp(ctx, rsq.ctx, "OnlyID")); err != nil {
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
@@ -175,8 +176,8 @@ func (rsq *RoundStatsQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (rsq *RoundStatsQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := rsq.OnlyID(ctx)
|
||||
func (_q *RoundStatsQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -184,18 +185,18 @@ func (rsq *RoundStatsQuery) OnlyIDX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of RoundStatsSlice.
|
||||
func (rsq *RoundStatsQuery) All(ctx context.Context) ([]*RoundStats, error) {
|
||||
ctx = setContextOp(ctx, rsq.ctx, "All")
|
||||
if err := rsq.prepareQuery(ctx); err != nil {
|
||||
func (_q *RoundStatsQuery) All(ctx context.Context) ([]*RoundStats, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*RoundStats, *RoundStatsQuery]()
|
||||
return withInterceptors[[]*RoundStats](ctx, rsq, qr, rsq.inters)
|
||||
return withInterceptors[[]*RoundStats](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (rsq *RoundStatsQuery) AllX(ctx context.Context) []*RoundStats {
|
||||
nodes, err := rsq.All(ctx)
|
||||
func (_q *RoundStatsQuery) AllX(ctx context.Context) []*RoundStats {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -203,20 +204,20 @@ func (rsq *RoundStatsQuery) AllX(ctx context.Context) []*RoundStats {
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of RoundStats IDs.
|
||||
func (rsq *RoundStatsQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if rsq.ctx.Unique == nil && rsq.path != nil {
|
||||
rsq.Unique(true)
|
||||
func (_q *RoundStatsQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, rsq.ctx, "IDs")
|
||||
if err = rsq.Select(roundstats.FieldID).Scan(ctx, &ids); err != nil {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(roundstats.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (rsq *RoundStatsQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := rsq.IDs(ctx)
|
||||
func (_q *RoundStatsQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -224,17 +225,17 @@ func (rsq *RoundStatsQuery) IDsX(ctx context.Context) []int {
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (rsq *RoundStatsQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, rsq.ctx, "Count")
|
||||
if err := rsq.prepareQuery(ctx); err != nil {
|
||||
func (_q *RoundStatsQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, rsq, querierCount[*RoundStatsQuery](), rsq.inters)
|
||||
return withInterceptors[int](ctx, _q, querierCount[*RoundStatsQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (rsq *RoundStatsQuery) CountX(ctx context.Context) int {
|
||||
count, err := rsq.Count(ctx)
|
||||
func (_q *RoundStatsQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -242,9 +243,9 @@ func (rsq *RoundStatsQuery) CountX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (rsq *RoundStatsQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, rsq.ctx, "Exist")
|
||||
switch _, err := rsq.FirstID(ctx); {
|
||||
func (_q *RoundStatsQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
@@ -255,8 +256,8 @@ func (rsq *RoundStatsQuery) Exist(ctx context.Context) (bool, error) {
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (rsq *RoundStatsQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := rsq.Exist(ctx)
|
||||
func (_q *RoundStatsQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -265,32 +266,33 @@ func (rsq *RoundStatsQuery) ExistX(ctx context.Context) bool {
|
||||
|
||||
// Clone returns a duplicate of the RoundStatsQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (rsq *RoundStatsQuery) Clone() *RoundStatsQuery {
|
||||
if rsq == nil {
|
||||
func (_q *RoundStatsQuery) Clone() *RoundStatsQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &RoundStatsQuery{
|
||||
config: rsq.config,
|
||||
ctx: rsq.ctx.Clone(),
|
||||
order: append([]roundstats.OrderOption{}, rsq.order...),
|
||||
inters: append([]Interceptor{}, rsq.inters...),
|
||||
predicates: append([]predicate.RoundStats{}, rsq.predicates...),
|
||||
withMatchPlayer: rsq.withMatchPlayer.Clone(),
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]roundstats.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.RoundStats{}, _q.predicates...),
|
||||
withMatchPlayer: _q.withMatchPlayer.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: rsq.sql.Clone(),
|
||||
path: rsq.path,
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
modifiers: append([]func(*sql.Selector){}, _q.modifiers...),
|
||||
}
|
||||
}
|
||||
|
||||
// WithMatchPlayer tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "match_player" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (rsq *RoundStatsQuery) WithMatchPlayer(opts ...func(*MatchPlayerQuery)) *RoundStatsQuery {
|
||||
query := (&MatchPlayerClient{config: rsq.config}).Query()
|
||||
func (_q *RoundStatsQuery) WithMatchPlayer(opts ...func(*MatchPlayerQuery)) *RoundStatsQuery {
|
||||
query := (&MatchPlayerClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
rsq.withMatchPlayer = query
|
||||
return rsq
|
||||
_q.withMatchPlayer = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
@@ -307,10 +309,10 @@ func (rsq *RoundStatsQuery) WithMatchPlayer(opts ...func(*MatchPlayerQuery)) *Ro
|
||||
// GroupBy(roundstats.FieldRound).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (rsq *RoundStatsQuery) GroupBy(field string, fields ...string) *RoundStatsGroupBy {
|
||||
rsq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &RoundStatsGroupBy{build: rsq}
|
||||
grbuild.flds = &rsq.ctx.Fields
|
||||
func (_q *RoundStatsQuery) GroupBy(field string, fields ...string) *RoundStatsGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &RoundStatsGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = roundstats.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
@@ -328,55 +330,55 @@ func (rsq *RoundStatsQuery) GroupBy(field string, fields ...string) *RoundStatsG
|
||||
// client.RoundStats.Query().
|
||||
// Select(roundstats.FieldRound).
|
||||
// Scan(ctx, &v)
|
||||
func (rsq *RoundStatsQuery) Select(fields ...string) *RoundStatsSelect {
|
||||
rsq.ctx.Fields = append(rsq.ctx.Fields, fields...)
|
||||
sbuild := &RoundStatsSelect{RoundStatsQuery: rsq}
|
||||
func (_q *RoundStatsQuery) Select(fields ...string) *RoundStatsSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &RoundStatsSelect{RoundStatsQuery: _q}
|
||||
sbuild.label = roundstats.Label
|
||||
sbuild.flds, sbuild.scan = &rsq.ctx.Fields, sbuild.Scan
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a RoundStatsSelect configured with the given aggregations.
|
||||
func (rsq *RoundStatsQuery) Aggregate(fns ...AggregateFunc) *RoundStatsSelect {
|
||||
return rsq.Select().Aggregate(fns...)
|
||||
func (_q *RoundStatsQuery) Aggregate(fns ...AggregateFunc) *RoundStatsSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (rsq *RoundStatsQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range rsq.inters {
|
||||
func (_q *RoundStatsQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, rsq); err != nil {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range rsq.ctx.Fields {
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !roundstats.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if rsq.path != nil {
|
||||
prev, err := rsq.path(ctx)
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
rsq.sql = prev
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rsq *RoundStatsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*RoundStats, error) {
|
||||
func (_q *RoundStatsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*RoundStats, error) {
|
||||
var (
|
||||
nodes = []*RoundStats{}
|
||||
withFKs = rsq.withFKs
|
||||
_spec = rsq.querySpec()
|
||||
withFKs = _q.withFKs
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
rsq.withMatchPlayer != nil,
|
||||
_q.withMatchPlayer != nil,
|
||||
}
|
||||
)
|
||||
if rsq.withMatchPlayer != nil {
|
||||
if _q.withMatchPlayer != nil {
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
@@ -386,25 +388,25 @@ func (rsq *RoundStatsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*
|
||||
return (*RoundStats).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &RoundStats{config: rsq.config}
|
||||
node := &RoundStats{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
if len(rsq.modifiers) > 0 {
|
||||
_spec.Modifiers = rsq.modifiers
|
||||
if len(_q.modifiers) > 0 {
|
||||
_spec.Modifiers = _q.modifiers
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, rsq.driver, _spec); err != nil {
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := rsq.withMatchPlayer; query != nil {
|
||||
if err := rsq.loadMatchPlayer(ctx, query, nodes, nil,
|
||||
if query := _q.withMatchPlayer; query != nil {
|
||||
if err := _q.loadMatchPlayer(ctx, query, nodes, nil,
|
||||
func(n *RoundStats, e *MatchPlayer) { n.Edges.MatchPlayer = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -412,7 +414,7 @@ func (rsq *RoundStatsQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (rsq *RoundStatsQuery) loadMatchPlayer(ctx context.Context, query *MatchPlayerQuery, nodes []*RoundStats, init func(*RoundStats), assign func(*RoundStats, *MatchPlayer)) error {
|
||||
func (_q *RoundStatsQuery) loadMatchPlayer(ctx context.Context, query *MatchPlayerQuery, nodes []*RoundStats, init func(*RoundStats), assign func(*RoundStats, *MatchPlayer)) error {
|
||||
ids := make([]int, 0, len(nodes))
|
||||
nodeids := make(map[int][]*RoundStats)
|
||||
for i := range nodes {
|
||||
@@ -445,27 +447,27 @@ func (rsq *RoundStatsQuery) loadMatchPlayer(ctx context.Context, query *MatchPla
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rsq *RoundStatsQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := rsq.querySpec()
|
||||
if len(rsq.modifiers) > 0 {
|
||||
_spec.Modifiers = rsq.modifiers
|
||||
func (_q *RoundStatsQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
if len(_q.modifiers) > 0 {
|
||||
_spec.Modifiers = _q.modifiers
|
||||
}
|
||||
_spec.Node.Columns = rsq.ctx.Fields
|
||||
if len(rsq.ctx.Fields) > 0 {
|
||||
_spec.Unique = rsq.ctx.Unique != nil && *rsq.ctx.Unique
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, rsq.driver, _spec)
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (rsq *RoundStatsQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
func (_q *RoundStatsQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(roundstats.Table, roundstats.Columns, sqlgraph.NewFieldSpec(roundstats.FieldID, field.TypeInt))
|
||||
_spec.From = rsq.sql
|
||||
if unique := rsq.ctx.Unique; unique != nil {
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if rsq.path != nil {
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := rsq.ctx.Fields; len(fields) > 0 {
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, roundstats.FieldID)
|
||||
for i := range fields {
|
||||
@@ -474,20 +476,20 @@ func (rsq *RoundStatsQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := rsq.predicates; len(ps) > 0 {
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := rsq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := rsq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := rsq.order; len(ps) > 0 {
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
@@ -497,45 +499,45 @@ func (rsq *RoundStatsQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (rsq *RoundStatsQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(rsq.driver.Dialect())
|
||||
func (_q *RoundStatsQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(roundstats.Table)
|
||||
columns := rsq.ctx.Fields
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = roundstats.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if rsq.sql != nil {
|
||||
selector = rsq.sql
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if rsq.ctx.Unique != nil && *rsq.ctx.Unique {
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, m := range rsq.modifiers {
|
||||
for _, m := range _q.modifiers {
|
||||
m(selector)
|
||||
}
|
||||
for _, p := range rsq.predicates {
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range rsq.order {
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := rsq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := rsq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// Modify adds a query modifier for attaching custom logic to queries.
|
||||
func (rsq *RoundStatsQuery) Modify(modifiers ...func(s *sql.Selector)) *RoundStatsSelect {
|
||||
rsq.modifiers = append(rsq.modifiers, modifiers...)
|
||||
return rsq.Select()
|
||||
func (_q *RoundStatsQuery) Modify(modifiers ...func(s *sql.Selector)) *RoundStatsSelect {
|
||||
_q.modifiers = append(_q.modifiers, modifiers...)
|
||||
return _q.Select()
|
||||
}
|
||||
|
||||
// RoundStatsGroupBy is the group-by builder for RoundStats entities.
|
||||
@@ -545,41 +547,41 @@ type RoundStatsGroupBy struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (rsgb *RoundStatsGroupBy) Aggregate(fns ...AggregateFunc) *RoundStatsGroupBy {
|
||||
rsgb.fns = append(rsgb.fns, fns...)
|
||||
return rsgb
|
||||
func (_g *RoundStatsGroupBy) Aggregate(fns ...AggregateFunc) *RoundStatsGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (rsgb *RoundStatsGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, rsgb.build.ctx, "GroupBy")
|
||||
if err := rsgb.build.prepareQuery(ctx); err != nil {
|
||||
func (_g *RoundStatsGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*RoundStatsQuery, *RoundStatsGroupBy](ctx, rsgb.build, rsgb, rsgb.build.inters, v)
|
||||
return scanWithInterceptors[*RoundStatsQuery, *RoundStatsGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (rsgb *RoundStatsGroupBy) sqlScan(ctx context.Context, root *RoundStatsQuery, v any) error {
|
||||
func (_g *RoundStatsGroupBy) sqlScan(ctx context.Context, root *RoundStatsQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(rsgb.fns))
|
||||
for _, fn := range rsgb.fns {
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*rsgb.flds)+len(rsgb.fns))
|
||||
for _, f := range *rsgb.flds {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*rsgb.flds...)...)
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := rsgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -593,27 +595,27 @@ type RoundStatsSelect struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (rss *RoundStatsSelect) Aggregate(fns ...AggregateFunc) *RoundStatsSelect {
|
||||
rss.fns = append(rss.fns, fns...)
|
||||
return rss
|
||||
func (_s *RoundStatsSelect) Aggregate(fns ...AggregateFunc) *RoundStatsSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (rss *RoundStatsSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, rss.ctx, "Select")
|
||||
if err := rss.prepareQuery(ctx); err != nil {
|
||||
func (_s *RoundStatsSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*RoundStatsQuery, *RoundStatsSelect](ctx, rss.RoundStatsQuery, rss, rss.inters, v)
|
||||
return scanWithInterceptors[*RoundStatsQuery, *RoundStatsSelect](ctx, _s.RoundStatsQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (rss *RoundStatsSelect) sqlScan(ctx context.Context, root *RoundStatsQuery, v any) error {
|
||||
func (_s *RoundStatsSelect) sqlScan(ctx context.Context, root *RoundStatsQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(rss.fns))
|
||||
for _, fn := range rss.fns {
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*rss.selector.flds); {
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
@@ -621,7 +623,7 @@ func (rss *RoundStatsSelect) sqlScan(ctx context.Context, root *RoundStatsQuery,
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := rss.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -629,7 +631,7 @@ func (rss *RoundStatsSelect) sqlScan(ctx context.Context, root *RoundStatsQuery,
|
||||
}
|
||||
|
||||
// Modify adds a query modifier for attaching custom logic to queries.
|
||||
func (rss *RoundStatsSelect) Modify(modifiers ...func(s *sql.Selector)) *RoundStatsSelect {
|
||||
rss.modifiers = append(rss.modifiers, modifiers...)
|
||||
return rss
|
||||
func (_s *RoundStatsSelect) Modify(modifiers ...func(s *sql.Selector)) *RoundStatsSelect {
|
||||
_s.modifiers = append(_s.modifiers, modifiers...)
|
||||
return _s
|
||||
}
|
||||
|
||||
@@ -24,101 +24,133 @@ type RoundStatsUpdate struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the RoundStatsUpdate builder.
|
||||
func (rsu *RoundStatsUpdate) Where(ps ...predicate.RoundStats) *RoundStatsUpdate {
|
||||
rsu.mutation.Where(ps...)
|
||||
return rsu
|
||||
func (_u *RoundStatsUpdate) Where(ps ...predicate.RoundStats) *RoundStatsUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetRound sets the "round" field.
|
||||
func (rsu *RoundStatsUpdate) SetRound(u uint) *RoundStatsUpdate {
|
||||
rsu.mutation.ResetRound()
|
||||
rsu.mutation.SetRound(u)
|
||||
return rsu
|
||||
func (_u *RoundStatsUpdate) SetRound(v uint) *RoundStatsUpdate {
|
||||
_u.mutation.ResetRound()
|
||||
_u.mutation.SetRound(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddRound adds u to the "round" field.
|
||||
func (rsu *RoundStatsUpdate) AddRound(u int) *RoundStatsUpdate {
|
||||
rsu.mutation.AddRound(u)
|
||||
return rsu
|
||||
// SetNillableRound sets the "round" field if the given value is not nil.
|
||||
func (_u *RoundStatsUpdate) SetNillableRound(v *uint) *RoundStatsUpdate {
|
||||
if v != nil {
|
||||
_u.SetRound(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddRound adds value to the "round" field.
|
||||
func (_u *RoundStatsUpdate) AddRound(v int) *RoundStatsUpdate {
|
||||
_u.mutation.AddRound(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetBank sets the "bank" field.
|
||||
func (rsu *RoundStatsUpdate) SetBank(u uint) *RoundStatsUpdate {
|
||||
rsu.mutation.ResetBank()
|
||||
rsu.mutation.SetBank(u)
|
||||
return rsu
|
||||
func (_u *RoundStatsUpdate) SetBank(v uint) *RoundStatsUpdate {
|
||||
_u.mutation.ResetBank()
|
||||
_u.mutation.SetBank(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddBank adds u to the "bank" field.
|
||||
func (rsu *RoundStatsUpdate) AddBank(u int) *RoundStatsUpdate {
|
||||
rsu.mutation.AddBank(u)
|
||||
return rsu
|
||||
// SetNillableBank sets the "bank" field if the given value is not nil.
|
||||
func (_u *RoundStatsUpdate) SetNillableBank(v *uint) *RoundStatsUpdate {
|
||||
if v != nil {
|
||||
_u.SetBank(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddBank adds value to the "bank" field.
|
||||
func (_u *RoundStatsUpdate) AddBank(v int) *RoundStatsUpdate {
|
||||
_u.mutation.AddBank(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEquipment sets the "equipment" field.
|
||||
func (rsu *RoundStatsUpdate) SetEquipment(u uint) *RoundStatsUpdate {
|
||||
rsu.mutation.ResetEquipment()
|
||||
rsu.mutation.SetEquipment(u)
|
||||
return rsu
|
||||
func (_u *RoundStatsUpdate) SetEquipment(v uint) *RoundStatsUpdate {
|
||||
_u.mutation.ResetEquipment()
|
||||
_u.mutation.SetEquipment(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddEquipment adds u to the "equipment" field.
|
||||
func (rsu *RoundStatsUpdate) AddEquipment(u int) *RoundStatsUpdate {
|
||||
rsu.mutation.AddEquipment(u)
|
||||
return rsu
|
||||
// SetNillableEquipment sets the "equipment" field if the given value is not nil.
|
||||
func (_u *RoundStatsUpdate) SetNillableEquipment(v *uint) *RoundStatsUpdate {
|
||||
if v != nil {
|
||||
_u.SetEquipment(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddEquipment adds value to the "equipment" field.
|
||||
func (_u *RoundStatsUpdate) AddEquipment(v int) *RoundStatsUpdate {
|
||||
_u.mutation.AddEquipment(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSpent sets the "spent" field.
|
||||
func (rsu *RoundStatsUpdate) SetSpent(u uint) *RoundStatsUpdate {
|
||||
rsu.mutation.ResetSpent()
|
||||
rsu.mutation.SetSpent(u)
|
||||
return rsu
|
||||
func (_u *RoundStatsUpdate) SetSpent(v uint) *RoundStatsUpdate {
|
||||
_u.mutation.ResetSpent()
|
||||
_u.mutation.SetSpent(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddSpent adds u to the "spent" field.
|
||||
func (rsu *RoundStatsUpdate) AddSpent(u int) *RoundStatsUpdate {
|
||||
rsu.mutation.AddSpent(u)
|
||||
return rsu
|
||||
// SetNillableSpent sets the "spent" field if the given value is not nil.
|
||||
func (_u *RoundStatsUpdate) SetNillableSpent(v *uint) *RoundStatsUpdate {
|
||||
if v != nil {
|
||||
_u.SetSpent(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddSpent adds value to the "spent" field.
|
||||
func (_u *RoundStatsUpdate) AddSpent(v int) *RoundStatsUpdate {
|
||||
_u.mutation.AddSpent(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID.
|
||||
func (rsu *RoundStatsUpdate) SetMatchPlayerID(id int) *RoundStatsUpdate {
|
||||
rsu.mutation.SetMatchPlayerID(id)
|
||||
return rsu
|
||||
func (_u *RoundStatsUpdate) SetMatchPlayerID(id int) *RoundStatsUpdate {
|
||||
_u.mutation.SetMatchPlayerID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID if the given value is not nil.
|
||||
func (rsu *RoundStatsUpdate) SetNillableMatchPlayerID(id *int) *RoundStatsUpdate {
|
||||
func (_u *RoundStatsUpdate) SetNillableMatchPlayerID(id *int) *RoundStatsUpdate {
|
||||
if id != nil {
|
||||
rsu = rsu.SetMatchPlayerID(*id)
|
||||
_u = _u.SetMatchPlayerID(*id)
|
||||
}
|
||||
return rsu
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetMatchPlayer sets the "match_player" edge to the MatchPlayer entity.
|
||||
func (rsu *RoundStatsUpdate) SetMatchPlayer(m *MatchPlayer) *RoundStatsUpdate {
|
||||
return rsu.SetMatchPlayerID(m.ID)
|
||||
func (_u *RoundStatsUpdate) SetMatchPlayer(v *MatchPlayer) *RoundStatsUpdate {
|
||||
return _u.SetMatchPlayerID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the RoundStatsMutation object of the builder.
|
||||
func (rsu *RoundStatsUpdate) Mutation() *RoundStatsMutation {
|
||||
return rsu.mutation
|
||||
func (_u *RoundStatsUpdate) Mutation() *RoundStatsMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearMatchPlayer clears the "match_player" edge to the MatchPlayer entity.
|
||||
func (rsu *RoundStatsUpdate) ClearMatchPlayer() *RoundStatsUpdate {
|
||||
rsu.mutation.ClearMatchPlayer()
|
||||
return rsu
|
||||
func (_u *RoundStatsUpdate) ClearMatchPlayer() *RoundStatsUpdate {
|
||||
_u.mutation.ClearMatchPlayer()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (rsu *RoundStatsUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, rsu.sqlSave, rsu.mutation, rsu.hooks)
|
||||
func (_u *RoundStatsUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (rsu *RoundStatsUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := rsu.Save(ctx)
|
||||
func (_u *RoundStatsUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -126,58 +158,58 @@ func (rsu *RoundStatsUpdate) SaveX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (rsu *RoundStatsUpdate) Exec(ctx context.Context) error {
|
||||
_, err := rsu.Save(ctx)
|
||||
func (_u *RoundStatsUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (rsu *RoundStatsUpdate) ExecX(ctx context.Context) {
|
||||
if err := rsu.Exec(ctx); err != nil {
|
||||
func (_u *RoundStatsUpdate) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
||||
func (rsu *RoundStatsUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RoundStatsUpdate {
|
||||
rsu.modifiers = append(rsu.modifiers, modifiers...)
|
||||
return rsu
|
||||
func (_u *RoundStatsUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RoundStatsUpdate {
|
||||
_u.modifiers = append(_u.modifiers, modifiers...)
|
||||
return _u
|
||||
}
|
||||
|
||||
func (rsu *RoundStatsUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
func (_u *RoundStatsUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(roundstats.Table, roundstats.Columns, sqlgraph.NewFieldSpec(roundstats.FieldID, field.TypeInt))
|
||||
if ps := rsu.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := rsu.mutation.Round(); ok {
|
||||
if value, ok := _u.mutation.Round(); ok {
|
||||
_spec.SetField(roundstats.FieldRound, field.TypeUint, value)
|
||||
}
|
||||
if value, ok := rsu.mutation.AddedRound(); ok {
|
||||
if value, ok := _u.mutation.AddedRound(); ok {
|
||||
_spec.AddField(roundstats.FieldRound, field.TypeUint, value)
|
||||
}
|
||||
if value, ok := rsu.mutation.Bank(); ok {
|
||||
if value, ok := _u.mutation.Bank(); ok {
|
||||
_spec.SetField(roundstats.FieldBank, field.TypeUint, value)
|
||||
}
|
||||
if value, ok := rsu.mutation.AddedBank(); ok {
|
||||
if value, ok := _u.mutation.AddedBank(); ok {
|
||||
_spec.AddField(roundstats.FieldBank, field.TypeUint, value)
|
||||
}
|
||||
if value, ok := rsu.mutation.Equipment(); ok {
|
||||
if value, ok := _u.mutation.Equipment(); ok {
|
||||
_spec.SetField(roundstats.FieldEquipment, field.TypeUint, value)
|
||||
}
|
||||
if value, ok := rsu.mutation.AddedEquipment(); ok {
|
||||
if value, ok := _u.mutation.AddedEquipment(); ok {
|
||||
_spec.AddField(roundstats.FieldEquipment, field.TypeUint, value)
|
||||
}
|
||||
if value, ok := rsu.mutation.Spent(); ok {
|
||||
if value, ok := _u.mutation.Spent(); ok {
|
||||
_spec.SetField(roundstats.FieldSpent, field.TypeUint, value)
|
||||
}
|
||||
if value, ok := rsu.mutation.AddedSpent(); ok {
|
||||
if value, ok := _u.mutation.AddedSpent(); ok {
|
||||
_spec.AddField(roundstats.FieldSpent, field.TypeUint, value)
|
||||
}
|
||||
if rsu.mutation.MatchPlayerCleared() {
|
||||
if _u.mutation.MatchPlayerCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -190,7 +222,7 @@ func (rsu *RoundStatsUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := rsu.mutation.MatchPlayerIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.MatchPlayerIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -206,8 +238,8 @@ func (rsu *RoundStatsUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_spec.AddModifiers(rsu.modifiers...)
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, rsu.driver, _spec); err != nil {
|
||||
_spec.AddModifiers(_u.modifiers...)
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{roundstats.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -215,8 +247,8 @@ func (rsu *RoundStatsUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
rsu.mutation.done = true
|
||||
return n, nil
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// RoundStatsUpdateOne is the builder for updating a single RoundStats entity.
|
||||
@@ -229,108 +261,140 @@ type RoundStatsUpdateOne struct {
|
||||
}
|
||||
|
||||
// SetRound sets the "round" field.
|
||||
func (rsuo *RoundStatsUpdateOne) SetRound(u uint) *RoundStatsUpdateOne {
|
||||
rsuo.mutation.ResetRound()
|
||||
rsuo.mutation.SetRound(u)
|
||||
return rsuo
|
||||
func (_u *RoundStatsUpdateOne) SetRound(v uint) *RoundStatsUpdateOne {
|
||||
_u.mutation.ResetRound()
|
||||
_u.mutation.SetRound(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddRound adds u to the "round" field.
|
||||
func (rsuo *RoundStatsUpdateOne) AddRound(u int) *RoundStatsUpdateOne {
|
||||
rsuo.mutation.AddRound(u)
|
||||
return rsuo
|
||||
// SetNillableRound sets the "round" field if the given value is not nil.
|
||||
func (_u *RoundStatsUpdateOne) SetNillableRound(v *uint) *RoundStatsUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetRound(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddRound adds value to the "round" field.
|
||||
func (_u *RoundStatsUpdateOne) AddRound(v int) *RoundStatsUpdateOne {
|
||||
_u.mutation.AddRound(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetBank sets the "bank" field.
|
||||
func (rsuo *RoundStatsUpdateOne) SetBank(u uint) *RoundStatsUpdateOne {
|
||||
rsuo.mutation.ResetBank()
|
||||
rsuo.mutation.SetBank(u)
|
||||
return rsuo
|
||||
func (_u *RoundStatsUpdateOne) SetBank(v uint) *RoundStatsUpdateOne {
|
||||
_u.mutation.ResetBank()
|
||||
_u.mutation.SetBank(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddBank adds u to the "bank" field.
|
||||
func (rsuo *RoundStatsUpdateOne) AddBank(u int) *RoundStatsUpdateOne {
|
||||
rsuo.mutation.AddBank(u)
|
||||
return rsuo
|
||||
// SetNillableBank sets the "bank" field if the given value is not nil.
|
||||
func (_u *RoundStatsUpdateOne) SetNillableBank(v *uint) *RoundStatsUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetBank(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddBank adds value to the "bank" field.
|
||||
func (_u *RoundStatsUpdateOne) AddBank(v int) *RoundStatsUpdateOne {
|
||||
_u.mutation.AddBank(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEquipment sets the "equipment" field.
|
||||
func (rsuo *RoundStatsUpdateOne) SetEquipment(u uint) *RoundStatsUpdateOne {
|
||||
rsuo.mutation.ResetEquipment()
|
||||
rsuo.mutation.SetEquipment(u)
|
||||
return rsuo
|
||||
func (_u *RoundStatsUpdateOne) SetEquipment(v uint) *RoundStatsUpdateOne {
|
||||
_u.mutation.ResetEquipment()
|
||||
_u.mutation.SetEquipment(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddEquipment adds u to the "equipment" field.
|
||||
func (rsuo *RoundStatsUpdateOne) AddEquipment(u int) *RoundStatsUpdateOne {
|
||||
rsuo.mutation.AddEquipment(u)
|
||||
return rsuo
|
||||
// SetNillableEquipment sets the "equipment" field if the given value is not nil.
|
||||
func (_u *RoundStatsUpdateOne) SetNillableEquipment(v *uint) *RoundStatsUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetEquipment(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddEquipment adds value to the "equipment" field.
|
||||
func (_u *RoundStatsUpdateOne) AddEquipment(v int) *RoundStatsUpdateOne {
|
||||
_u.mutation.AddEquipment(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSpent sets the "spent" field.
|
||||
func (rsuo *RoundStatsUpdateOne) SetSpent(u uint) *RoundStatsUpdateOne {
|
||||
rsuo.mutation.ResetSpent()
|
||||
rsuo.mutation.SetSpent(u)
|
||||
return rsuo
|
||||
func (_u *RoundStatsUpdateOne) SetSpent(v uint) *RoundStatsUpdateOne {
|
||||
_u.mutation.ResetSpent()
|
||||
_u.mutation.SetSpent(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddSpent adds u to the "spent" field.
|
||||
func (rsuo *RoundStatsUpdateOne) AddSpent(u int) *RoundStatsUpdateOne {
|
||||
rsuo.mutation.AddSpent(u)
|
||||
return rsuo
|
||||
// SetNillableSpent sets the "spent" field if the given value is not nil.
|
||||
func (_u *RoundStatsUpdateOne) SetNillableSpent(v *uint) *RoundStatsUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetSpent(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddSpent adds value to the "spent" field.
|
||||
func (_u *RoundStatsUpdateOne) AddSpent(v int) *RoundStatsUpdateOne {
|
||||
_u.mutation.AddSpent(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID.
|
||||
func (rsuo *RoundStatsUpdateOne) SetMatchPlayerID(id int) *RoundStatsUpdateOne {
|
||||
rsuo.mutation.SetMatchPlayerID(id)
|
||||
return rsuo
|
||||
func (_u *RoundStatsUpdateOne) SetMatchPlayerID(id int) *RoundStatsUpdateOne {
|
||||
_u.mutation.SetMatchPlayerID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableMatchPlayerID sets the "match_player" edge to the MatchPlayer entity by ID if the given value is not nil.
|
||||
func (rsuo *RoundStatsUpdateOne) SetNillableMatchPlayerID(id *int) *RoundStatsUpdateOne {
|
||||
func (_u *RoundStatsUpdateOne) SetNillableMatchPlayerID(id *int) *RoundStatsUpdateOne {
|
||||
if id != nil {
|
||||
rsuo = rsuo.SetMatchPlayerID(*id)
|
||||
_u = _u.SetMatchPlayerID(*id)
|
||||
}
|
||||
return rsuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetMatchPlayer sets the "match_player" edge to the MatchPlayer entity.
|
||||
func (rsuo *RoundStatsUpdateOne) SetMatchPlayer(m *MatchPlayer) *RoundStatsUpdateOne {
|
||||
return rsuo.SetMatchPlayerID(m.ID)
|
||||
func (_u *RoundStatsUpdateOne) SetMatchPlayer(v *MatchPlayer) *RoundStatsUpdateOne {
|
||||
return _u.SetMatchPlayerID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the RoundStatsMutation object of the builder.
|
||||
func (rsuo *RoundStatsUpdateOne) Mutation() *RoundStatsMutation {
|
||||
return rsuo.mutation
|
||||
func (_u *RoundStatsUpdateOne) Mutation() *RoundStatsMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearMatchPlayer clears the "match_player" edge to the MatchPlayer entity.
|
||||
func (rsuo *RoundStatsUpdateOne) ClearMatchPlayer() *RoundStatsUpdateOne {
|
||||
rsuo.mutation.ClearMatchPlayer()
|
||||
return rsuo
|
||||
func (_u *RoundStatsUpdateOne) ClearMatchPlayer() *RoundStatsUpdateOne {
|
||||
_u.mutation.ClearMatchPlayer()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the RoundStatsUpdate builder.
|
||||
func (rsuo *RoundStatsUpdateOne) Where(ps ...predicate.RoundStats) *RoundStatsUpdateOne {
|
||||
rsuo.mutation.Where(ps...)
|
||||
return rsuo
|
||||
func (_u *RoundStatsUpdateOne) Where(ps ...predicate.RoundStats) *RoundStatsUpdateOne {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (rsuo *RoundStatsUpdateOne) Select(field string, fields ...string) *RoundStatsUpdateOne {
|
||||
rsuo.fields = append([]string{field}, fields...)
|
||||
return rsuo
|
||||
func (_u *RoundStatsUpdateOne) Select(field string, fields ...string) *RoundStatsUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated RoundStats entity.
|
||||
func (rsuo *RoundStatsUpdateOne) Save(ctx context.Context) (*RoundStats, error) {
|
||||
return withHooks(ctx, rsuo.sqlSave, rsuo.mutation, rsuo.hooks)
|
||||
func (_u *RoundStatsUpdateOne) Save(ctx context.Context) (*RoundStats, error) {
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (rsuo *RoundStatsUpdateOne) SaveX(ctx context.Context) *RoundStats {
|
||||
node, err := rsuo.Save(ctx)
|
||||
func (_u *RoundStatsUpdateOne) SaveX(ctx context.Context) *RoundStats {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -338,32 +402,32 @@ func (rsuo *RoundStatsUpdateOne) SaveX(ctx context.Context) *RoundStats {
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (rsuo *RoundStatsUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := rsuo.Save(ctx)
|
||||
func (_u *RoundStatsUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (rsuo *RoundStatsUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := rsuo.Exec(ctx); err != nil {
|
||||
func (_u *RoundStatsUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
||||
func (rsuo *RoundStatsUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RoundStatsUpdateOne {
|
||||
rsuo.modifiers = append(rsuo.modifiers, modifiers...)
|
||||
return rsuo
|
||||
func (_u *RoundStatsUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *RoundStatsUpdateOne {
|
||||
_u.modifiers = append(_u.modifiers, modifiers...)
|
||||
return _u
|
||||
}
|
||||
|
||||
func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats, err error) {
|
||||
func (_u *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(roundstats.Table, roundstats.Columns, sqlgraph.NewFieldSpec(roundstats.FieldID, field.TypeInt))
|
||||
id, ok := rsuo.mutation.ID()
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "RoundStats.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := rsuo.fields; len(fields) > 0 {
|
||||
if fields := _u.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, roundstats.FieldID)
|
||||
for _, f := range fields {
|
||||
@@ -375,38 +439,38 @@ func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := rsuo.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := rsuo.mutation.Round(); ok {
|
||||
if value, ok := _u.mutation.Round(); ok {
|
||||
_spec.SetField(roundstats.FieldRound, field.TypeUint, value)
|
||||
}
|
||||
if value, ok := rsuo.mutation.AddedRound(); ok {
|
||||
if value, ok := _u.mutation.AddedRound(); ok {
|
||||
_spec.AddField(roundstats.FieldRound, field.TypeUint, value)
|
||||
}
|
||||
if value, ok := rsuo.mutation.Bank(); ok {
|
||||
if value, ok := _u.mutation.Bank(); ok {
|
||||
_spec.SetField(roundstats.FieldBank, field.TypeUint, value)
|
||||
}
|
||||
if value, ok := rsuo.mutation.AddedBank(); ok {
|
||||
if value, ok := _u.mutation.AddedBank(); ok {
|
||||
_spec.AddField(roundstats.FieldBank, field.TypeUint, value)
|
||||
}
|
||||
if value, ok := rsuo.mutation.Equipment(); ok {
|
||||
if value, ok := _u.mutation.Equipment(); ok {
|
||||
_spec.SetField(roundstats.FieldEquipment, field.TypeUint, value)
|
||||
}
|
||||
if value, ok := rsuo.mutation.AddedEquipment(); ok {
|
||||
if value, ok := _u.mutation.AddedEquipment(); ok {
|
||||
_spec.AddField(roundstats.FieldEquipment, field.TypeUint, value)
|
||||
}
|
||||
if value, ok := rsuo.mutation.Spent(); ok {
|
||||
if value, ok := _u.mutation.Spent(); ok {
|
||||
_spec.SetField(roundstats.FieldSpent, field.TypeUint, value)
|
||||
}
|
||||
if value, ok := rsuo.mutation.AddedSpent(); ok {
|
||||
if value, ok := _u.mutation.AddedSpent(); ok {
|
||||
_spec.AddField(roundstats.FieldSpent, field.TypeUint, value)
|
||||
}
|
||||
if rsuo.mutation.MatchPlayerCleared() {
|
||||
if _u.mutation.MatchPlayerCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -419,7 +483,7 @@ func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := rsuo.mutation.MatchPlayerIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.MatchPlayerIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -435,11 +499,11 @@ func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_spec.AddModifiers(rsuo.modifiers...)
|
||||
_node = &RoundStats{config: rsuo.config}
|
||||
_spec.AddModifiers(_u.modifiers...)
|
||||
_node = &RoundStats{config: _u.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, rsuo.driver, _spec); err != nil {
|
||||
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{roundstats.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -447,6 +511,6 @@ func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
rsuo.mutation.done = true
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
@@ -5,6 +5,6 @@ package runtime
|
||||
// The schema-stitching logic is generated in somegit.dev/csgowtf/csgowtfd/ent/runtime.go
|
||||
|
||||
const (
|
||||
Version = "v0.12.3" // Version of ent codegen.
|
||||
Sum = "h1:N5lO2EOrHpCH5HYfiMOCHYbo+oh5M8GjT0/cx5x6xkk=" // Sum of ent codegen.
|
||||
Version = "v0.14.5" // Version of ent codegen.
|
||||
Sum = "h1:Rj2WOYJtCkWyFo6a+5wB3EfBRP0rnx1fMk6gGA0UUe4=" // Sum of ent codegen.
|
||||
)
|
||||
|
||||
50
ent/spray.go
50
ent/spray.go
@@ -40,12 +40,10 @@ type SprayEdges struct {
|
||||
// MatchPlayersOrErr returns the MatchPlayers value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e SprayEdges) MatchPlayersOrErr() (*MatchPlayer, error) {
|
||||
if e.loadedTypes[0] {
|
||||
if e.MatchPlayers == nil {
|
||||
// Edge was loaded but was not found.
|
||||
return nil, &NotFoundError{label: matchplayer.Label}
|
||||
}
|
||||
if e.MatchPlayers != nil {
|
||||
return e.MatchPlayers, nil
|
||||
} else if e.loadedTypes[0] {
|
||||
return nil, &NotFoundError{label: matchplayer.Label}
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "match_players"}
|
||||
}
|
||||
@@ -70,7 +68,7 @@ func (*Spray) scanValues(columns []string) ([]any, error) {
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Spray fields.
|
||||
func (s *Spray) assignValues(columns []string, values []any) error {
|
||||
func (_m *Spray) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
@@ -81,28 +79,28 @@ func (s *Spray) assignValues(columns []string, values []any) error {
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
s.ID = int(value.Int64)
|
||||
_m.ID = int(value.Int64)
|
||||
case spray.FieldWeapon:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field weapon", values[i])
|
||||
} else if value.Valid {
|
||||
s.Weapon = int(value.Int64)
|
||||
_m.Weapon = int(value.Int64)
|
||||
}
|
||||
case spray.FieldSpray:
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field spray", values[i])
|
||||
} else if value != nil {
|
||||
s.Spray = *value
|
||||
_m.Spray = *value
|
||||
}
|
||||
case spray.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for edge-field match_player_spray", value)
|
||||
} else if value.Valid {
|
||||
s.match_player_spray = new(int)
|
||||
*s.match_player_spray = int(value.Int64)
|
||||
_m.match_player_spray = new(int)
|
||||
*_m.match_player_spray = int(value.Int64)
|
||||
}
|
||||
default:
|
||||
s.selectValues.Set(columns[i], values[i])
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -110,43 +108,43 @@ func (s *Spray) assignValues(columns []string, values []any) error {
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Spray.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (s *Spray) Value(name string) (ent.Value, error) {
|
||||
return s.selectValues.Get(name)
|
||||
func (_m *Spray) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryMatchPlayers queries the "match_players" edge of the Spray entity.
|
||||
func (s *Spray) QueryMatchPlayers() *MatchPlayerQuery {
|
||||
return NewSprayClient(s.config).QueryMatchPlayers(s)
|
||||
func (_m *Spray) QueryMatchPlayers() *MatchPlayerQuery {
|
||||
return NewSprayClient(_m.config).QueryMatchPlayers(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Spray.
|
||||
// Note that you need to call Spray.Unwrap() before calling this method if this Spray
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (s *Spray) Update() *SprayUpdateOne {
|
||||
return NewSprayClient(s.config).UpdateOne(s)
|
||||
func (_m *Spray) Update() *SprayUpdateOne {
|
||||
return NewSprayClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Spray entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (s *Spray) Unwrap() *Spray {
|
||||
_tx, ok := s.config.driver.(*txDriver)
|
||||
func (_m *Spray) Unwrap() *Spray {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Spray is not a transactional entity")
|
||||
}
|
||||
s.config.driver = _tx.drv
|
||||
return s
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (s *Spray) String() string {
|
||||
func (_m *Spray) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Spray(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", s.ID))
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("weapon=")
|
||||
builder.WriteString(fmt.Sprintf("%v", s.Weapon))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Weapon))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("spray=")
|
||||
builder.WriteString(fmt.Sprintf("%v", s.Spray))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Spray))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -168,32 +168,15 @@ func HasMatchPlayersWith(preds ...predicate.MatchPlayer) predicate.Spray {
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Spray) predicate.Spray {
|
||||
return predicate.Spray(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for _, p := range predicates {
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
return predicate.Spray(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.Spray) predicate.Spray {
|
||||
return predicate.Spray(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for i, p := range predicates {
|
||||
if i > 0 {
|
||||
s1.Or()
|
||||
}
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
return predicate.Spray(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.Spray) predicate.Spray {
|
||||
return predicate.Spray(func(s *sql.Selector) {
|
||||
p(s.Not())
|
||||
})
|
||||
return predicate.Spray(sql.NotPredicates(p))
|
||||
}
|
||||
|
||||
@@ -21,49 +21,49 @@ type SprayCreate struct {
|
||||
}
|
||||
|
||||
// SetWeapon sets the "weapon" field.
|
||||
func (sc *SprayCreate) SetWeapon(i int) *SprayCreate {
|
||||
sc.mutation.SetWeapon(i)
|
||||
return sc
|
||||
func (_c *SprayCreate) SetWeapon(v int) *SprayCreate {
|
||||
_c.mutation.SetWeapon(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetSpray sets the "spray" field.
|
||||
func (sc *SprayCreate) SetSpray(b []byte) *SprayCreate {
|
||||
sc.mutation.SetSpray(b)
|
||||
return sc
|
||||
func (_c *SprayCreate) SetSpray(v []byte) *SprayCreate {
|
||||
_c.mutation.SetSpray(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID.
|
||||
func (sc *SprayCreate) SetMatchPlayersID(id int) *SprayCreate {
|
||||
sc.mutation.SetMatchPlayersID(id)
|
||||
return sc
|
||||
func (_c *SprayCreate) SetMatchPlayersID(id int) *SprayCreate {
|
||||
_c.mutation.SetMatchPlayersID(id)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID if the given value is not nil.
|
||||
func (sc *SprayCreate) SetNillableMatchPlayersID(id *int) *SprayCreate {
|
||||
func (_c *SprayCreate) SetNillableMatchPlayersID(id *int) *SprayCreate {
|
||||
if id != nil {
|
||||
sc = sc.SetMatchPlayersID(*id)
|
||||
_c = _c.SetMatchPlayersID(*id)
|
||||
}
|
||||
return sc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetMatchPlayers sets the "match_players" edge to the MatchPlayer entity.
|
||||
func (sc *SprayCreate) SetMatchPlayers(m *MatchPlayer) *SprayCreate {
|
||||
return sc.SetMatchPlayersID(m.ID)
|
||||
func (_c *SprayCreate) SetMatchPlayers(v *MatchPlayer) *SprayCreate {
|
||||
return _c.SetMatchPlayersID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the SprayMutation object of the builder.
|
||||
func (sc *SprayCreate) Mutation() *SprayMutation {
|
||||
return sc.mutation
|
||||
func (_c *SprayCreate) Mutation() *SprayMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the Spray in the database.
|
||||
func (sc *SprayCreate) Save(ctx context.Context) (*Spray, error) {
|
||||
return withHooks(ctx, sc.sqlSave, sc.mutation, sc.hooks)
|
||||
func (_c *SprayCreate) Save(ctx context.Context) (*Spray, error) {
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (sc *SprayCreate) SaveX(ctx context.Context) *Spray {
|
||||
v, err := sc.Save(ctx)
|
||||
func (_c *SprayCreate) SaveX(ctx context.Context) *Spray {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -71,35 +71,35 @@ func (sc *SprayCreate) SaveX(ctx context.Context) *Spray {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (sc *SprayCreate) Exec(ctx context.Context) error {
|
||||
_, err := sc.Save(ctx)
|
||||
func (_c *SprayCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (sc *SprayCreate) ExecX(ctx context.Context) {
|
||||
if err := sc.Exec(ctx); err != nil {
|
||||
func (_c *SprayCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (sc *SprayCreate) check() error {
|
||||
if _, ok := sc.mutation.Weapon(); !ok {
|
||||
func (_c *SprayCreate) check() error {
|
||||
if _, ok := _c.mutation.Weapon(); !ok {
|
||||
return &ValidationError{Name: "weapon", err: errors.New(`ent: missing required field "Spray.weapon"`)}
|
||||
}
|
||||
if _, ok := sc.mutation.Spray(); !ok {
|
||||
if _, ok := _c.mutation.Spray(); !ok {
|
||||
return &ValidationError{Name: "spray", err: errors.New(`ent: missing required field "Spray.spray"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sc *SprayCreate) sqlSave(ctx context.Context) (*Spray, error) {
|
||||
if err := sc.check(); err != nil {
|
||||
func (_c *SprayCreate) sqlSave(ctx context.Context) (*Spray, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := sc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, sc.driver, _spec); err != nil {
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -107,25 +107,25 @@ func (sc *SprayCreate) sqlSave(ctx context.Context) (*Spray, error) {
|
||||
}
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = int(id)
|
||||
sc.mutation.id = &_node.ID
|
||||
sc.mutation.done = true
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (sc *SprayCreate) createSpec() (*Spray, *sqlgraph.CreateSpec) {
|
||||
func (_c *SprayCreate) createSpec() (*Spray, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Spray{config: sc.config}
|
||||
_node = &Spray{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(spray.Table, sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := sc.mutation.Weapon(); ok {
|
||||
if value, ok := _c.mutation.Weapon(); ok {
|
||||
_spec.SetField(spray.FieldWeapon, field.TypeInt, value)
|
||||
_node.Weapon = value
|
||||
}
|
||||
if value, ok := sc.mutation.Spray(); ok {
|
||||
if value, ok := _c.mutation.Spray(); ok {
|
||||
_spec.SetField(spray.FieldSpray, field.TypeBytes, value)
|
||||
_node.Spray = value
|
||||
}
|
||||
if nodes := sc.mutation.MatchPlayersIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.MatchPlayersIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -148,17 +148,21 @@ func (sc *SprayCreate) createSpec() (*Spray, *sqlgraph.CreateSpec) {
|
||||
// SprayCreateBulk is the builder for creating many Spray entities in bulk.
|
||||
type SprayCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*SprayCreate
|
||||
}
|
||||
|
||||
// Save creates the Spray entities in the database.
|
||||
func (scb *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(scb.builders))
|
||||
nodes := make([]*Spray, len(scb.builders))
|
||||
mutators := make([]Mutator, len(scb.builders))
|
||||
for i := range scb.builders {
|
||||
func (_c *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*Spray, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := scb.builders[i]
|
||||
builder := _c.builders[i]
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*SprayMutation)
|
||||
if !ok {
|
||||
@@ -171,11 +175,11 @@ func (scb *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) {
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, scb.builders[i+1].mutation)
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, scb.driver, spec); err != nil {
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -199,7 +203,7 @@ func (scb *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) {
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, scb.builders[0].mutation); err != nil {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -207,8 +211,8 @@ func (scb *SprayCreateBulk) Save(ctx context.Context) ([]*Spray, error) {
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (scb *SprayCreateBulk) SaveX(ctx context.Context) []*Spray {
|
||||
v, err := scb.Save(ctx)
|
||||
func (_c *SprayCreateBulk) SaveX(ctx context.Context) []*Spray {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -216,14 +220,14 @@ func (scb *SprayCreateBulk) SaveX(ctx context.Context) []*Spray {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (scb *SprayCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := scb.Save(ctx)
|
||||
func (_c *SprayCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (scb *SprayCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := scb.Exec(ctx); err != nil {
|
||||
func (_c *SprayCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,56 +20,56 @@ type SprayDelete struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the SprayDelete builder.
|
||||
func (sd *SprayDelete) Where(ps ...predicate.Spray) *SprayDelete {
|
||||
sd.mutation.Where(ps...)
|
||||
return sd
|
||||
func (_d *SprayDelete) Where(ps ...predicate.Spray) *SprayDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (sd *SprayDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, sd.sqlExec, sd.mutation, sd.hooks)
|
||||
func (_d *SprayDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (sd *SprayDelete) ExecX(ctx context.Context) int {
|
||||
n, err := sd.Exec(ctx)
|
||||
func (_d *SprayDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (sd *SprayDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
func (_d *SprayDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(spray.Table, sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt))
|
||||
if ps := sd.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, sd.driver, _spec)
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
sd.mutation.done = true
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// SprayDeleteOne is the builder for deleting a single Spray entity.
|
||||
type SprayDeleteOne struct {
|
||||
sd *SprayDelete
|
||||
_d *SprayDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the SprayDelete builder.
|
||||
func (sdo *SprayDeleteOne) Where(ps ...predicate.Spray) *SprayDeleteOne {
|
||||
sdo.sd.mutation.Where(ps...)
|
||||
return sdo
|
||||
func (_d *SprayDeleteOne) Where(ps ...predicate.Spray) *SprayDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (sdo *SprayDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := sdo.sd.Exec(ctx)
|
||||
func (_d *SprayDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
@@ -81,8 +81,8 @@ func (sdo *SprayDeleteOne) Exec(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (sdo *SprayDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := sdo.Exec(ctx); err != nil {
|
||||
func (_d *SprayDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
@@ -31,44 +32,44 @@ type SprayQuery struct {
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the SprayQuery builder.
|
||||
func (sq *SprayQuery) Where(ps ...predicate.Spray) *SprayQuery {
|
||||
sq.predicates = append(sq.predicates, ps...)
|
||||
return sq
|
||||
func (_q *SprayQuery) Where(ps ...predicate.Spray) *SprayQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (sq *SprayQuery) Limit(limit int) *SprayQuery {
|
||||
sq.ctx.Limit = &limit
|
||||
return sq
|
||||
func (_q *SprayQuery) Limit(limit int) *SprayQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (sq *SprayQuery) Offset(offset int) *SprayQuery {
|
||||
sq.ctx.Offset = &offset
|
||||
return sq
|
||||
func (_q *SprayQuery) Offset(offset int) *SprayQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (sq *SprayQuery) Unique(unique bool) *SprayQuery {
|
||||
sq.ctx.Unique = &unique
|
||||
return sq
|
||||
func (_q *SprayQuery) Unique(unique bool) *SprayQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (sq *SprayQuery) Order(o ...spray.OrderOption) *SprayQuery {
|
||||
sq.order = append(sq.order, o...)
|
||||
return sq
|
||||
func (_q *SprayQuery) Order(o ...spray.OrderOption) *SprayQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryMatchPlayers chains the current query on the "match_players" edge.
|
||||
func (sq *SprayQuery) QueryMatchPlayers() *MatchPlayerQuery {
|
||||
query := (&MatchPlayerClient{config: sq.config}).Query()
|
||||
func (_q *SprayQuery) QueryMatchPlayers() *MatchPlayerQuery {
|
||||
query := (&MatchPlayerClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := sq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := sq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -77,7 +78,7 @@ func (sq *SprayQuery) QueryMatchPlayers() *MatchPlayerQuery {
|
||||
sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, spray.MatchPlayersTable, spray.MatchPlayersColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(sq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
@@ -85,8 +86,8 @@ func (sq *SprayQuery) QueryMatchPlayers() *MatchPlayerQuery {
|
||||
|
||||
// First returns the first Spray entity from the query.
|
||||
// Returns a *NotFoundError when no Spray was found.
|
||||
func (sq *SprayQuery) First(ctx context.Context) (*Spray, error) {
|
||||
nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, "First"))
|
||||
func (_q *SprayQuery) First(ctx context.Context) (*Spray, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -97,8 +98,8 @@ func (sq *SprayQuery) First(ctx context.Context) (*Spray, error) {
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (sq *SprayQuery) FirstX(ctx context.Context) *Spray {
|
||||
node, err := sq.First(ctx)
|
||||
func (_q *SprayQuery) FirstX(ctx context.Context) *Spray {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -107,9 +108,9 @@ func (sq *SprayQuery) FirstX(ctx context.Context) *Spray {
|
||||
|
||||
// FirstID returns the first Spray ID from the query.
|
||||
// Returns a *NotFoundError when no Spray ID was found.
|
||||
func (sq *SprayQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
func (_q *SprayQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, "FirstID")); err != nil {
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
@@ -120,8 +121,8 @@ func (sq *SprayQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (sq *SprayQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := sq.FirstID(ctx)
|
||||
func (_q *SprayQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -131,8 +132,8 @@ func (sq *SprayQuery) FirstIDX(ctx context.Context) int {
|
||||
// Only returns a single Spray entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one Spray entity is found.
|
||||
// Returns a *NotFoundError when no Spray entities are found.
|
||||
func (sq *SprayQuery) Only(ctx context.Context) (*Spray, error) {
|
||||
nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, "Only"))
|
||||
func (_q *SprayQuery) Only(ctx context.Context) (*Spray, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -147,8 +148,8 @@ func (sq *SprayQuery) Only(ctx context.Context) (*Spray, error) {
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (sq *SprayQuery) OnlyX(ctx context.Context) *Spray {
|
||||
node, err := sq.Only(ctx)
|
||||
func (_q *SprayQuery) OnlyX(ctx context.Context) *Spray {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -158,9 +159,9 @@ func (sq *SprayQuery) OnlyX(ctx context.Context) *Spray {
|
||||
// OnlyID is like Only, but returns the only Spray ID in the query.
|
||||
// Returns a *NotSingularError when more than one Spray ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (sq *SprayQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
func (_q *SprayQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = sq.Limit(2).IDs(setContextOp(ctx, sq.ctx, "OnlyID")); err != nil {
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
@@ -175,8 +176,8 @@ func (sq *SprayQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (sq *SprayQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := sq.OnlyID(ctx)
|
||||
func (_q *SprayQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -184,18 +185,18 @@ func (sq *SprayQuery) OnlyIDX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of Sprays.
|
||||
func (sq *SprayQuery) All(ctx context.Context) ([]*Spray, error) {
|
||||
ctx = setContextOp(ctx, sq.ctx, "All")
|
||||
if err := sq.prepareQuery(ctx); err != nil {
|
||||
func (_q *SprayQuery) All(ctx context.Context) ([]*Spray, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*Spray, *SprayQuery]()
|
||||
return withInterceptors[[]*Spray](ctx, sq, qr, sq.inters)
|
||||
return withInterceptors[[]*Spray](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (sq *SprayQuery) AllX(ctx context.Context) []*Spray {
|
||||
nodes, err := sq.All(ctx)
|
||||
func (_q *SprayQuery) AllX(ctx context.Context) []*Spray {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -203,20 +204,20 @@ func (sq *SprayQuery) AllX(ctx context.Context) []*Spray {
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Spray IDs.
|
||||
func (sq *SprayQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if sq.ctx.Unique == nil && sq.path != nil {
|
||||
sq.Unique(true)
|
||||
func (_q *SprayQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, sq.ctx, "IDs")
|
||||
if err = sq.Select(spray.FieldID).Scan(ctx, &ids); err != nil {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(spray.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (sq *SprayQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := sq.IDs(ctx)
|
||||
func (_q *SprayQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -224,17 +225,17 @@ func (sq *SprayQuery) IDsX(ctx context.Context) []int {
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (sq *SprayQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, sq.ctx, "Count")
|
||||
if err := sq.prepareQuery(ctx); err != nil {
|
||||
func (_q *SprayQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, sq, querierCount[*SprayQuery](), sq.inters)
|
||||
return withInterceptors[int](ctx, _q, querierCount[*SprayQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (sq *SprayQuery) CountX(ctx context.Context) int {
|
||||
count, err := sq.Count(ctx)
|
||||
func (_q *SprayQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -242,9 +243,9 @@ func (sq *SprayQuery) CountX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (sq *SprayQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, sq.ctx, "Exist")
|
||||
switch _, err := sq.FirstID(ctx); {
|
||||
func (_q *SprayQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
@@ -255,8 +256,8 @@ func (sq *SprayQuery) Exist(ctx context.Context) (bool, error) {
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (sq *SprayQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := sq.Exist(ctx)
|
||||
func (_q *SprayQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -265,32 +266,33 @@ func (sq *SprayQuery) ExistX(ctx context.Context) bool {
|
||||
|
||||
// Clone returns a duplicate of the SprayQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (sq *SprayQuery) Clone() *SprayQuery {
|
||||
if sq == nil {
|
||||
func (_q *SprayQuery) Clone() *SprayQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &SprayQuery{
|
||||
config: sq.config,
|
||||
ctx: sq.ctx.Clone(),
|
||||
order: append([]spray.OrderOption{}, sq.order...),
|
||||
inters: append([]Interceptor{}, sq.inters...),
|
||||
predicates: append([]predicate.Spray{}, sq.predicates...),
|
||||
withMatchPlayers: sq.withMatchPlayers.Clone(),
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]spray.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.Spray{}, _q.predicates...),
|
||||
withMatchPlayers: _q.withMatchPlayers.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: sq.sql.Clone(),
|
||||
path: sq.path,
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
modifiers: append([]func(*sql.Selector){}, _q.modifiers...),
|
||||
}
|
||||
}
|
||||
|
||||
// WithMatchPlayers tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "match_players" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (sq *SprayQuery) WithMatchPlayers(opts ...func(*MatchPlayerQuery)) *SprayQuery {
|
||||
query := (&MatchPlayerClient{config: sq.config}).Query()
|
||||
func (_q *SprayQuery) WithMatchPlayers(opts ...func(*MatchPlayerQuery)) *SprayQuery {
|
||||
query := (&MatchPlayerClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
sq.withMatchPlayers = query
|
||||
return sq
|
||||
_q.withMatchPlayers = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
@@ -307,10 +309,10 @@ func (sq *SprayQuery) WithMatchPlayers(opts ...func(*MatchPlayerQuery)) *SprayQu
|
||||
// GroupBy(spray.FieldWeapon).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (sq *SprayQuery) GroupBy(field string, fields ...string) *SprayGroupBy {
|
||||
sq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &SprayGroupBy{build: sq}
|
||||
grbuild.flds = &sq.ctx.Fields
|
||||
func (_q *SprayQuery) GroupBy(field string, fields ...string) *SprayGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &SprayGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = spray.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
@@ -328,55 +330,55 @@ func (sq *SprayQuery) GroupBy(field string, fields ...string) *SprayGroupBy {
|
||||
// client.Spray.Query().
|
||||
// Select(spray.FieldWeapon).
|
||||
// Scan(ctx, &v)
|
||||
func (sq *SprayQuery) Select(fields ...string) *SpraySelect {
|
||||
sq.ctx.Fields = append(sq.ctx.Fields, fields...)
|
||||
sbuild := &SpraySelect{SprayQuery: sq}
|
||||
func (_q *SprayQuery) Select(fields ...string) *SpraySelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &SpraySelect{SprayQuery: _q}
|
||||
sbuild.label = spray.Label
|
||||
sbuild.flds, sbuild.scan = &sq.ctx.Fields, sbuild.Scan
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a SpraySelect configured with the given aggregations.
|
||||
func (sq *SprayQuery) Aggregate(fns ...AggregateFunc) *SpraySelect {
|
||||
return sq.Select().Aggregate(fns...)
|
||||
func (_q *SprayQuery) Aggregate(fns ...AggregateFunc) *SpraySelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (sq *SprayQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range sq.inters {
|
||||
func (_q *SprayQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, sq); err != nil {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range sq.ctx.Fields {
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !spray.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if sq.path != nil {
|
||||
prev, err := sq.path(ctx)
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
sq.sql = prev
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sq *SprayQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Spray, error) {
|
||||
func (_q *SprayQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Spray, error) {
|
||||
var (
|
||||
nodes = []*Spray{}
|
||||
withFKs = sq.withFKs
|
||||
_spec = sq.querySpec()
|
||||
withFKs = _q.withFKs
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
sq.withMatchPlayers != nil,
|
||||
_q.withMatchPlayers != nil,
|
||||
}
|
||||
)
|
||||
if sq.withMatchPlayers != nil {
|
||||
if _q.withMatchPlayers != nil {
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
@@ -386,25 +388,25 @@ func (sq *SprayQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Spray,
|
||||
return (*Spray).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &Spray{config: sq.config}
|
||||
node := &Spray{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
if len(sq.modifiers) > 0 {
|
||||
_spec.Modifiers = sq.modifiers
|
||||
if len(_q.modifiers) > 0 {
|
||||
_spec.Modifiers = _q.modifiers
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, sq.driver, _spec); err != nil {
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := sq.withMatchPlayers; query != nil {
|
||||
if err := sq.loadMatchPlayers(ctx, query, nodes, nil,
|
||||
if query := _q.withMatchPlayers; query != nil {
|
||||
if err := _q.loadMatchPlayers(ctx, query, nodes, nil,
|
||||
func(n *Spray, e *MatchPlayer) { n.Edges.MatchPlayers = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -412,7 +414,7 @@ func (sq *SprayQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Spray,
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (sq *SprayQuery) loadMatchPlayers(ctx context.Context, query *MatchPlayerQuery, nodes []*Spray, init func(*Spray), assign func(*Spray, *MatchPlayer)) error {
|
||||
func (_q *SprayQuery) loadMatchPlayers(ctx context.Context, query *MatchPlayerQuery, nodes []*Spray, init func(*Spray), assign func(*Spray, *MatchPlayer)) error {
|
||||
ids := make([]int, 0, len(nodes))
|
||||
nodeids := make(map[int][]*Spray)
|
||||
for i := range nodes {
|
||||
@@ -445,27 +447,27 @@ func (sq *SprayQuery) loadMatchPlayers(ctx context.Context, query *MatchPlayerQu
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sq *SprayQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := sq.querySpec()
|
||||
if len(sq.modifiers) > 0 {
|
||||
_spec.Modifiers = sq.modifiers
|
||||
func (_q *SprayQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
if len(_q.modifiers) > 0 {
|
||||
_spec.Modifiers = _q.modifiers
|
||||
}
|
||||
_spec.Node.Columns = sq.ctx.Fields
|
||||
if len(sq.ctx.Fields) > 0 {
|
||||
_spec.Unique = sq.ctx.Unique != nil && *sq.ctx.Unique
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, sq.driver, _spec)
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (sq *SprayQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
func (_q *SprayQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(spray.Table, spray.Columns, sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt))
|
||||
_spec.From = sq.sql
|
||||
if unique := sq.ctx.Unique; unique != nil {
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if sq.path != nil {
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := sq.ctx.Fields; len(fields) > 0 {
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, spray.FieldID)
|
||||
for i := range fields {
|
||||
@@ -474,20 +476,20 @@ func (sq *SprayQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := sq.predicates; len(ps) > 0 {
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := sq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := sq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := sq.order; len(ps) > 0 {
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
@@ -497,45 +499,45 @@ func (sq *SprayQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (sq *SprayQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(sq.driver.Dialect())
|
||||
func (_q *SprayQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(spray.Table)
|
||||
columns := sq.ctx.Fields
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = spray.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if sq.sql != nil {
|
||||
selector = sq.sql
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if sq.ctx.Unique != nil && *sq.ctx.Unique {
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, m := range sq.modifiers {
|
||||
for _, m := range _q.modifiers {
|
||||
m(selector)
|
||||
}
|
||||
for _, p := range sq.predicates {
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range sq.order {
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := sq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := sq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// Modify adds a query modifier for attaching custom logic to queries.
|
||||
func (sq *SprayQuery) Modify(modifiers ...func(s *sql.Selector)) *SpraySelect {
|
||||
sq.modifiers = append(sq.modifiers, modifiers...)
|
||||
return sq.Select()
|
||||
func (_q *SprayQuery) Modify(modifiers ...func(s *sql.Selector)) *SpraySelect {
|
||||
_q.modifiers = append(_q.modifiers, modifiers...)
|
||||
return _q.Select()
|
||||
}
|
||||
|
||||
// SprayGroupBy is the group-by builder for Spray entities.
|
||||
@@ -545,41 +547,41 @@ type SprayGroupBy struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (sgb *SprayGroupBy) Aggregate(fns ...AggregateFunc) *SprayGroupBy {
|
||||
sgb.fns = append(sgb.fns, fns...)
|
||||
return sgb
|
||||
func (_g *SprayGroupBy) Aggregate(fns ...AggregateFunc) *SprayGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (sgb *SprayGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, sgb.build.ctx, "GroupBy")
|
||||
if err := sgb.build.prepareQuery(ctx); err != nil {
|
||||
func (_g *SprayGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*SprayQuery, *SprayGroupBy](ctx, sgb.build, sgb, sgb.build.inters, v)
|
||||
return scanWithInterceptors[*SprayQuery, *SprayGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (sgb *SprayGroupBy) sqlScan(ctx context.Context, root *SprayQuery, v any) error {
|
||||
func (_g *SprayGroupBy) sqlScan(ctx context.Context, root *SprayQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(sgb.fns))
|
||||
for _, fn := range sgb.fns {
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*sgb.flds)+len(sgb.fns))
|
||||
for _, f := range *sgb.flds {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*sgb.flds...)...)
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := sgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -593,27 +595,27 @@ type SpraySelect struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (ss *SpraySelect) Aggregate(fns ...AggregateFunc) *SpraySelect {
|
||||
ss.fns = append(ss.fns, fns...)
|
||||
return ss
|
||||
func (_s *SpraySelect) Aggregate(fns ...AggregateFunc) *SpraySelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ss *SpraySelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, ss.ctx, "Select")
|
||||
if err := ss.prepareQuery(ctx); err != nil {
|
||||
func (_s *SpraySelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*SprayQuery, *SpraySelect](ctx, ss.SprayQuery, ss, ss.inters, v)
|
||||
return scanWithInterceptors[*SprayQuery, *SpraySelect](ctx, _s.SprayQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (ss *SpraySelect) sqlScan(ctx context.Context, root *SprayQuery, v any) error {
|
||||
func (_s *SpraySelect) sqlScan(ctx context.Context, root *SprayQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(ss.fns))
|
||||
for _, fn := range ss.fns {
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*ss.selector.flds); {
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
@@ -621,7 +623,7 @@ func (ss *SpraySelect) sqlScan(ctx context.Context, root *SprayQuery, v any) err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := ss.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -629,7 +631,7 @@ func (ss *SpraySelect) sqlScan(ctx context.Context, root *SprayQuery, v any) err
|
||||
}
|
||||
|
||||
// Modify adds a query modifier for attaching custom logic to queries.
|
||||
func (ss *SpraySelect) Modify(modifiers ...func(s *sql.Selector)) *SpraySelect {
|
||||
ss.modifiers = append(ss.modifiers, modifiers...)
|
||||
return ss
|
||||
func (_s *SpraySelect) Modify(modifiers ...func(s *sql.Selector)) *SpraySelect {
|
||||
_s.modifiers = append(_s.modifiers, modifiers...)
|
||||
return _s
|
||||
}
|
||||
|
||||
@@ -24,68 +24,76 @@ type SprayUpdate struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the SprayUpdate builder.
|
||||
func (su *SprayUpdate) Where(ps ...predicate.Spray) *SprayUpdate {
|
||||
su.mutation.Where(ps...)
|
||||
return su
|
||||
func (_u *SprayUpdate) Where(ps ...predicate.Spray) *SprayUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetWeapon sets the "weapon" field.
|
||||
func (su *SprayUpdate) SetWeapon(i int) *SprayUpdate {
|
||||
su.mutation.ResetWeapon()
|
||||
su.mutation.SetWeapon(i)
|
||||
return su
|
||||
func (_u *SprayUpdate) SetWeapon(v int) *SprayUpdate {
|
||||
_u.mutation.ResetWeapon()
|
||||
_u.mutation.SetWeapon(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddWeapon adds i to the "weapon" field.
|
||||
func (su *SprayUpdate) AddWeapon(i int) *SprayUpdate {
|
||||
su.mutation.AddWeapon(i)
|
||||
return su
|
||||
// SetNillableWeapon sets the "weapon" field if the given value is not nil.
|
||||
func (_u *SprayUpdate) SetNillableWeapon(v *int) *SprayUpdate {
|
||||
if v != nil {
|
||||
_u.SetWeapon(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddWeapon adds value to the "weapon" field.
|
||||
func (_u *SprayUpdate) AddWeapon(v int) *SprayUpdate {
|
||||
_u.mutation.AddWeapon(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSpray sets the "spray" field.
|
||||
func (su *SprayUpdate) SetSpray(b []byte) *SprayUpdate {
|
||||
su.mutation.SetSpray(b)
|
||||
return su
|
||||
func (_u *SprayUpdate) SetSpray(v []byte) *SprayUpdate {
|
||||
_u.mutation.SetSpray(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID.
|
||||
func (su *SprayUpdate) SetMatchPlayersID(id int) *SprayUpdate {
|
||||
su.mutation.SetMatchPlayersID(id)
|
||||
return su
|
||||
func (_u *SprayUpdate) SetMatchPlayersID(id int) *SprayUpdate {
|
||||
_u.mutation.SetMatchPlayersID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID if the given value is not nil.
|
||||
func (su *SprayUpdate) SetNillableMatchPlayersID(id *int) *SprayUpdate {
|
||||
func (_u *SprayUpdate) SetNillableMatchPlayersID(id *int) *SprayUpdate {
|
||||
if id != nil {
|
||||
su = su.SetMatchPlayersID(*id)
|
||||
_u = _u.SetMatchPlayersID(*id)
|
||||
}
|
||||
return su
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetMatchPlayers sets the "match_players" edge to the MatchPlayer entity.
|
||||
func (su *SprayUpdate) SetMatchPlayers(m *MatchPlayer) *SprayUpdate {
|
||||
return su.SetMatchPlayersID(m.ID)
|
||||
func (_u *SprayUpdate) SetMatchPlayers(v *MatchPlayer) *SprayUpdate {
|
||||
return _u.SetMatchPlayersID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the SprayMutation object of the builder.
|
||||
func (su *SprayUpdate) Mutation() *SprayMutation {
|
||||
return su.mutation
|
||||
func (_u *SprayUpdate) Mutation() *SprayMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearMatchPlayers clears the "match_players" edge to the MatchPlayer entity.
|
||||
func (su *SprayUpdate) ClearMatchPlayers() *SprayUpdate {
|
||||
su.mutation.ClearMatchPlayers()
|
||||
return su
|
||||
func (_u *SprayUpdate) ClearMatchPlayers() *SprayUpdate {
|
||||
_u.mutation.ClearMatchPlayers()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (su *SprayUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, su.sqlSave, su.mutation, su.hooks)
|
||||
func (_u *SprayUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (su *SprayUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := su.Save(ctx)
|
||||
func (_u *SprayUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -93,43 +101,43 @@ func (su *SprayUpdate) SaveX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (su *SprayUpdate) Exec(ctx context.Context) error {
|
||||
_, err := su.Save(ctx)
|
||||
func (_u *SprayUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (su *SprayUpdate) ExecX(ctx context.Context) {
|
||||
if err := su.Exec(ctx); err != nil {
|
||||
func (_u *SprayUpdate) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
||||
func (su *SprayUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SprayUpdate {
|
||||
su.modifiers = append(su.modifiers, modifiers...)
|
||||
return su
|
||||
func (_u *SprayUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SprayUpdate {
|
||||
_u.modifiers = append(_u.modifiers, modifiers...)
|
||||
return _u
|
||||
}
|
||||
|
||||
func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
func (_u *SprayUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(spray.Table, spray.Columns, sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt))
|
||||
if ps := su.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := su.mutation.Weapon(); ok {
|
||||
if value, ok := _u.mutation.Weapon(); ok {
|
||||
_spec.SetField(spray.FieldWeapon, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := su.mutation.AddedWeapon(); ok {
|
||||
if value, ok := _u.mutation.AddedWeapon(); ok {
|
||||
_spec.AddField(spray.FieldWeapon, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := su.mutation.Spray(); ok {
|
||||
if value, ok := _u.mutation.Spray(); ok {
|
||||
_spec.SetField(spray.FieldSpray, field.TypeBytes, value)
|
||||
}
|
||||
if su.mutation.MatchPlayersCleared() {
|
||||
if _u.mutation.MatchPlayersCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -142,7 +150,7 @@ func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := su.mutation.MatchPlayersIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.MatchPlayersIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -158,8 +166,8 @@ func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_spec.AddModifiers(su.modifiers...)
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, su.driver, _spec); err != nil {
|
||||
_spec.AddModifiers(_u.modifiers...)
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{spray.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -167,8 +175,8 @@ func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
su.mutation.done = true
|
||||
return n, nil
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// SprayUpdateOne is the builder for updating a single Spray entity.
|
||||
@@ -181,75 +189,83 @@ type SprayUpdateOne struct {
|
||||
}
|
||||
|
||||
// SetWeapon sets the "weapon" field.
|
||||
func (suo *SprayUpdateOne) SetWeapon(i int) *SprayUpdateOne {
|
||||
suo.mutation.ResetWeapon()
|
||||
suo.mutation.SetWeapon(i)
|
||||
return suo
|
||||
func (_u *SprayUpdateOne) SetWeapon(v int) *SprayUpdateOne {
|
||||
_u.mutation.ResetWeapon()
|
||||
_u.mutation.SetWeapon(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddWeapon adds i to the "weapon" field.
|
||||
func (suo *SprayUpdateOne) AddWeapon(i int) *SprayUpdateOne {
|
||||
suo.mutation.AddWeapon(i)
|
||||
return suo
|
||||
// SetNillableWeapon sets the "weapon" field if the given value is not nil.
|
||||
func (_u *SprayUpdateOne) SetNillableWeapon(v *int) *SprayUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetWeapon(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddWeapon adds value to the "weapon" field.
|
||||
func (_u *SprayUpdateOne) AddWeapon(v int) *SprayUpdateOne {
|
||||
_u.mutation.AddWeapon(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetSpray sets the "spray" field.
|
||||
func (suo *SprayUpdateOne) SetSpray(b []byte) *SprayUpdateOne {
|
||||
suo.mutation.SetSpray(b)
|
||||
return suo
|
||||
func (_u *SprayUpdateOne) SetSpray(v []byte) *SprayUpdateOne {
|
||||
_u.mutation.SetSpray(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID.
|
||||
func (suo *SprayUpdateOne) SetMatchPlayersID(id int) *SprayUpdateOne {
|
||||
suo.mutation.SetMatchPlayersID(id)
|
||||
return suo
|
||||
func (_u *SprayUpdateOne) SetMatchPlayersID(id int) *SprayUpdateOne {
|
||||
_u.mutation.SetMatchPlayersID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableMatchPlayersID sets the "match_players" edge to the MatchPlayer entity by ID if the given value is not nil.
|
||||
func (suo *SprayUpdateOne) SetNillableMatchPlayersID(id *int) *SprayUpdateOne {
|
||||
func (_u *SprayUpdateOne) SetNillableMatchPlayersID(id *int) *SprayUpdateOne {
|
||||
if id != nil {
|
||||
suo = suo.SetMatchPlayersID(*id)
|
||||
_u = _u.SetMatchPlayersID(*id)
|
||||
}
|
||||
return suo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetMatchPlayers sets the "match_players" edge to the MatchPlayer entity.
|
||||
func (suo *SprayUpdateOne) SetMatchPlayers(m *MatchPlayer) *SprayUpdateOne {
|
||||
return suo.SetMatchPlayersID(m.ID)
|
||||
func (_u *SprayUpdateOne) SetMatchPlayers(v *MatchPlayer) *SprayUpdateOne {
|
||||
return _u.SetMatchPlayersID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the SprayMutation object of the builder.
|
||||
func (suo *SprayUpdateOne) Mutation() *SprayMutation {
|
||||
return suo.mutation
|
||||
func (_u *SprayUpdateOne) Mutation() *SprayMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearMatchPlayers clears the "match_players" edge to the MatchPlayer entity.
|
||||
func (suo *SprayUpdateOne) ClearMatchPlayers() *SprayUpdateOne {
|
||||
suo.mutation.ClearMatchPlayers()
|
||||
return suo
|
||||
func (_u *SprayUpdateOne) ClearMatchPlayers() *SprayUpdateOne {
|
||||
_u.mutation.ClearMatchPlayers()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the SprayUpdate builder.
|
||||
func (suo *SprayUpdateOne) Where(ps ...predicate.Spray) *SprayUpdateOne {
|
||||
suo.mutation.Where(ps...)
|
||||
return suo
|
||||
func (_u *SprayUpdateOne) Where(ps ...predicate.Spray) *SprayUpdateOne {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (suo *SprayUpdateOne) Select(field string, fields ...string) *SprayUpdateOne {
|
||||
suo.fields = append([]string{field}, fields...)
|
||||
return suo
|
||||
func (_u *SprayUpdateOne) Select(field string, fields ...string) *SprayUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated Spray entity.
|
||||
func (suo *SprayUpdateOne) Save(ctx context.Context) (*Spray, error) {
|
||||
return withHooks(ctx, suo.sqlSave, suo.mutation, suo.hooks)
|
||||
func (_u *SprayUpdateOne) Save(ctx context.Context) (*Spray, error) {
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (suo *SprayUpdateOne) SaveX(ctx context.Context) *Spray {
|
||||
node, err := suo.Save(ctx)
|
||||
func (_u *SprayUpdateOne) SaveX(ctx context.Context) *Spray {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -257,32 +273,32 @@ func (suo *SprayUpdateOne) SaveX(ctx context.Context) *Spray {
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (suo *SprayUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := suo.Save(ctx)
|
||||
func (_u *SprayUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (suo *SprayUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := suo.Exec(ctx); err != nil {
|
||||
func (_u *SprayUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
||||
func (suo *SprayUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SprayUpdateOne {
|
||||
suo.modifiers = append(suo.modifiers, modifiers...)
|
||||
return suo
|
||||
func (_u *SprayUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SprayUpdateOne {
|
||||
_u.modifiers = append(_u.modifiers, modifiers...)
|
||||
return _u
|
||||
}
|
||||
|
||||
func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error) {
|
||||
func (_u *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(spray.Table, spray.Columns, sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt))
|
||||
id, ok := suo.mutation.ID()
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Spray.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := suo.fields; len(fields) > 0 {
|
||||
if fields := _u.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, spray.FieldID)
|
||||
for _, f := range fields {
|
||||
@@ -294,23 +310,23 @@ func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := suo.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := suo.mutation.Weapon(); ok {
|
||||
if value, ok := _u.mutation.Weapon(); ok {
|
||||
_spec.SetField(spray.FieldWeapon, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := suo.mutation.AddedWeapon(); ok {
|
||||
if value, ok := _u.mutation.AddedWeapon(); ok {
|
||||
_spec.AddField(spray.FieldWeapon, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := suo.mutation.Spray(); ok {
|
||||
if value, ok := _u.mutation.Spray(); ok {
|
||||
_spec.SetField(spray.FieldSpray, field.TypeBytes, value)
|
||||
}
|
||||
if suo.mutation.MatchPlayersCleared() {
|
||||
if _u.mutation.MatchPlayersCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -323,7 +339,7 @@ func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := suo.mutation.MatchPlayersIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.MatchPlayersIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -339,11 +355,11 @@ func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_spec.AddModifiers(suo.modifiers...)
|
||||
_node = &Spray{config: suo.config}
|
||||
_spec.AddModifiers(_u.modifiers...)
|
||||
_node = &Spray{config: _u.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, suo.driver, _spec); err != nil {
|
||||
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{spray.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -351,6 +367,6 @@ func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
suo.mutation.done = true
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
@@ -44,12 +44,10 @@ type WeaponEdges struct {
|
||||
// StatOrErr returns the Stat value or an error if the edge
|
||||
// was not loaded in eager-loading, or loaded but was not found.
|
||||
func (e WeaponEdges) StatOrErr() (*MatchPlayer, error) {
|
||||
if e.loadedTypes[0] {
|
||||
if e.Stat == nil {
|
||||
// Edge was loaded but was not found.
|
||||
return nil, &NotFoundError{label: matchplayer.Label}
|
||||
}
|
||||
if e.Stat != nil {
|
||||
return e.Stat, nil
|
||||
} else if e.loadedTypes[0] {
|
||||
return nil, &NotFoundError{label: matchplayer.Label}
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "stat"}
|
||||
}
|
||||
@@ -72,7 +70,7 @@ func (*Weapon) scanValues(columns []string) ([]any, error) {
|
||||
|
||||
// assignValues assigns the values that were returned from sql.Rows (after scanning)
|
||||
// to the Weapon fields.
|
||||
func (w *Weapon) assignValues(columns []string, values []any) error {
|
||||
func (_m *Weapon) assignValues(columns []string, values []any) error {
|
||||
if m, n := len(values), len(columns); m < n {
|
||||
return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
|
||||
}
|
||||
@@ -83,40 +81,40 @@ func (w *Weapon) assignValues(columns []string, values []any) error {
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
w.ID = int(value.Int64)
|
||||
_m.ID = int(value.Int64)
|
||||
case weapon.FieldVictim:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field victim", values[i])
|
||||
} else if value.Valid {
|
||||
w.Victim = uint64(value.Int64)
|
||||
_m.Victim = uint64(value.Int64)
|
||||
}
|
||||
case weapon.FieldDmg:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field dmg", values[i])
|
||||
} else if value.Valid {
|
||||
w.Dmg = uint(value.Int64)
|
||||
_m.Dmg = uint(value.Int64)
|
||||
}
|
||||
case weapon.FieldEqType:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field eq_type", values[i])
|
||||
} else if value.Valid {
|
||||
w.EqType = int(value.Int64)
|
||||
_m.EqType = int(value.Int64)
|
||||
}
|
||||
case weapon.FieldHitGroup:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field hit_group", values[i])
|
||||
} else if value.Valid {
|
||||
w.HitGroup = int(value.Int64)
|
||||
_m.HitGroup = int(value.Int64)
|
||||
}
|
||||
case weapon.ForeignKeys[0]:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for edge-field match_player_weapon_stats", value)
|
||||
} else if value.Valid {
|
||||
w.match_player_weapon_stats = new(int)
|
||||
*w.match_player_weapon_stats = int(value.Int64)
|
||||
_m.match_player_weapon_stats = new(int)
|
||||
*_m.match_player_weapon_stats = int(value.Int64)
|
||||
}
|
||||
default:
|
||||
w.selectValues.Set(columns[i], values[i])
|
||||
_m.selectValues.Set(columns[i], values[i])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -124,49 +122,49 @@ func (w *Weapon) assignValues(columns []string, values []any) error {
|
||||
|
||||
// Value returns the ent.Value that was dynamically selected and assigned to the Weapon.
|
||||
// This includes values selected through modifiers, order, etc.
|
||||
func (w *Weapon) Value(name string) (ent.Value, error) {
|
||||
return w.selectValues.Get(name)
|
||||
func (_m *Weapon) Value(name string) (ent.Value, error) {
|
||||
return _m.selectValues.Get(name)
|
||||
}
|
||||
|
||||
// QueryStat queries the "stat" edge of the Weapon entity.
|
||||
func (w *Weapon) QueryStat() *MatchPlayerQuery {
|
||||
return NewWeaponClient(w.config).QueryStat(w)
|
||||
func (_m *Weapon) QueryStat() *MatchPlayerQuery {
|
||||
return NewWeaponClient(_m.config).QueryStat(_m)
|
||||
}
|
||||
|
||||
// Update returns a builder for updating this Weapon.
|
||||
// Note that you need to call Weapon.Unwrap() before calling this method if this Weapon
|
||||
// was returned from a transaction, and the transaction was committed or rolled back.
|
||||
func (w *Weapon) Update() *WeaponUpdateOne {
|
||||
return NewWeaponClient(w.config).UpdateOne(w)
|
||||
func (_m *Weapon) Update() *WeaponUpdateOne {
|
||||
return NewWeaponClient(_m.config).UpdateOne(_m)
|
||||
}
|
||||
|
||||
// Unwrap unwraps the Weapon entity that was returned from a transaction after it was closed,
|
||||
// so that all future queries will be executed through the driver which created the transaction.
|
||||
func (w *Weapon) Unwrap() *Weapon {
|
||||
_tx, ok := w.config.driver.(*txDriver)
|
||||
func (_m *Weapon) Unwrap() *Weapon {
|
||||
_tx, ok := _m.config.driver.(*txDriver)
|
||||
if !ok {
|
||||
panic("ent: Weapon is not a transactional entity")
|
||||
}
|
||||
w.config.driver = _tx.drv
|
||||
return w
|
||||
_m.config.driver = _tx.drv
|
||||
return _m
|
||||
}
|
||||
|
||||
// String implements the fmt.Stringer.
|
||||
func (w *Weapon) String() string {
|
||||
func (_m *Weapon) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("Weapon(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", w.ID))
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("victim=")
|
||||
builder.WriteString(fmt.Sprintf("%v", w.Victim))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Victim))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("dmg=")
|
||||
builder.WriteString(fmt.Sprintf("%v", w.Dmg))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Dmg))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("eq_type=")
|
||||
builder.WriteString(fmt.Sprintf("%v", w.EqType))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.EqType))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("hit_group=")
|
||||
builder.WriteString(fmt.Sprintf("%v", w.HitGroup))
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.HitGroup))
|
||||
builder.WriteByte(')')
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
@@ -258,32 +258,15 @@ func HasStatWith(preds ...predicate.MatchPlayer) predicate.Weapon {
|
||||
|
||||
// And groups predicates with the AND operator between them.
|
||||
func And(predicates ...predicate.Weapon) predicate.Weapon {
|
||||
return predicate.Weapon(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for _, p := range predicates {
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
return predicate.Weapon(sql.AndPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Or groups predicates with the OR operator between them.
|
||||
func Or(predicates ...predicate.Weapon) predicate.Weapon {
|
||||
return predicate.Weapon(func(s *sql.Selector) {
|
||||
s1 := s.Clone().SetP(nil)
|
||||
for i, p := range predicates {
|
||||
if i > 0 {
|
||||
s1.Or()
|
||||
}
|
||||
p(s1)
|
||||
}
|
||||
s.Where(s1.P())
|
||||
})
|
||||
return predicate.Weapon(sql.OrPredicates(predicates...))
|
||||
}
|
||||
|
||||
// Not applies the not operator on the given predicate.
|
||||
func Not(p predicate.Weapon) predicate.Weapon {
|
||||
return predicate.Weapon(func(s *sql.Selector) {
|
||||
p(s.Not())
|
||||
})
|
||||
return predicate.Weapon(sql.NotPredicates(p))
|
||||
}
|
||||
|
||||
@@ -21,61 +21,61 @@ type WeaponCreate struct {
|
||||
}
|
||||
|
||||
// SetVictim sets the "victim" field.
|
||||
func (wc *WeaponCreate) SetVictim(u uint64) *WeaponCreate {
|
||||
wc.mutation.SetVictim(u)
|
||||
return wc
|
||||
func (_c *WeaponCreate) SetVictim(v uint64) *WeaponCreate {
|
||||
_c.mutation.SetVictim(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetDmg sets the "dmg" field.
|
||||
func (wc *WeaponCreate) SetDmg(u uint) *WeaponCreate {
|
||||
wc.mutation.SetDmg(u)
|
||||
return wc
|
||||
func (_c *WeaponCreate) SetDmg(v uint) *WeaponCreate {
|
||||
_c.mutation.SetDmg(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetEqType sets the "eq_type" field.
|
||||
func (wc *WeaponCreate) SetEqType(i int) *WeaponCreate {
|
||||
wc.mutation.SetEqType(i)
|
||||
return wc
|
||||
func (_c *WeaponCreate) SetEqType(v int) *WeaponCreate {
|
||||
_c.mutation.SetEqType(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetHitGroup sets the "hit_group" field.
|
||||
func (wc *WeaponCreate) SetHitGroup(i int) *WeaponCreate {
|
||||
wc.mutation.SetHitGroup(i)
|
||||
return wc
|
||||
func (_c *WeaponCreate) SetHitGroup(v int) *WeaponCreate {
|
||||
_c.mutation.SetHitGroup(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetStatID sets the "stat" edge to the MatchPlayer entity by ID.
|
||||
func (wc *WeaponCreate) SetStatID(id int) *WeaponCreate {
|
||||
wc.mutation.SetStatID(id)
|
||||
return wc
|
||||
func (_c *WeaponCreate) SetStatID(id int) *WeaponCreate {
|
||||
_c.mutation.SetStatID(id)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableStatID sets the "stat" edge to the MatchPlayer entity by ID if the given value is not nil.
|
||||
func (wc *WeaponCreate) SetNillableStatID(id *int) *WeaponCreate {
|
||||
func (_c *WeaponCreate) SetNillableStatID(id *int) *WeaponCreate {
|
||||
if id != nil {
|
||||
wc = wc.SetStatID(*id)
|
||||
_c = _c.SetStatID(*id)
|
||||
}
|
||||
return wc
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetStat sets the "stat" edge to the MatchPlayer entity.
|
||||
func (wc *WeaponCreate) SetStat(m *MatchPlayer) *WeaponCreate {
|
||||
return wc.SetStatID(m.ID)
|
||||
func (_c *WeaponCreate) SetStat(v *MatchPlayer) *WeaponCreate {
|
||||
return _c.SetStatID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the WeaponMutation object of the builder.
|
||||
func (wc *WeaponCreate) Mutation() *WeaponMutation {
|
||||
return wc.mutation
|
||||
func (_c *WeaponCreate) Mutation() *WeaponMutation {
|
||||
return _c.mutation
|
||||
}
|
||||
|
||||
// Save creates the Weapon in the database.
|
||||
func (wc *WeaponCreate) Save(ctx context.Context) (*Weapon, error) {
|
||||
return withHooks(ctx, wc.sqlSave, wc.mutation, wc.hooks)
|
||||
func (_c *WeaponCreate) Save(ctx context.Context) (*Weapon, error) {
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
// SaveX calls Save and panics if Save returns an error.
|
||||
func (wc *WeaponCreate) SaveX(ctx context.Context) *Weapon {
|
||||
v, err := wc.Save(ctx)
|
||||
func (_c *WeaponCreate) SaveX(ctx context.Context) *Weapon {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -83,41 +83,41 @@ func (wc *WeaponCreate) SaveX(ctx context.Context) *Weapon {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (wc *WeaponCreate) Exec(ctx context.Context) error {
|
||||
_, err := wc.Save(ctx)
|
||||
func (_c *WeaponCreate) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (wc *WeaponCreate) ExecX(ctx context.Context) {
|
||||
if err := wc.Exec(ctx); err != nil {
|
||||
func (_c *WeaponCreate) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (wc *WeaponCreate) check() error {
|
||||
if _, ok := wc.mutation.Victim(); !ok {
|
||||
func (_c *WeaponCreate) check() error {
|
||||
if _, ok := _c.mutation.Victim(); !ok {
|
||||
return &ValidationError{Name: "victim", err: errors.New(`ent: missing required field "Weapon.victim"`)}
|
||||
}
|
||||
if _, ok := wc.mutation.Dmg(); !ok {
|
||||
if _, ok := _c.mutation.Dmg(); !ok {
|
||||
return &ValidationError{Name: "dmg", err: errors.New(`ent: missing required field "Weapon.dmg"`)}
|
||||
}
|
||||
if _, ok := wc.mutation.EqType(); !ok {
|
||||
if _, ok := _c.mutation.EqType(); !ok {
|
||||
return &ValidationError{Name: "eq_type", err: errors.New(`ent: missing required field "Weapon.eq_type"`)}
|
||||
}
|
||||
if _, ok := wc.mutation.HitGroup(); !ok {
|
||||
if _, ok := _c.mutation.HitGroup(); !ok {
|
||||
return &ValidationError{Name: "hit_group", err: errors.New(`ent: missing required field "Weapon.hit_group"`)}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (wc *WeaponCreate) sqlSave(ctx context.Context) (*Weapon, error) {
|
||||
if err := wc.check(); err != nil {
|
||||
func (_c *WeaponCreate) sqlSave(ctx context.Context) (*Weapon, error) {
|
||||
if err := _c.check(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_node, _spec := wc.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, wc.driver, _spec); err != nil {
|
||||
_node, _spec := _c.createSpec()
|
||||
if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -125,33 +125,33 @@ func (wc *WeaponCreate) sqlSave(ctx context.Context) (*Weapon, error) {
|
||||
}
|
||||
id := _spec.ID.Value.(int64)
|
||||
_node.ID = int(id)
|
||||
wc.mutation.id = &_node.ID
|
||||
wc.mutation.done = true
|
||||
_c.mutation.id = &_node.ID
|
||||
_c.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
func (wc *WeaponCreate) createSpec() (*Weapon, *sqlgraph.CreateSpec) {
|
||||
func (_c *WeaponCreate) createSpec() (*Weapon, *sqlgraph.CreateSpec) {
|
||||
var (
|
||||
_node = &Weapon{config: wc.config}
|
||||
_node = &Weapon{config: _c.config}
|
||||
_spec = sqlgraph.NewCreateSpec(weapon.Table, sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt))
|
||||
)
|
||||
if value, ok := wc.mutation.Victim(); ok {
|
||||
if value, ok := _c.mutation.Victim(); ok {
|
||||
_spec.SetField(weapon.FieldVictim, field.TypeUint64, value)
|
||||
_node.Victim = value
|
||||
}
|
||||
if value, ok := wc.mutation.Dmg(); ok {
|
||||
if value, ok := _c.mutation.Dmg(); ok {
|
||||
_spec.SetField(weapon.FieldDmg, field.TypeUint, value)
|
||||
_node.Dmg = value
|
||||
}
|
||||
if value, ok := wc.mutation.EqType(); ok {
|
||||
if value, ok := _c.mutation.EqType(); ok {
|
||||
_spec.SetField(weapon.FieldEqType, field.TypeInt, value)
|
||||
_node.EqType = value
|
||||
}
|
||||
if value, ok := wc.mutation.HitGroup(); ok {
|
||||
if value, ok := _c.mutation.HitGroup(); ok {
|
||||
_spec.SetField(weapon.FieldHitGroup, field.TypeInt, value)
|
||||
_node.HitGroup = value
|
||||
}
|
||||
if nodes := wc.mutation.StatIDs(); len(nodes) > 0 {
|
||||
if nodes := _c.mutation.StatIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -174,17 +174,21 @@ func (wc *WeaponCreate) createSpec() (*Weapon, *sqlgraph.CreateSpec) {
|
||||
// WeaponCreateBulk is the builder for creating many Weapon entities in bulk.
|
||||
type WeaponCreateBulk struct {
|
||||
config
|
||||
err error
|
||||
builders []*WeaponCreate
|
||||
}
|
||||
|
||||
// Save creates the Weapon entities in the database.
|
||||
func (wcb *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) {
|
||||
specs := make([]*sqlgraph.CreateSpec, len(wcb.builders))
|
||||
nodes := make([]*Weapon, len(wcb.builders))
|
||||
mutators := make([]Mutator, len(wcb.builders))
|
||||
for i := range wcb.builders {
|
||||
func (_c *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) {
|
||||
if _c.err != nil {
|
||||
return nil, _c.err
|
||||
}
|
||||
specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
|
||||
nodes := make([]*Weapon, len(_c.builders))
|
||||
mutators := make([]Mutator, len(_c.builders))
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := wcb.builders[i]
|
||||
builder := _c.builders[i]
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*WeaponMutation)
|
||||
if !ok {
|
||||
@@ -197,11 +201,11 @@ func (wcb *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) {
|
||||
var err error
|
||||
nodes[i], specs[i] = builder.createSpec()
|
||||
if i < len(mutators)-1 {
|
||||
_, err = mutators[i+1].Mutate(root, wcb.builders[i+1].mutation)
|
||||
_, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
|
||||
} else {
|
||||
spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
|
||||
// Invoke the actual operation on the latest mutation in the chain.
|
||||
if err = sqlgraph.BatchCreate(ctx, wcb.driver, spec); err != nil {
|
||||
if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
|
||||
if sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
@@ -225,7 +229,7 @@ func (wcb *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) {
|
||||
}(i, ctx)
|
||||
}
|
||||
if len(mutators) > 0 {
|
||||
if _, err := mutators[0].Mutate(ctx, wcb.builders[0].mutation); err != nil {
|
||||
if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -233,8 +237,8 @@ func (wcb *WeaponCreateBulk) Save(ctx context.Context) ([]*Weapon, error) {
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (wcb *WeaponCreateBulk) SaveX(ctx context.Context) []*Weapon {
|
||||
v, err := wcb.Save(ctx)
|
||||
func (_c *WeaponCreateBulk) SaveX(ctx context.Context) []*Weapon {
|
||||
v, err := _c.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -242,14 +246,14 @@ func (wcb *WeaponCreateBulk) SaveX(ctx context.Context) []*Weapon {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (wcb *WeaponCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := wcb.Save(ctx)
|
||||
func (_c *WeaponCreateBulk) Exec(ctx context.Context) error {
|
||||
_, err := _c.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (wcb *WeaponCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := wcb.Exec(ctx); err != nil {
|
||||
func (_c *WeaponCreateBulk) ExecX(ctx context.Context) {
|
||||
if err := _c.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,56 +20,56 @@ type WeaponDelete struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the WeaponDelete builder.
|
||||
func (wd *WeaponDelete) Where(ps ...predicate.Weapon) *WeaponDelete {
|
||||
wd.mutation.Where(ps...)
|
||||
return wd
|
||||
func (_d *WeaponDelete) Where(ps ...predicate.Weapon) *WeaponDelete {
|
||||
_d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query and returns how many vertices were deleted.
|
||||
func (wd *WeaponDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, wd.sqlExec, wd.mutation, wd.hooks)
|
||||
func (_d *WeaponDelete) Exec(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (wd *WeaponDelete) ExecX(ctx context.Context) int {
|
||||
n, err := wd.Exec(ctx)
|
||||
func (_d *WeaponDelete) ExecX(ctx context.Context) int {
|
||||
n, err := _d.Exec(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (wd *WeaponDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
func (_d *WeaponDelete) sqlExec(ctx context.Context) (int, error) {
|
||||
_spec := sqlgraph.NewDeleteSpec(weapon.Table, sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt))
|
||||
if ps := wd.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _d.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, wd.driver, _spec)
|
||||
affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
|
||||
if err != nil && sqlgraph.IsConstraintError(err) {
|
||||
err = &ConstraintError{msg: err.Error(), wrap: err}
|
||||
}
|
||||
wd.mutation.done = true
|
||||
_d.mutation.done = true
|
||||
return affected, err
|
||||
}
|
||||
|
||||
// WeaponDeleteOne is the builder for deleting a single Weapon entity.
|
||||
type WeaponDeleteOne struct {
|
||||
wd *WeaponDelete
|
||||
_d *WeaponDelete
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the WeaponDelete builder.
|
||||
func (wdo *WeaponDeleteOne) Where(ps ...predicate.Weapon) *WeaponDeleteOne {
|
||||
wdo.wd.mutation.Where(ps...)
|
||||
return wdo
|
||||
func (_d *WeaponDeleteOne) Where(ps ...predicate.Weapon) *WeaponDeleteOne {
|
||||
_d._d.mutation.Where(ps...)
|
||||
return _d
|
||||
}
|
||||
|
||||
// Exec executes the deletion query.
|
||||
func (wdo *WeaponDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := wdo.wd.Exec(ctx)
|
||||
func (_d *WeaponDeleteOne) Exec(ctx context.Context) error {
|
||||
n, err := _d._d.Exec(ctx)
|
||||
switch {
|
||||
case err != nil:
|
||||
return err
|
||||
@@ -81,8 +81,8 @@ func (wdo *WeaponDeleteOne) Exec(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (wdo *WeaponDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := wdo.Exec(ctx); err != nil {
|
||||
func (_d *WeaponDeleteOne) ExecX(ctx context.Context) {
|
||||
if err := _d.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"math"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"entgo.io/ent/schema/field"
|
||||
@@ -31,44 +32,44 @@ type WeaponQuery struct {
|
||||
}
|
||||
|
||||
// Where adds a new predicate for the WeaponQuery builder.
|
||||
func (wq *WeaponQuery) Where(ps ...predicate.Weapon) *WeaponQuery {
|
||||
wq.predicates = append(wq.predicates, ps...)
|
||||
return wq
|
||||
func (_q *WeaponQuery) Where(ps ...predicate.Weapon) *WeaponQuery {
|
||||
_q.predicates = append(_q.predicates, ps...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// Limit the number of records to be returned by this query.
|
||||
func (wq *WeaponQuery) Limit(limit int) *WeaponQuery {
|
||||
wq.ctx.Limit = &limit
|
||||
return wq
|
||||
func (_q *WeaponQuery) Limit(limit int) *WeaponQuery {
|
||||
_q.ctx.Limit = &limit
|
||||
return _q
|
||||
}
|
||||
|
||||
// Offset to start from.
|
||||
func (wq *WeaponQuery) Offset(offset int) *WeaponQuery {
|
||||
wq.ctx.Offset = &offset
|
||||
return wq
|
||||
func (_q *WeaponQuery) Offset(offset int) *WeaponQuery {
|
||||
_q.ctx.Offset = &offset
|
||||
return _q
|
||||
}
|
||||
|
||||
// Unique configures the query builder to filter duplicate records on query.
|
||||
// By default, unique is set to true, and can be disabled using this method.
|
||||
func (wq *WeaponQuery) Unique(unique bool) *WeaponQuery {
|
||||
wq.ctx.Unique = &unique
|
||||
return wq
|
||||
func (_q *WeaponQuery) Unique(unique bool) *WeaponQuery {
|
||||
_q.ctx.Unique = &unique
|
||||
return _q
|
||||
}
|
||||
|
||||
// Order specifies how the records should be ordered.
|
||||
func (wq *WeaponQuery) Order(o ...weapon.OrderOption) *WeaponQuery {
|
||||
wq.order = append(wq.order, o...)
|
||||
return wq
|
||||
func (_q *WeaponQuery) Order(o ...weapon.OrderOption) *WeaponQuery {
|
||||
_q.order = append(_q.order, o...)
|
||||
return _q
|
||||
}
|
||||
|
||||
// QueryStat chains the current query on the "stat" edge.
|
||||
func (wq *WeaponQuery) QueryStat() *MatchPlayerQuery {
|
||||
query := (&MatchPlayerClient{config: wq.config}).Query()
|
||||
func (_q *WeaponQuery) QueryStat() *MatchPlayerQuery {
|
||||
query := (&MatchPlayerClient{config: _q.config}).Query()
|
||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||
if err := wq.prepareQuery(ctx); err != nil {
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
selector := wq.sqlQuery(ctx)
|
||||
selector := _q.sqlQuery(ctx)
|
||||
if err := selector.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -77,7 +78,7 @@ func (wq *WeaponQuery) QueryStat() *MatchPlayerQuery {
|
||||
sqlgraph.To(matchplayer.Table, matchplayer.FieldID),
|
||||
sqlgraph.Edge(sqlgraph.M2O, true, weapon.StatTable, weapon.StatColumn),
|
||||
)
|
||||
fromU = sqlgraph.SetNeighbors(wq.driver.Dialect(), step)
|
||||
fromU = sqlgraph.SetNeighbors(_q.driver.Dialect(), step)
|
||||
return fromU, nil
|
||||
}
|
||||
return query
|
||||
@@ -85,8 +86,8 @@ func (wq *WeaponQuery) QueryStat() *MatchPlayerQuery {
|
||||
|
||||
// First returns the first Weapon entity from the query.
|
||||
// Returns a *NotFoundError when no Weapon was found.
|
||||
func (wq *WeaponQuery) First(ctx context.Context) (*Weapon, error) {
|
||||
nodes, err := wq.Limit(1).All(setContextOp(ctx, wq.ctx, "First"))
|
||||
func (_q *WeaponQuery) First(ctx context.Context) (*Weapon, error) {
|
||||
nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -97,8 +98,8 @@ func (wq *WeaponQuery) First(ctx context.Context) (*Weapon, error) {
|
||||
}
|
||||
|
||||
// FirstX is like First, but panics if an error occurs.
|
||||
func (wq *WeaponQuery) FirstX(ctx context.Context) *Weapon {
|
||||
node, err := wq.First(ctx)
|
||||
func (_q *WeaponQuery) FirstX(ctx context.Context) *Weapon {
|
||||
node, err := _q.First(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -107,9 +108,9 @@ func (wq *WeaponQuery) FirstX(ctx context.Context) *Weapon {
|
||||
|
||||
// FirstID returns the first Weapon ID from the query.
|
||||
// Returns a *NotFoundError when no Weapon ID was found.
|
||||
func (wq *WeaponQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
func (_q *WeaponQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = wq.Limit(1).IDs(setContextOp(ctx, wq.ctx, "FirstID")); err != nil {
|
||||
if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
|
||||
return
|
||||
}
|
||||
if len(ids) == 0 {
|
||||
@@ -120,8 +121,8 @@ func (wq *WeaponQuery) FirstID(ctx context.Context) (id int, err error) {
|
||||
}
|
||||
|
||||
// FirstIDX is like FirstID, but panics if an error occurs.
|
||||
func (wq *WeaponQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := wq.FirstID(ctx)
|
||||
func (_q *WeaponQuery) FirstIDX(ctx context.Context) int {
|
||||
id, err := _q.FirstID(ctx)
|
||||
if err != nil && !IsNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
@@ -131,8 +132,8 @@ func (wq *WeaponQuery) FirstIDX(ctx context.Context) int {
|
||||
// Only returns a single Weapon entity found by the query, ensuring it only returns one.
|
||||
// Returns a *NotSingularError when more than one Weapon entity is found.
|
||||
// Returns a *NotFoundError when no Weapon entities are found.
|
||||
func (wq *WeaponQuery) Only(ctx context.Context) (*Weapon, error) {
|
||||
nodes, err := wq.Limit(2).All(setContextOp(ctx, wq.ctx, "Only"))
|
||||
func (_q *WeaponQuery) Only(ctx context.Context) (*Weapon, error) {
|
||||
nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -147,8 +148,8 @@ func (wq *WeaponQuery) Only(ctx context.Context) (*Weapon, error) {
|
||||
}
|
||||
|
||||
// OnlyX is like Only, but panics if an error occurs.
|
||||
func (wq *WeaponQuery) OnlyX(ctx context.Context) *Weapon {
|
||||
node, err := wq.Only(ctx)
|
||||
func (_q *WeaponQuery) OnlyX(ctx context.Context) *Weapon {
|
||||
node, err := _q.Only(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -158,9 +159,9 @@ func (wq *WeaponQuery) OnlyX(ctx context.Context) *Weapon {
|
||||
// OnlyID is like Only, but returns the only Weapon ID in the query.
|
||||
// Returns a *NotSingularError when more than one Weapon ID is found.
|
||||
// Returns a *NotFoundError when no entities are found.
|
||||
func (wq *WeaponQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
func (_q *WeaponQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
var ids []int
|
||||
if ids, err = wq.Limit(2).IDs(setContextOp(ctx, wq.ctx, "OnlyID")); err != nil {
|
||||
if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
|
||||
return
|
||||
}
|
||||
switch len(ids) {
|
||||
@@ -175,8 +176,8 @@ func (wq *WeaponQuery) OnlyID(ctx context.Context) (id int, err error) {
|
||||
}
|
||||
|
||||
// OnlyIDX is like OnlyID, but panics if an error occurs.
|
||||
func (wq *WeaponQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := wq.OnlyID(ctx)
|
||||
func (_q *WeaponQuery) OnlyIDX(ctx context.Context) int {
|
||||
id, err := _q.OnlyID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -184,18 +185,18 @@ func (wq *WeaponQuery) OnlyIDX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// All executes the query and returns a list of Weapons.
|
||||
func (wq *WeaponQuery) All(ctx context.Context) ([]*Weapon, error) {
|
||||
ctx = setContextOp(ctx, wq.ctx, "All")
|
||||
if err := wq.prepareQuery(ctx); err != nil {
|
||||
func (_q *WeaponQuery) All(ctx context.Context) ([]*Weapon, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qr := querierAll[[]*Weapon, *WeaponQuery]()
|
||||
return withInterceptors[[]*Weapon](ctx, wq, qr, wq.inters)
|
||||
return withInterceptors[[]*Weapon](ctx, _q, qr, _q.inters)
|
||||
}
|
||||
|
||||
// AllX is like All, but panics if an error occurs.
|
||||
func (wq *WeaponQuery) AllX(ctx context.Context) []*Weapon {
|
||||
nodes, err := wq.All(ctx)
|
||||
func (_q *WeaponQuery) AllX(ctx context.Context) []*Weapon {
|
||||
nodes, err := _q.All(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -203,20 +204,20 @@ func (wq *WeaponQuery) AllX(ctx context.Context) []*Weapon {
|
||||
}
|
||||
|
||||
// IDs executes the query and returns a list of Weapon IDs.
|
||||
func (wq *WeaponQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if wq.ctx.Unique == nil && wq.path != nil {
|
||||
wq.Unique(true)
|
||||
func (_q *WeaponQuery) IDs(ctx context.Context) (ids []int, err error) {
|
||||
if _q.ctx.Unique == nil && _q.path != nil {
|
||||
_q.Unique(true)
|
||||
}
|
||||
ctx = setContextOp(ctx, wq.ctx, "IDs")
|
||||
if err = wq.Select(weapon.FieldID).Scan(ctx, &ids); err != nil {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
|
||||
if err = _q.Select(weapon.FieldID).Scan(ctx, &ids); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// IDsX is like IDs, but panics if an error occurs.
|
||||
func (wq *WeaponQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := wq.IDs(ctx)
|
||||
func (_q *WeaponQuery) IDsX(ctx context.Context) []int {
|
||||
ids, err := _q.IDs(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -224,17 +225,17 @@ func (wq *WeaponQuery) IDsX(ctx context.Context) []int {
|
||||
}
|
||||
|
||||
// Count returns the count of the given query.
|
||||
func (wq *WeaponQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, wq.ctx, "Count")
|
||||
if err := wq.prepareQuery(ctx); err != nil {
|
||||
func (_q *WeaponQuery) Count(ctx context.Context) (int, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
|
||||
if err := _q.prepareQuery(ctx); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return withInterceptors[int](ctx, wq, querierCount[*WeaponQuery](), wq.inters)
|
||||
return withInterceptors[int](ctx, _q, querierCount[*WeaponQuery](), _q.inters)
|
||||
}
|
||||
|
||||
// CountX is like Count, but panics if an error occurs.
|
||||
func (wq *WeaponQuery) CountX(ctx context.Context) int {
|
||||
count, err := wq.Count(ctx)
|
||||
func (_q *WeaponQuery) CountX(ctx context.Context) int {
|
||||
count, err := _q.Count(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -242,9 +243,9 @@ func (wq *WeaponQuery) CountX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exist returns true if the query has elements in the graph.
|
||||
func (wq *WeaponQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, wq.ctx, "Exist")
|
||||
switch _, err := wq.FirstID(ctx); {
|
||||
func (_q *WeaponQuery) Exist(ctx context.Context) (bool, error) {
|
||||
ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
|
||||
switch _, err := _q.FirstID(ctx); {
|
||||
case IsNotFound(err):
|
||||
return false, nil
|
||||
case err != nil:
|
||||
@@ -255,8 +256,8 @@ func (wq *WeaponQuery) Exist(ctx context.Context) (bool, error) {
|
||||
}
|
||||
|
||||
// ExistX is like Exist, but panics if an error occurs.
|
||||
func (wq *WeaponQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := wq.Exist(ctx)
|
||||
func (_q *WeaponQuery) ExistX(ctx context.Context) bool {
|
||||
exist, err := _q.Exist(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -265,32 +266,33 @@ func (wq *WeaponQuery) ExistX(ctx context.Context) bool {
|
||||
|
||||
// Clone returns a duplicate of the WeaponQuery builder, including all associated steps. It can be
|
||||
// used to prepare common query builders and use them differently after the clone is made.
|
||||
func (wq *WeaponQuery) Clone() *WeaponQuery {
|
||||
if wq == nil {
|
||||
func (_q *WeaponQuery) Clone() *WeaponQuery {
|
||||
if _q == nil {
|
||||
return nil
|
||||
}
|
||||
return &WeaponQuery{
|
||||
config: wq.config,
|
||||
ctx: wq.ctx.Clone(),
|
||||
order: append([]weapon.OrderOption{}, wq.order...),
|
||||
inters: append([]Interceptor{}, wq.inters...),
|
||||
predicates: append([]predicate.Weapon{}, wq.predicates...),
|
||||
withStat: wq.withStat.Clone(),
|
||||
config: _q.config,
|
||||
ctx: _q.ctx.Clone(),
|
||||
order: append([]weapon.OrderOption{}, _q.order...),
|
||||
inters: append([]Interceptor{}, _q.inters...),
|
||||
predicates: append([]predicate.Weapon{}, _q.predicates...),
|
||||
withStat: _q.withStat.Clone(),
|
||||
// clone intermediate query.
|
||||
sql: wq.sql.Clone(),
|
||||
path: wq.path,
|
||||
sql: _q.sql.Clone(),
|
||||
path: _q.path,
|
||||
modifiers: append([]func(*sql.Selector){}, _q.modifiers...),
|
||||
}
|
||||
}
|
||||
|
||||
// WithStat tells the query-builder to eager-load the nodes that are connected to
|
||||
// the "stat" edge. The optional arguments are used to configure the query builder of the edge.
|
||||
func (wq *WeaponQuery) WithStat(opts ...func(*MatchPlayerQuery)) *WeaponQuery {
|
||||
query := (&MatchPlayerClient{config: wq.config}).Query()
|
||||
func (_q *WeaponQuery) WithStat(opts ...func(*MatchPlayerQuery)) *WeaponQuery {
|
||||
query := (&MatchPlayerClient{config: _q.config}).Query()
|
||||
for _, opt := range opts {
|
||||
opt(query)
|
||||
}
|
||||
wq.withStat = query
|
||||
return wq
|
||||
_q.withStat = query
|
||||
return _q
|
||||
}
|
||||
|
||||
// GroupBy is used to group vertices by one or more fields/columns.
|
||||
@@ -307,10 +309,10 @@ func (wq *WeaponQuery) WithStat(opts ...func(*MatchPlayerQuery)) *WeaponQuery {
|
||||
// GroupBy(weapon.FieldVictim).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (wq *WeaponQuery) GroupBy(field string, fields ...string) *WeaponGroupBy {
|
||||
wq.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &WeaponGroupBy{build: wq}
|
||||
grbuild.flds = &wq.ctx.Fields
|
||||
func (_q *WeaponQuery) GroupBy(field string, fields ...string) *WeaponGroupBy {
|
||||
_q.ctx.Fields = append([]string{field}, fields...)
|
||||
grbuild := &WeaponGroupBy{build: _q}
|
||||
grbuild.flds = &_q.ctx.Fields
|
||||
grbuild.label = weapon.Label
|
||||
grbuild.scan = grbuild.Scan
|
||||
return grbuild
|
||||
@@ -328,55 +330,55 @@ func (wq *WeaponQuery) GroupBy(field string, fields ...string) *WeaponGroupBy {
|
||||
// client.Weapon.Query().
|
||||
// Select(weapon.FieldVictim).
|
||||
// Scan(ctx, &v)
|
||||
func (wq *WeaponQuery) Select(fields ...string) *WeaponSelect {
|
||||
wq.ctx.Fields = append(wq.ctx.Fields, fields...)
|
||||
sbuild := &WeaponSelect{WeaponQuery: wq}
|
||||
func (_q *WeaponQuery) Select(fields ...string) *WeaponSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
sbuild := &WeaponSelect{WeaponQuery: _q}
|
||||
sbuild.label = weapon.Label
|
||||
sbuild.flds, sbuild.scan = &wq.ctx.Fields, sbuild.Scan
|
||||
sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
|
||||
return sbuild
|
||||
}
|
||||
|
||||
// Aggregate returns a WeaponSelect configured with the given aggregations.
|
||||
func (wq *WeaponQuery) Aggregate(fns ...AggregateFunc) *WeaponSelect {
|
||||
return wq.Select().Aggregate(fns...)
|
||||
func (_q *WeaponQuery) Aggregate(fns ...AggregateFunc) *WeaponSelect {
|
||||
return _q.Select().Aggregate(fns...)
|
||||
}
|
||||
|
||||
func (wq *WeaponQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range wq.inters {
|
||||
func (_q *WeaponQuery) prepareQuery(ctx context.Context) error {
|
||||
for _, inter := range _q.inters {
|
||||
if inter == nil {
|
||||
return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
|
||||
}
|
||||
if trv, ok := inter.(Traverser); ok {
|
||||
if err := trv.Traverse(ctx, wq); err != nil {
|
||||
if err := trv.Traverse(ctx, _q); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, f := range wq.ctx.Fields {
|
||||
for _, f := range _q.ctx.Fields {
|
||||
if !weapon.ValidColumn(f) {
|
||||
return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
||||
}
|
||||
}
|
||||
if wq.path != nil {
|
||||
prev, err := wq.path(ctx)
|
||||
if _q.path != nil {
|
||||
prev, err := _q.path(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
wq.sql = prev
|
||||
_q.sql = prev
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (wq *WeaponQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Weapon, error) {
|
||||
func (_q *WeaponQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Weapon, error) {
|
||||
var (
|
||||
nodes = []*Weapon{}
|
||||
withFKs = wq.withFKs
|
||||
_spec = wq.querySpec()
|
||||
withFKs = _q.withFKs
|
||||
_spec = _q.querySpec()
|
||||
loadedTypes = [1]bool{
|
||||
wq.withStat != nil,
|
||||
_q.withStat != nil,
|
||||
}
|
||||
)
|
||||
if wq.withStat != nil {
|
||||
if _q.withStat != nil {
|
||||
withFKs = true
|
||||
}
|
||||
if withFKs {
|
||||
@@ -386,25 +388,25 @@ func (wq *WeaponQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Weapo
|
||||
return (*Weapon).scanValues(nil, columns)
|
||||
}
|
||||
_spec.Assign = func(columns []string, values []any) error {
|
||||
node := &Weapon{config: wq.config}
|
||||
node := &Weapon{config: _q.config}
|
||||
nodes = append(nodes, node)
|
||||
node.Edges.loadedTypes = loadedTypes
|
||||
return node.assignValues(columns, values)
|
||||
}
|
||||
if len(wq.modifiers) > 0 {
|
||||
_spec.Modifiers = wq.modifiers
|
||||
if len(_q.modifiers) > 0 {
|
||||
_spec.Modifiers = _q.modifiers
|
||||
}
|
||||
for i := range hooks {
|
||||
hooks[i](ctx, _spec)
|
||||
}
|
||||
if err := sqlgraph.QueryNodes(ctx, wq.driver, _spec); err != nil {
|
||||
if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes) == 0 {
|
||||
return nodes, nil
|
||||
}
|
||||
if query := wq.withStat; query != nil {
|
||||
if err := wq.loadStat(ctx, query, nodes, nil,
|
||||
if query := _q.withStat; query != nil {
|
||||
if err := _q.loadStat(ctx, query, nodes, nil,
|
||||
func(n *Weapon, e *MatchPlayer) { n.Edges.Stat = e }); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -412,7 +414,7 @@ func (wq *WeaponQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Weapo
|
||||
return nodes, nil
|
||||
}
|
||||
|
||||
func (wq *WeaponQuery) loadStat(ctx context.Context, query *MatchPlayerQuery, nodes []*Weapon, init func(*Weapon), assign func(*Weapon, *MatchPlayer)) error {
|
||||
func (_q *WeaponQuery) loadStat(ctx context.Context, query *MatchPlayerQuery, nodes []*Weapon, init func(*Weapon), assign func(*Weapon, *MatchPlayer)) error {
|
||||
ids := make([]int, 0, len(nodes))
|
||||
nodeids := make(map[int][]*Weapon)
|
||||
for i := range nodes {
|
||||
@@ -445,27 +447,27 @@ func (wq *WeaponQuery) loadStat(ctx context.Context, query *MatchPlayerQuery, no
|
||||
return nil
|
||||
}
|
||||
|
||||
func (wq *WeaponQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := wq.querySpec()
|
||||
if len(wq.modifiers) > 0 {
|
||||
_spec.Modifiers = wq.modifiers
|
||||
func (_q *WeaponQuery) sqlCount(ctx context.Context) (int, error) {
|
||||
_spec := _q.querySpec()
|
||||
if len(_q.modifiers) > 0 {
|
||||
_spec.Modifiers = _q.modifiers
|
||||
}
|
||||
_spec.Node.Columns = wq.ctx.Fields
|
||||
if len(wq.ctx.Fields) > 0 {
|
||||
_spec.Unique = wq.ctx.Unique != nil && *wq.ctx.Unique
|
||||
_spec.Node.Columns = _q.ctx.Fields
|
||||
if len(_q.ctx.Fields) > 0 {
|
||||
_spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
|
||||
}
|
||||
return sqlgraph.CountNodes(ctx, wq.driver, _spec)
|
||||
return sqlgraph.CountNodes(ctx, _q.driver, _spec)
|
||||
}
|
||||
|
||||
func (wq *WeaponQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
func (_q *WeaponQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
_spec := sqlgraph.NewQuerySpec(weapon.Table, weapon.Columns, sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt))
|
||||
_spec.From = wq.sql
|
||||
if unique := wq.ctx.Unique; unique != nil {
|
||||
_spec.From = _q.sql
|
||||
if unique := _q.ctx.Unique; unique != nil {
|
||||
_spec.Unique = *unique
|
||||
} else if wq.path != nil {
|
||||
} else if _q.path != nil {
|
||||
_spec.Unique = true
|
||||
}
|
||||
if fields := wq.ctx.Fields; len(fields) > 0 {
|
||||
if fields := _q.ctx.Fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, weapon.FieldID)
|
||||
for i := range fields {
|
||||
@@ -474,20 +476,20 @@ func (wq *WeaponQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := wq.predicates; len(ps) > 0 {
|
||||
if ps := _q.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if limit := wq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
_spec.Limit = *limit
|
||||
}
|
||||
if offset := wq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
_spec.Offset = *offset
|
||||
}
|
||||
if ps := wq.order; len(ps) > 0 {
|
||||
if ps := _q.order; len(ps) > 0 {
|
||||
_spec.Order = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
@@ -497,45 +499,45 @@ func (wq *WeaponQuery) querySpec() *sqlgraph.QuerySpec {
|
||||
return _spec
|
||||
}
|
||||
|
||||
func (wq *WeaponQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(wq.driver.Dialect())
|
||||
func (_q *WeaponQuery) sqlQuery(ctx context.Context) *sql.Selector {
|
||||
builder := sql.Dialect(_q.driver.Dialect())
|
||||
t1 := builder.Table(weapon.Table)
|
||||
columns := wq.ctx.Fields
|
||||
columns := _q.ctx.Fields
|
||||
if len(columns) == 0 {
|
||||
columns = weapon.Columns
|
||||
}
|
||||
selector := builder.Select(t1.Columns(columns...)...).From(t1)
|
||||
if wq.sql != nil {
|
||||
selector = wq.sql
|
||||
if _q.sql != nil {
|
||||
selector = _q.sql
|
||||
selector.Select(selector.Columns(columns...)...)
|
||||
}
|
||||
if wq.ctx.Unique != nil && *wq.ctx.Unique {
|
||||
if _q.ctx.Unique != nil && *_q.ctx.Unique {
|
||||
selector.Distinct()
|
||||
}
|
||||
for _, m := range wq.modifiers {
|
||||
for _, m := range _q.modifiers {
|
||||
m(selector)
|
||||
}
|
||||
for _, p := range wq.predicates {
|
||||
for _, p := range _q.predicates {
|
||||
p(selector)
|
||||
}
|
||||
for _, p := range wq.order {
|
||||
for _, p := range _q.order {
|
||||
p(selector)
|
||||
}
|
||||
if offset := wq.ctx.Offset; offset != nil {
|
||||
if offset := _q.ctx.Offset; offset != nil {
|
||||
// limit is mandatory for offset clause. We start
|
||||
// with default value, and override it below if needed.
|
||||
selector.Offset(*offset).Limit(math.MaxInt32)
|
||||
}
|
||||
if limit := wq.ctx.Limit; limit != nil {
|
||||
if limit := _q.ctx.Limit; limit != nil {
|
||||
selector.Limit(*limit)
|
||||
}
|
||||
return selector
|
||||
}
|
||||
|
||||
// Modify adds a query modifier for attaching custom logic to queries.
|
||||
func (wq *WeaponQuery) Modify(modifiers ...func(s *sql.Selector)) *WeaponSelect {
|
||||
wq.modifiers = append(wq.modifiers, modifiers...)
|
||||
return wq.Select()
|
||||
func (_q *WeaponQuery) Modify(modifiers ...func(s *sql.Selector)) *WeaponSelect {
|
||||
_q.modifiers = append(_q.modifiers, modifiers...)
|
||||
return _q.Select()
|
||||
}
|
||||
|
||||
// WeaponGroupBy is the group-by builder for Weapon entities.
|
||||
@@ -545,41 +547,41 @@ type WeaponGroupBy struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the group-by query.
|
||||
func (wgb *WeaponGroupBy) Aggregate(fns ...AggregateFunc) *WeaponGroupBy {
|
||||
wgb.fns = append(wgb.fns, fns...)
|
||||
return wgb
|
||||
func (_g *WeaponGroupBy) Aggregate(fns ...AggregateFunc) *WeaponGroupBy {
|
||||
_g.fns = append(_g.fns, fns...)
|
||||
return _g
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (wgb *WeaponGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, wgb.build.ctx, "GroupBy")
|
||||
if err := wgb.build.prepareQuery(ctx); err != nil {
|
||||
func (_g *WeaponGroupBy) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
|
||||
if err := _g.build.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*WeaponQuery, *WeaponGroupBy](ctx, wgb.build, wgb, wgb.build.inters, v)
|
||||
return scanWithInterceptors[*WeaponQuery, *WeaponGroupBy](ctx, _g.build, _g, _g.build.inters, v)
|
||||
}
|
||||
|
||||
func (wgb *WeaponGroupBy) sqlScan(ctx context.Context, root *WeaponQuery, v any) error {
|
||||
func (_g *WeaponGroupBy) sqlScan(ctx context.Context, root *WeaponQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx).Select()
|
||||
aggregation := make([]string, 0, len(wgb.fns))
|
||||
for _, fn := range wgb.fns {
|
||||
aggregation := make([]string, 0, len(_g.fns))
|
||||
for _, fn := range _g.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
if len(selector.SelectedColumns()) == 0 {
|
||||
columns := make([]string, 0, len(*wgb.flds)+len(wgb.fns))
|
||||
for _, f := range *wgb.flds {
|
||||
columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
|
||||
for _, f := range *_g.flds {
|
||||
columns = append(columns, selector.C(f))
|
||||
}
|
||||
columns = append(columns, aggregation...)
|
||||
selector.Select(columns...)
|
||||
}
|
||||
selector.GroupBy(selector.Columns(*wgb.flds...)...)
|
||||
selector.GroupBy(selector.Columns(*_g.flds...)...)
|
||||
if err := selector.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := wgb.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -593,27 +595,27 @@ type WeaponSelect struct {
|
||||
}
|
||||
|
||||
// Aggregate adds the given aggregation functions to the selector query.
|
||||
func (ws *WeaponSelect) Aggregate(fns ...AggregateFunc) *WeaponSelect {
|
||||
ws.fns = append(ws.fns, fns...)
|
||||
return ws
|
||||
func (_s *WeaponSelect) Aggregate(fns ...AggregateFunc) *WeaponSelect {
|
||||
_s.fns = append(_s.fns, fns...)
|
||||
return _s
|
||||
}
|
||||
|
||||
// Scan applies the selector query and scans the result into the given value.
|
||||
func (ws *WeaponSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, ws.ctx, "Select")
|
||||
if err := ws.prepareQuery(ctx); err != nil {
|
||||
func (_s *WeaponSelect) Scan(ctx context.Context, v any) error {
|
||||
ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
|
||||
if err := _s.prepareQuery(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return scanWithInterceptors[*WeaponQuery, *WeaponSelect](ctx, ws.WeaponQuery, ws, ws.inters, v)
|
||||
return scanWithInterceptors[*WeaponQuery, *WeaponSelect](ctx, _s.WeaponQuery, _s, _s.inters, v)
|
||||
}
|
||||
|
||||
func (ws *WeaponSelect) sqlScan(ctx context.Context, root *WeaponQuery, v any) error {
|
||||
func (_s *WeaponSelect) sqlScan(ctx context.Context, root *WeaponQuery, v any) error {
|
||||
selector := root.sqlQuery(ctx)
|
||||
aggregation := make([]string, 0, len(ws.fns))
|
||||
for _, fn := range ws.fns {
|
||||
aggregation := make([]string, 0, len(_s.fns))
|
||||
for _, fn := range _s.fns {
|
||||
aggregation = append(aggregation, fn(selector))
|
||||
}
|
||||
switch n := len(*ws.selector.flds); {
|
||||
switch n := len(*_s.selector.flds); {
|
||||
case n == 0 && len(aggregation) > 0:
|
||||
selector.Select(aggregation...)
|
||||
case n != 0 && len(aggregation) > 0:
|
||||
@@ -621,7 +623,7 @@ func (ws *WeaponSelect) sqlScan(ctx context.Context, root *WeaponQuery, v any) e
|
||||
}
|
||||
rows := &sql.Rows{}
|
||||
query, args := selector.Query()
|
||||
if err := ws.driver.Query(ctx, query, args, rows); err != nil {
|
||||
if err := _s.driver.Query(ctx, query, args, rows); err != nil {
|
||||
return err
|
||||
}
|
||||
defer rows.Close()
|
||||
@@ -629,7 +631,7 @@ func (ws *WeaponSelect) sqlScan(ctx context.Context, root *WeaponQuery, v any) e
|
||||
}
|
||||
|
||||
// Modify adds a query modifier for attaching custom logic to queries.
|
||||
func (ws *WeaponSelect) Modify(modifiers ...func(s *sql.Selector)) *WeaponSelect {
|
||||
ws.modifiers = append(ws.modifiers, modifiers...)
|
||||
return ws
|
||||
func (_s *WeaponSelect) Modify(modifiers ...func(s *sql.Selector)) *WeaponSelect {
|
||||
_s.modifiers = append(_s.modifiers, modifiers...)
|
||||
return _s
|
||||
}
|
||||
|
||||
@@ -24,101 +24,133 @@ type WeaponUpdate struct {
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the WeaponUpdate builder.
|
||||
func (wu *WeaponUpdate) Where(ps ...predicate.Weapon) *WeaponUpdate {
|
||||
wu.mutation.Where(ps...)
|
||||
return wu
|
||||
func (_u *WeaponUpdate) Where(ps ...predicate.Weapon) *WeaponUpdate {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetVictim sets the "victim" field.
|
||||
func (wu *WeaponUpdate) SetVictim(u uint64) *WeaponUpdate {
|
||||
wu.mutation.ResetVictim()
|
||||
wu.mutation.SetVictim(u)
|
||||
return wu
|
||||
func (_u *WeaponUpdate) SetVictim(v uint64) *WeaponUpdate {
|
||||
_u.mutation.ResetVictim()
|
||||
_u.mutation.SetVictim(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddVictim adds u to the "victim" field.
|
||||
func (wu *WeaponUpdate) AddVictim(u int64) *WeaponUpdate {
|
||||
wu.mutation.AddVictim(u)
|
||||
return wu
|
||||
// SetNillableVictim sets the "victim" field if the given value is not nil.
|
||||
func (_u *WeaponUpdate) SetNillableVictim(v *uint64) *WeaponUpdate {
|
||||
if v != nil {
|
||||
_u.SetVictim(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddVictim adds value to the "victim" field.
|
||||
func (_u *WeaponUpdate) AddVictim(v int64) *WeaponUpdate {
|
||||
_u.mutation.AddVictim(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetDmg sets the "dmg" field.
|
||||
func (wu *WeaponUpdate) SetDmg(u uint) *WeaponUpdate {
|
||||
wu.mutation.ResetDmg()
|
||||
wu.mutation.SetDmg(u)
|
||||
return wu
|
||||
func (_u *WeaponUpdate) SetDmg(v uint) *WeaponUpdate {
|
||||
_u.mutation.ResetDmg()
|
||||
_u.mutation.SetDmg(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddDmg adds u to the "dmg" field.
|
||||
func (wu *WeaponUpdate) AddDmg(u int) *WeaponUpdate {
|
||||
wu.mutation.AddDmg(u)
|
||||
return wu
|
||||
// SetNillableDmg sets the "dmg" field if the given value is not nil.
|
||||
func (_u *WeaponUpdate) SetNillableDmg(v *uint) *WeaponUpdate {
|
||||
if v != nil {
|
||||
_u.SetDmg(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddDmg adds value to the "dmg" field.
|
||||
func (_u *WeaponUpdate) AddDmg(v int) *WeaponUpdate {
|
||||
_u.mutation.AddDmg(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEqType sets the "eq_type" field.
|
||||
func (wu *WeaponUpdate) SetEqType(i int) *WeaponUpdate {
|
||||
wu.mutation.ResetEqType()
|
||||
wu.mutation.SetEqType(i)
|
||||
return wu
|
||||
func (_u *WeaponUpdate) SetEqType(v int) *WeaponUpdate {
|
||||
_u.mutation.ResetEqType()
|
||||
_u.mutation.SetEqType(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddEqType adds i to the "eq_type" field.
|
||||
func (wu *WeaponUpdate) AddEqType(i int) *WeaponUpdate {
|
||||
wu.mutation.AddEqType(i)
|
||||
return wu
|
||||
// SetNillableEqType sets the "eq_type" field if the given value is not nil.
|
||||
func (_u *WeaponUpdate) SetNillableEqType(v *int) *WeaponUpdate {
|
||||
if v != nil {
|
||||
_u.SetEqType(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddEqType adds value to the "eq_type" field.
|
||||
func (_u *WeaponUpdate) AddEqType(v int) *WeaponUpdate {
|
||||
_u.mutation.AddEqType(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetHitGroup sets the "hit_group" field.
|
||||
func (wu *WeaponUpdate) SetHitGroup(i int) *WeaponUpdate {
|
||||
wu.mutation.ResetHitGroup()
|
||||
wu.mutation.SetHitGroup(i)
|
||||
return wu
|
||||
func (_u *WeaponUpdate) SetHitGroup(v int) *WeaponUpdate {
|
||||
_u.mutation.ResetHitGroup()
|
||||
_u.mutation.SetHitGroup(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddHitGroup adds i to the "hit_group" field.
|
||||
func (wu *WeaponUpdate) AddHitGroup(i int) *WeaponUpdate {
|
||||
wu.mutation.AddHitGroup(i)
|
||||
return wu
|
||||
// SetNillableHitGroup sets the "hit_group" field if the given value is not nil.
|
||||
func (_u *WeaponUpdate) SetNillableHitGroup(v *int) *WeaponUpdate {
|
||||
if v != nil {
|
||||
_u.SetHitGroup(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddHitGroup adds value to the "hit_group" field.
|
||||
func (_u *WeaponUpdate) AddHitGroup(v int) *WeaponUpdate {
|
||||
_u.mutation.AddHitGroup(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetStatID sets the "stat" edge to the MatchPlayer entity by ID.
|
||||
func (wu *WeaponUpdate) SetStatID(id int) *WeaponUpdate {
|
||||
wu.mutation.SetStatID(id)
|
||||
return wu
|
||||
func (_u *WeaponUpdate) SetStatID(id int) *WeaponUpdate {
|
||||
_u.mutation.SetStatID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableStatID sets the "stat" edge to the MatchPlayer entity by ID if the given value is not nil.
|
||||
func (wu *WeaponUpdate) SetNillableStatID(id *int) *WeaponUpdate {
|
||||
func (_u *WeaponUpdate) SetNillableStatID(id *int) *WeaponUpdate {
|
||||
if id != nil {
|
||||
wu = wu.SetStatID(*id)
|
||||
_u = _u.SetStatID(*id)
|
||||
}
|
||||
return wu
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetStat sets the "stat" edge to the MatchPlayer entity.
|
||||
func (wu *WeaponUpdate) SetStat(m *MatchPlayer) *WeaponUpdate {
|
||||
return wu.SetStatID(m.ID)
|
||||
func (_u *WeaponUpdate) SetStat(v *MatchPlayer) *WeaponUpdate {
|
||||
return _u.SetStatID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the WeaponMutation object of the builder.
|
||||
func (wu *WeaponUpdate) Mutation() *WeaponMutation {
|
||||
return wu.mutation
|
||||
func (_u *WeaponUpdate) Mutation() *WeaponMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearStat clears the "stat" edge to the MatchPlayer entity.
|
||||
func (wu *WeaponUpdate) ClearStat() *WeaponUpdate {
|
||||
wu.mutation.ClearStat()
|
||||
return wu
|
||||
func (_u *WeaponUpdate) ClearStat() *WeaponUpdate {
|
||||
_u.mutation.ClearStat()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (wu *WeaponUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, wu.sqlSave, wu.mutation, wu.hooks)
|
||||
func (_u *WeaponUpdate) Save(ctx context.Context) (int, error) {
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (wu *WeaponUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := wu.Save(ctx)
|
||||
func (_u *WeaponUpdate) SaveX(ctx context.Context) int {
|
||||
affected, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -126,58 +158,58 @@ func (wu *WeaponUpdate) SaveX(ctx context.Context) int {
|
||||
}
|
||||
|
||||
// Exec executes the query.
|
||||
func (wu *WeaponUpdate) Exec(ctx context.Context) error {
|
||||
_, err := wu.Save(ctx)
|
||||
func (_u *WeaponUpdate) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (wu *WeaponUpdate) ExecX(ctx context.Context) {
|
||||
if err := wu.Exec(ctx); err != nil {
|
||||
func (_u *WeaponUpdate) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
||||
func (wu *WeaponUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WeaponUpdate {
|
||||
wu.modifiers = append(wu.modifiers, modifiers...)
|
||||
return wu
|
||||
func (_u *WeaponUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WeaponUpdate {
|
||||
_u.modifiers = append(_u.modifiers, modifiers...)
|
||||
return _u
|
||||
}
|
||||
|
||||
func (wu *WeaponUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
func (_u *WeaponUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(weapon.Table, weapon.Columns, sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt))
|
||||
if ps := wu.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := wu.mutation.Victim(); ok {
|
||||
if value, ok := _u.mutation.Victim(); ok {
|
||||
_spec.SetField(weapon.FieldVictim, field.TypeUint64, value)
|
||||
}
|
||||
if value, ok := wu.mutation.AddedVictim(); ok {
|
||||
if value, ok := _u.mutation.AddedVictim(); ok {
|
||||
_spec.AddField(weapon.FieldVictim, field.TypeUint64, value)
|
||||
}
|
||||
if value, ok := wu.mutation.Dmg(); ok {
|
||||
if value, ok := _u.mutation.Dmg(); ok {
|
||||
_spec.SetField(weapon.FieldDmg, field.TypeUint, value)
|
||||
}
|
||||
if value, ok := wu.mutation.AddedDmg(); ok {
|
||||
if value, ok := _u.mutation.AddedDmg(); ok {
|
||||
_spec.AddField(weapon.FieldDmg, field.TypeUint, value)
|
||||
}
|
||||
if value, ok := wu.mutation.EqType(); ok {
|
||||
if value, ok := _u.mutation.EqType(); ok {
|
||||
_spec.SetField(weapon.FieldEqType, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := wu.mutation.AddedEqType(); ok {
|
||||
if value, ok := _u.mutation.AddedEqType(); ok {
|
||||
_spec.AddField(weapon.FieldEqType, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := wu.mutation.HitGroup(); ok {
|
||||
if value, ok := _u.mutation.HitGroup(); ok {
|
||||
_spec.SetField(weapon.FieldHitGroup, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := wu.mutation.AddedHitGroup(); ok {
|
||||
if value, ok := _u.mutation.AddedHitGroup(); ok {
|
||||
_spec.AddField(weapon.FieldHitGroup, field.TypeInt, value)
|
||||
}
|
||||
if wu.mutation.StatCleared() {
|
||||
if _u.mutation.StatCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -190,7 +222,7 @@ func (wu *WeaponUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := wu.mutation.StatIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.StatIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -206,8 +238,8 @@ func (wu *WeaponUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_spec.AddModifiers(wu.modifiers...)
|
||||
if n, err = sqlgraph.UpdateNodes(ctx, wu.driver, _spec); err != nil {
|
||||
_spec.AddModifiers(_u.modifiers...)
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{weapon.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -215,8 +247,8 @@ func (wu *WeaponUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
||||
}
|
||||
return 0, err
|
||||
}
|
||||
wu.mutation.done = true
|
||||
return n, nil
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
// WeaponUpdateOne is the builder for updating a single Weapon entity.
|
||||
@@ -229,108 +261,140 @@ type WeaponUpdateOne struct {
|
||||
}
|
||||
|
||||
// SetVictim sets the "victim" field.
|
||||
func (wuo *WeaponUpdateOne) SetVictim(u uint64) *WeaponUpdateOne {
|
||||
wuo.mutation.ResetVictim()
|
||||
wuo.mutation.SetVictim(u)
|
||||
return wuo
|
||||
func (_u *WeaponUpdateOne) SetVictim(v uint64) *WeaponUpdateOne {
|
||||
_u.mutation.ResetVictim()
|
||||
_u.mutation.SetVictim(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddVictim adds u to the "victim" field.
|
||||
func (wuo *WeaponUpdateOne) AddVictim(u int64) *WeaponUpdateOne {
|
||||
wuo.mutation.AddVictim(u)
|
||||
return wuo
|
||||
// SetNillableVictim sets the "victim" field if the given value is not nil.
|
||||
func (_u *WeaponUpdateOne) SetNillableVictim(v *uint64) *WeaponUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetVictim(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddVictim adds value to the "victim" field.
|
||||
func (_u *WeaponUpdateOne) AddVictim(v int64) *WeaponUpdateOne {
|
||||
_u.mutation.AddVictim(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetDmg sets the "dmg" field.
|
||||
func (wuo *WeaponUpdateOne) SetDmg(u uint) *WeaponUpdateOne {
|
||||
wuo.mutation.ResetDmg()
|
||||
wuo.mutation.SetDmg(u)
|
||||
return wuo
|
||||
func (_u *WeaponUpdateOne) SetDmg(v uint) *WeaponUpdateOne {
|
||||
_u.mutation.ResetDmg()
|
||||
_u.mutation.SetDmg(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddDmg adds u to the "dmg" field.
|
||||
func (wuo *WeaponUpdateOne) AddDmg(u int) *WeaponUpdateOne {
|
||||
wuo.mutation.AddDmg(u)
|
||||
return wuo
|
||||
// SetNillableDmg sets the "dmg" field if the given value is not nil.
|
||||
func (_u *WeaponUpdateOne) SetNillableDmg(v *uint) *WeaponUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetDmg(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddDmg adds value to the "dmg" field.
|
||||
func (_u *WeaponUpdateOne) AddDmg(v int) *WeaponUpdateOne {
|
||||
_u.mutation.AddDmg(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEqType sets the "eq_type" field.
|
||||
func (wuo *WeaponUpdateOne) SetEqType(i int) *WeaponUpdateOne {
|
||||
wuo.mutation.ResetEqType()
|
||||
wuo.mutation.SetEqType(i)
|
||||
return wuo
|
||||
func (_u *WeaponUpdateOne) SetEqType(v int) *WeaponUpdateOne {
|
||||
_u.mutation.ResetEqType()
|
||||
_u.mutation.SetEqType(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddEqType adds i to the "eq_type" field.
|
||||
func (wuo *WeaponUpdateOne) AddEqType(i int) *WeaponUpdateOne {
|
||||
wuo.mutation.AddEqType(i)
|
||||
return wuo
|
||||
// SetNillableEqType sets the "eq_type" field if the given value is not nil.
|
||||
func (_u *WeaponUpdateOne) SetNillableEqType(v *int) *WeaponUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetEqType(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddEqType adds value to the "eq_type" field.
|
||||
func (_u *WeaponUpdateOne) AddEqType(v int) *WeaponUpdateOne {
|
||||
_u.mutation.AddEqType(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetHitGroup sets the "hit_group" field.
|
||||
func (wuo *WeaponUpdateOne) SetHitGroup(i int) *WeaponUpdateOne {
|
||||
wuo.mutation.ResetHitGroup()
|
||||
wuo.mutation.SetHitGroup(i)
|
||||
return wuo
|
||||
func (_u *WeaponUpdateOne) SetHitGroup(v int) *WeaponUpdateOne {
|
||||
_u.mutation.ResetHitGroup()
|
||||
_u.mutation.SetHitGroup(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddHitGroup adds i to the "hit_group" field.
|
||||
func (wuo *WeaponUpdateOne) AddHitGroup(i int) *WeaponUpdateOne {
|
||||
wuo.mutation.AddHitGroup(i)
|
||||
return wuo
|
||||
// SetNillableHitGroup sets the "hit_group" field if the given value is not nil.
|
||||
func (_u *WeaponUpdateOne) SetNillableHitGroup(v *int) *WeaponUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetHitGroup(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// AddHitGroup adds value to the "hit_group" field.
|
||||
func (_u *WeaponUpdateOne) AddHitGroup(v int) *WeaponUpdateOne {
|
||||
_u.mutation.AddHitGroup(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetStatID sets the "stat" edge to the MatchPlayer entity by ID.
|
||||
func (wuo *WeaponUpdateOne) SetStatID(id int) *WeaponUpdateOne {
|
||||
wuo.mutation.SetStatID(id)
|
||||
return wuo
|
||||
func (_u *WeaponUpdateOne) SetStatID(id int) *WeaponUpdateOne {
|
||||
_u.mutation.SetStatID(id)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableStatID sets the "stat" edge to the MatchPlayer entity by ID if the given value is not nil.
|
||||
func (wuo *WeaponUpdateOne) SetNillableStatID(id *int) *WeaponUpdateOne {
|
||||
func (_u *WeaponUpdateOne) SetNillableStatID(id *int) *WeaponUpdateOne {
|
||||
if id != nil {
|
||||
wuo = wuo.SetStatID(*id)
|
||||
_u = _u.SetStatID(*id)
|
||||
}
|
||||
return wuo
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetStat sets the "stat" edge to the MatchPlayer entity.
|
||||
func (wuo *WeaponUpdateOne) SetStat(m *MatchPlayer) *WeaponUpdateOne {
|
||||
return wuo.SetStatID(m.ID)
|
||||
func (_u *WeaponUpdateOne) SetStat(v *MatchPlayer) *WeaponUpdateOne {
|
||||
return _u.SetStatID(v.ID)
|
||||
}
|
||||
|
||||
// Mutation returns the WeaponMutation object of the builder.
|
||||
func (wuo *WeaponUpdateOne) Mutation() *WeaponMutation {
|
||||
return wuo.mutation
|
||||
func (_u *WeaponUpdateOne) Mutation() *WeaponMutation {
|
||||
return _u.mutation
|
||||
}
|
||||
|
||||
// ClearStat clears the "stat" edge to the MatchPlayer entity.
|
||||
func (wuo *WeaponUpdateOne) ClearStat() *WeaponUpdateOne {
|
||||
wuo.mutation.ClearStat()
|
||||
return wuo
|
||||
func (_u *WeaponUpdateOne) ClearStat() *WeaponUpdateOne {
|
||||
_u.mutation.ClearStat()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Where appends a list predicates to the WeaponUpdate builder.
|
||||
func (wuo *WeaponUpdateOne) Where(ps ...predicate.Weapon) *WeaponUpdateOne {
|
||||
wuo.mutation.Where(ps...)
|
||||
return wuo
|
||||
func (_u *WeaponUpdateOne) Where(ps ...predicate.Weapon) *WeaponUpdateOne {
|
||||
_u.mutation.Where(ps...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Select allows selecting one or more fields (columns) of the returned entity.
|
||||
// The default is selecting all fields defined in the entity schema.
|
||||
func (wuo *WeaponUpdateOne) Select(field string, fields ...string) *WeaponUpdateOne {
|
||||
wuo.fields = append([]string{field}, fields...)
|
||||
return wuo
|
||||
func (_u *WeaponUpdateOne) Select(field string, fields ...string) *WeaponUpdateOne {
|
||||
_u.fields = append([]string{field}, fields...)
|
||||
return _u
|
||||
}
|
||||
|
||||
// Save executes the query and returns the updated Weapon entity.
|
||||
func (wuo *WeaponUpdateOne) Save(ctx context.Context) (*Weapon, error) {
|
||||
return withHooks(ctx, wuo.sqlSave, wuo.mutation, wuo.hooks)
|
||||
func (_u *WeaponUpdateOne) Save(ctx context.Context) (*Weapon, error) {
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
// SaveX is like Save, but panics if an error occurs.
|
||||
func (wuo *WeaponUpdateOne) SaveX(ctx context.Context) *Weapon {
|
||||
node, err := wuo.Save(ctx)
|
||||
func (_u *WeaponUpdateOne) SaveX(ctx context.Context) *Weapon {
|
||||
node, err := _u.Save(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -338,32 +402,32 @@ func (wuo *WeaponUpdateOne) SaveX(ctx context.Context) *Weapon {
|
||||
}
|
||||
|
||||
// Exec executes the query on the entity.
|
||||
func (wuo *WeaponUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := wuo.Save(ctx)
|
||||
func (_u *WeaponUpdateOne) Exec(ctx context.Context) error {
|
||||
_, err := _u.Save(ctx)
|
||||
return err
|
||||
}
|
||||
|
||||
// ExecX is like Exec, but panics if an error occurs.
|
||||
func (wuo *WeaponUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := wuo.Exec(ctx); err != nil {
|
||||
func (_u *WeaponUpdateOne) ExecX(ctx context.Context) {
|
||||
if err := _u.Exec(ctx); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
||||
func (wuo *WeaponUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WeaponUpdateOne {
|
||||
wuo.modifiers = append(wuo.modifiers, modifiers...)
|
||||
return wuo
|
||||
func (_u *WeaponUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WeaponUpdateOne {
|
||||
_u.modifiers = append(_u.modifiers, modifiers...)
|
||||
return _u
|
||||
}
|
||||
|
||||
func (wuo *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err error) {
|
||||
func (_u *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err error) {
|
||||
_spec := sqlgraph.NewUpdateSpec(weapon.Table, weapon.Columns, sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt))
|
||||
id, ok := wuo.mutation.ID()
|
||||
id, ok := _u.mutation.ID()
|
||||
if !ok {
|
||||
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Weapon.id" for update`)}
|
||||
}
|
||||
_spec.Node.ID.Value = id
|
||||
if fields := wuo.fields; len(fields) > 0 {
|
||||
if fields := _u.fields; len(fields) > 0 {
|
||||
_spec.Node.Columns = make([]string, 0, len(fields))
|
||||
_spec.Node.Columns = append(_spec.Node.Columns, weapon.FieldID)
|
||||
for _, f := range fields {
|
||||
@@ -375,38 +439,38 @@ func (wuo *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err err
|
||||
}
|
||||
}
|
||||
}
|
||||
if ps := wuo.mutation.predicates; len(ps) > 0 {
|
||||
if ps := _u.mutation.predicates; len(ps) > 0 {
|
||||
_spec.Predicate = func(selector *sql.Selector) {
|
||||
for i := range ps {
|
||||
ps[i](selector)
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := wuo.mutation.Victim(); ok {
|
||||
if value, ok := _u.mutation.Victim(); ok {
|
||||
_spec.SetField(weapon.FieldVictim, field.TypeUint64, value)
|
||||
}
|
||||
if value, ok := wuo.mutation.AddedVictim(); ok {
|
||||
if value, ok := _u.mutation.AddedVictim(); ok {
|
||||
_spec.AddField(weapon.FieldVictim, field.TypeUint64, value)
|
||||
}
|
||||
if value, ok := wuo.mutation.Dmg(); ok {
|
||||
if value, ok := _u.mutation.Dmg(); ok {
|
||||
_spec.SetField(weapon.FieldDmg, field.TypeUint, value)
|
||||
}
|
||||
if value, ok := wuo.mutation.AddedDmg(); ok {
|
||||
if value, ok := _u.mutation.AddedDmg(); ok {
|
||||
_spec.AddField(weapon.FieldDmg, field.TypeUint, value)
|
||||
}
|
||||
if value, ok := wuo.mutation.EqType(); ok {
|
||||
if value, ok := _u.mutation.EqType(); ok {
|
||||
_spec.SetField(weapon.FieldEqType, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := wuo.mutation.AddedEqType(); ok {
|
||||
if value, ok := _u.mutation.AddedEqType(); ok {
|
||||
_spec.AddField(weapon.FieldEqType, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := wuo.mutation.HitGroup(); ok {
|
||||
if value, ok := _u.mutation.HitGroup(); ok {
|
||||
_spec.SetField(weapon.FieldHitGroup, field.TypeInt, value)
|
||||
}
|
||||
if value, ok := wuo.mutation.AddedHitGroup(); ok {
|
||||
if value, ok := _u.mutation.AddedHitGroup(); ok {
|
||||
_spec.AddField(weapon.FieldHitGroup, field.TypeInt, value)
|
||||
}
|
||||
if wuo.mutation.StatCleared() {
|
||||
if _u.mutation.StatCleared() {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -419,7 +483,7 @@ func (wuo *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err err
|
||||
}
|
||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||
}
|
||||
if nodes := wuo.mutation.StatIDs(); len(nodes) > 0 {
|
||||
if nodes := _u.mutation.StatIDs(); len(nodes) > 0 {
|
||||
edge := &sqlgraph.EdgeSpec{
|
||||
Rel: sqlgraph.M2O,
|
||||
Inverse: true,
|
||||
@@ -435,11 +499,11 @@ func (wuo *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err err
|
||||
}
|
||||
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
||||
}
|
||||
_spec.AddModifiers(wuo.modifiers...)
|
||||
_node = &Weapon{config: wuo.config}
|
||||
_spec.AddModifiers(_u.modifiers...)
|
||||
_node = &Weapon{config: _u.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
_spec.ScanValues = _node.scanValues
|
||||
if err = sqlgraph.UpdateNode(ctx, wuo.driver, _spec); err != nil {
|
||||
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
err = &NotFoundError{weapon.Label}
|
||||
} else if sqlgraph.IsConstraintError(err) {
|
||||
@@ -447,6 +511,6 @@ func (wuo *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err err
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
wuo.mutation.done = true
|
||||
_u.mutation.done = true
|
||||
return _node, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user