1171 lines
33 KiB
Go
1171 lines
33 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
"somegit.dev/csgowtf/csgowtfd/ent/match"
|
|
"somegit.dev/csgowtf/csgowtfd/ent/matchplayer"
|
|
"somegit.dev/csgowtf/csgowtfd/ent/player"
|
|
"somegit.dev/csgowtf/csgowtfd/ent/predicate"
|
|
)
|
|
|
|
// MatchUpdate is the builder for updating Match entities.
|
|
type MatchUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *MatchMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// Where appends a list predicates to the MatchUpdate builder.
|
|
func (_u *MatchUpdate) Where(ps ...predicate.Match) *MatchUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetShareCode sets the "share_code" field.
|
|
func (_u *MatchUpdate) SetShareCode(v string) *MatchUpdate {
|
|
_u.mutation.SetShareCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableShareCode sets the "share_code" field if the given value is not nil.
|
|
func (_u *MatchUpdate) SetNillableShareCode(v *string) *MatchUpdate {
|
|
if v != nil {
|
|
_u.SetShareCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetMap sets the "map" field.
|
|
func (_u *MatchUpdate) SetMap(v string) *MatchUpdate {
|
|
_u.mutation.SetMap(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMap sets the "map" field if the given value is not nil.
|
|
func (_u *MatchUpdate) SetNillableMap(v *string) *MatchUpdate {
|
|
if v != nil {
|
|
_u.SetMap(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearMap clears the value of the "map" field.
|
|
func (_u *MatchUpdate) ClearMap() *MatchUpdate {
|
|
_u.mutation.ClearMap()
|
|
return _u
|
|
}
|
|
|
|
// SetDate sets the "date" field.
|
|
func (_u *MatchUpdate) SetDate(v time.Time) *MatchUpdate {
|
|
_u.mutation.SetDate(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDate sets the "date" field if the given value is not nil.
|
|
func (_u *MatchUpdate) SetNillableDate(v *time.Time) *MatchUpdate {
|
|
if v != nil {
|
|
_u.SetDate(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetScoreTeamA sets the "score_team_a" field.
|
|
func (_u *MatchUpdate) SetScoreTeamA(v int) *MatchUpdate {
|
|
_u.mutation.ResetScoreTeamA()
|
|
_u.mutation.SetScoreTeamA(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableScoreTeamA sets the "score_team_a" field if the given value is not nil.
|
|
func (_u *MatchUpdate) SetNillableScoreTeamA(v *int) *MatchUpdate {
|
|
if v != nil {
|
|
_u.SetScoreTeamA(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddScoreTeamA adds value to the "score_team_a" field.
|
|
func (_u *MatchUpdate) AddScoreTeamA(v int) *MatchUpdate {
|
|
_u.mutation.AddScoreTeamA(v)
|
|
return _u
|
|
}
|
|
|
|
// SetScoreTeamB sets the "score_team_b" field.
|
|
func (_u *MatchUpdate) SetScoreTeamB(v int) *MatchUpdate {
|
|
_u.mutation.ResetScoreTeamB()
|
|
_u.mutation.SetScoreTeamB(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableScoreTeamB sets the "score_team_b" field if the given value is not nil.
|
|
func (_u *MatchUpdate) SetNillableScoreTeamB(v *int) *MatchUpdate {
|
|
if v != nil {
|
|
_u.SetScoreTeamB(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddScoreTeamB adds value to the "score_team_b" field.
|
|
func (_u *MatchUpdate) AddScoreTeamB(v int) *MatchUpdate {
|
|
_u.mutation.AddScoreTeamB(v)
|
|
return _u
|
|
}
|
|
|
|
// SetReplayURL sets the "replay_url" field.
|
|
func (_u *MatchUpdate) SetReplayURL(v string) *MatchUpdate {
|
|
_u.mutation.SetReplayURL(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableReplayURL sets the "replay_url" field if the given value is not nil.
|
|
func (_u *MatchUpdate) SetNillableReplayURL(v *string) *MatchUpdate {
|
|
if v != nil {
|
|
_u.SetReplayURL(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearReplayURL clears the value of the "replay_url" field.
|
|
func (_u *MatchUpdate) ClearReplayURL() *MatchUpdate {
|
|
_u.mutation.ClearReplayURL()
|
|
return _u
|
|
}
|
|
|
|
// SetDuration sets the "duration" field.
|
|
func (_u *MatchUpdate) SetDuration(v int) *MatchUpdate {
|
|
_u.mutation.ResetDuration()
|
|
_u.mutation.SetDuration(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDuration sets the "duration" field if the given value is not nil.
|
|
func (_u *MatchUpdate) SetNillableDuration(v *int) *MatchUpdate {
|
|
if v != nil {
|
|
_u.SetDuration(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddDuration adds value to the "duration" field.
|
|
func (_u *MatchUpdate) AddDuration(v int) *MatchUpdate {
|
|
_u.mutation.AddDuration(v)
|
|
return _u
|
|
}
|
|
|
|
// SetMatchResult sets the "match_result" field.
|
|
func (_u *MatchUpdate) SetMatchResult(v int) *MatchUpdate {
|
|
_u.mutation.ResetMatchResult()
|
|
_u.mutation.SetMatchResult(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMatchResult sets the "match_result" field if the given value is not nil.
|
|
func (_u *MatchUpdate) SetNillableMatchResult(v *int) *MatchUpdate {
|
|
if v != nil {
|
|
_u.SetMatchResult(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddMatchResult adds value to the "match_result" field.
|
|
func (_u *MatchUpdate) AddMatchResult(v int) *MatchUpdate {
|
|
_u.mutation.AddMatchResult(v)
|
|
return _u
|
|
}
|
|
|
|
// SetMaxRounds sets the "max_rounds" field.
|
|
func (_u *MatchUpdate) SetMaxRounds(v int) *MatchUpdate {
|
|
_u.mutation.ResetMaxRounds()
|
|
_u.mutation.SetMaxRounds(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMaxRounds sets the "max_rounds" field if the given value is not nil.
|
|
func (_u *MatchUpdate) SetNillableMaxRounds(v *int) *MatchUpdate {
|
|
if v != nil {
|
|
_u.SetMaxRounds(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddMaxRounds adds value to the "max_rounds" field.
|
|
func (_u *MatchUpdate) AddMaxRounds(v int) *MatchUpdate {
|
|
_u.mutation.AddMaxRounds(v)
|
|
return _u
|
|
}
|
|
|
|
// SetDemoParsed sets the "demo_parsed" field.
|
|
func (_u *MatchUpdate) SetDemoParsed(v bool) *MatchUpdate {
|
|
_u.mutation.SetDemoParsed(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDemoParsed sets the "demo_parsed" field if the given value is not nil.
|
|
func (_u *MatchUpdate) SetNillableDemoParsed(v *bool) *MatchUpdate {
|
|
if v != nil {
|
|
_u.SetDemoParsed(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetVacPresent sets the "vac_present" field.
|
|
func (_u *MatchUpdate) SetVacPresent(v bool) *MatchUpdate {
|
|
_u.mutation.SetVacPresent(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableVacPresent sets the "vac_present" field if the given value is not nil.
|
|
func (_u *MatchUpdate) SetNillableVacPresent(v *bool) *MatchUpdate {
|
|
if v != nil {
|
|
_u.SetVacPresent(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetGamebanPresent sets the "gameban_present" field.
|
|
func (_u *MatchUpdate) SetGamebanPresent(v bool) *MatchUpdate {
|
|
_u.mutation.SetGamebanPresent(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableGamebanPresent sets the "gameban_present" field if the given value is not nil.
|
|
func (_u *MatchUpdate) SetNillableGamebanPresent(v *bool) *MatchUpdate {
|
|
if v != nil {
|
|
_u.SetGamebanPresent(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetDecryptionKey sets the "decryption_key" field.
|
|
func (_u *MatchUpdate) SetDecryptionKey(v []byte) *MatchUpdate {
|
|
_u.mutation.SetDecryptionKey(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearDecryptionKey clears the value of the "decryption_key" field.
|
|
func (_u *MatchUpdate) ClearDecryptionKey() *MatchUpdate {
|
|
_u.mutation.ClearDecryptionKey()
|
|
return _u
|
|
}
|
|
|
|
// SetTickRate sets the "tick_rate" field.
|
|
func (_u *MatchUpdate) SetTickRate(v float64) *MatchUpdate {
|
|
_u.mutation.ResetTickRate()
|
|
_u.mutation.SetTickRate(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTickRate sets the "tick_rate" field if the given value is not nil.
|
|
func (_u *MatchUpdate) SetNillableTickRate(v *float64) *MatchUpdate {
|
|
if v != nil {
|
|
_u.SetTickRate(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddTickRate adds value to the "tick_rate" field.
|
|
func (_u *MatchUpdate) AddTickRate(v float64) *MatchUpdate {
|
|
_u.mutation.AddTickRate(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearTickRate clears the value of the "tick_rate" field.
|
|
func (_u *MatchUpdate) ClearTickRate() *MatchUpdate {
|
|
_u.mutation.ClearTickRate()
|
|
return _u
|
|
}
|
|
|
|
// AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs.
|
|
func (_u *MatchUpdate) AddStatIDs(ids ...int) *MatchUpdate {
|
|
_u.mutation.AddStatIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddStats adds the "stats" edges to the MatchPlayer entity.
|
|
func (_u *MatchUpdate) AddStats(v ...*MatchPlayer) *MatchUpdate {
|
|
ids := make([]int, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddStatIDs(ids...)
|
|
}
|
|
|
|
// AddPlayerIDs adds the "players" edge to the Player entity by IDs.
|
|
func (_u *MatchUpdate) AddPlayerIDs(ids ...uint64) *MatchUpdate {
|
|
_u.mutation.AddPlayerIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddPlayers adds the "players" edges to the Player entity.
|
|
func (_u *MatchUpdate) AddPlayers(v ...*Player) *MatchUpdate {
|
|
ids := make([]uint64, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddPlayerIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the MatchMutation object of the builder.
|
|
func (_u *MatchUpdate) Mutation() *MatchMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearStats clears all "stats" edges to the MatchPlayer entity.
|
|
func (_u *MatchUpdate) ClearStats() *MatchUpdate {
|
|
_u.mutation.ClearStats()
|
|
return _u
|
|
}
|
|
|
|
// RemoveStatIDs removes the "stats" edge to MatchPlayer entities by IDs.
|
|
func (_u *MatchUpdate) RemoveStatIDs(ids ...int) *MatchUpdate {
|
|
_u.mutation.RemoveStatIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveStats removes "stats" edges to MatchPlayer entities.
|
|
func (_u *MatchUpdate) RemoveStats(v ...*MatchPlayer) *MatchUpdate {
|
|
ids := make([]int, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveStatIDs(ids...)
|
|
}
|
|
|
|
// ClearPlayers clears all "players" edges to the Player entity.
|
|
func (_u *MatchUpdate) ClearPlayers() *MatchUpdate {
|
|
_u.mutation.ClearPlayers()
|
|
return _u
|
|
}
|
|
|
|
// RemovePlayerIDs removes the "players" edge to Player entities by IDs.
|
|
func (_u *MatchUpdate) RemovePlayerIDs(ids ...uint64) *MatchUpdate {
|
|
_u.mutation.RemovePlayerIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemovePlayers removes "players" edges to Player entities.
|
|
func (_u *MatchUpdate) RemovePlayers(v ...*Player) *MatchUpdate {
|
|
ids := make([]uint64, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemovePlayerIDs(ids...)
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *MatchUpdate) Save(ctx context.Context) (int, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *MatchUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *MatchUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *MatchUpdate) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *MatchUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MatchUpdate {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *MatchUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
_spec := sqlgraph.NewUpdateSpec(match.Table, match.Columns, sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64))
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.ShareCode(); ok {
|
|
_spec.SetField(match.FieldShareCode, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Map(); ok {
|
|
_spec.SetField(match.FieldMap, field.TypeString, value)
|
|
}
|
|
if _u.mutation.MapCleared() {
|
|
_spec.ClearField(match.FieldMap, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Date(); ok {
|
|
_spec.SetField(match.FieldDate, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.ScoreTeamA(); ok {
|
|
_spec.SetField(match.FieldScoreTeamA, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedScoreTeamA(); ok {
|
|
_spec.AddField(match.FieldScoreTeamA, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.ScoreTeamB(); ok {
|
|
_spec.SetField(match.FieldScoreTeamB, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedScoreTeamB(); ok {
|
|
_spec.AddField(match.FieldScoreTeamB, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.ReplayURL(); ok {
|
|
_spec.SetField(match.FieldReplayURL, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ReplayURLCleared() {
|
|
_spec.ClearField(match.FieldReplayURL, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Duration(); ok {
|
|
_spec.SetField(match.FieldDuration, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedDuration(); ok {
|
|
_spec.AddField(match.FieldDuration, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.MatchResult(); ok {
|
|
_spec.SetField(match.FieldMatchResult, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedMatchResult(); ok {
|
|
_spec.AddField(match.FieldMatchResult, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.MaxRounds(); ok {
|
|
_spec.SetField(match.FieldMaxRounds, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedMaxRounds(); ok {
|
|
_spec.AddField(match.FieldMaxRounds, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.DemoParsed(); ok {
|
|
_spec.SetField(match.FieldDemoParsed, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.VacPresent(); ok {
|
|
_spec.SetField(match.FieldVacPresent, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.GamebanPresent(); ok {
|
|
_spec.SetField(match.FieldGamebanPresent, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.DecryptionKey(); ok {
|
|
_spec.SetField(match.FieldDecryptionKey, field.TypeBytes, value)
|
|
}
|
|
if _u.mutation.DecryptionKeyCleared() {
|
|
_spec.ClearField(match.FieldDecryptionKey, field.TypeBytes)
|
|
}
|
|
if value, ok := _u.mutation.TickRate(); ok {
|
|
_spec.SetField(match.FieldTickRate, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedTickRate(); ok {
|
|
_spec.AddField(match.FieldTickRate, field.TypeFloat64, value)
|
|
}
|
|
if _u.mutation.TickRateCleared() {
|
|
_spec.ClearField(match.FieldTickRate, field.TypeFloat64)
|
|
}
|
|
if _u.mutation.StatsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: match.StatsTable,
|
|
Columns: []string{match.StatsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedStatsIDs(); len(nodes) > 0 && !_u.mutation.StatsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: match.StatsTable,
|
|
Columns: []string{match.StatsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.StatsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: match.StatsTable,
|
|
Columns: []string{match.StatsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.PlayersCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: match.PlayersTable,
|
|
Columns: match.PlayersPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedPlayersIDs(); len(nodes) > 0 && !_u.mutation.PlayersCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: match.PlayersTable,
|
|
Columns: match.PlayersPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.PlayersIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: match.PlayersTable,
|
|
Columns: match.PlayersPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{match.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// MatchUpdateOne is the builder for updating a single Match entity.
|
|
type MatchUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *MatchMutation
|
|
modifiers []func(*sql.UpdateBuilder)
|
|
}
|
|
|
|
// SetShareCode sets the "share_code" field.
|
|
func (_u *MatchUpdateOne) SetShareCode(v string) *MatchUpdateOne {
|
|
_u.mutation.SetShareCode(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableShareCode sets the "share_code" field if the given value is not nil.
|
|
func (_u *MatchUpdateOne) SetNillableShareCode(v *string) *MatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetShareCode(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetMap sets the "map" field.
|
|
func (_u *MatchUpdateOne) SetMap(v string) *MatchUpdateOne {
|
|
_u.mutation.SetMap(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMap sets the "map" field if the given value is not nil.
|
|
func (_u *MatchUpdateOne) SetNillableMap(v *string) *MatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetMap(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearMap clears the value of the "map" field.
|
|
func (_u *MatchUpdateOne) ClearMap() *MatchUpdateOne {
|
|
_u.mutation.ClearMap()
|
|
return _u
|
|
}
|
|
|
|
// SetDate sets the "date" field.
|
|
func (_u *MatchUpdateOne) SetDate(v time.Time) *MatchUpdateOne {
|
|
_u.mutation.SetDate(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDate sets the "date" field if the given value is not nil.
|
|
func (_u *MatchUpdateOne) SetNillableDate(v *time.Time) *MatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetDate(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetScoreTeamA sets the "score_team_a" field.
|
|
func (_u *MatchUpdateOne) SetScoreTeamA(v int) *MatchUpdateOne {
|
|
_u.mutation.ResetScoreTeamA()
|
|
_u.mutation.SetScoreTeamA(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableScoreTeamA sets the "score_team_a" field if the given value is not nil.
|
|
func (_u *MatchUpdateOne) SetNillableScoreTeamA(v *int) *MatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetScoreTeamA(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddScoreTeamA adds value to the "score_team_a" field.
|
|
func (_u *MatchUpdateOne) AddScoreTeamA(v int) *MatchUpdateOne {
|
|
_u.mutation.AddScoreTeamA(v)
|
|
return _u
|
|
}
|
|
|
|
// SetScoreTeamB sets the "score_team_b" field.
|
|
func (_u *MatchUpdateOne) SetScoreTeamB(v int) *MatchUpdateOne {
|
|
_u.mutation.ResetScoreTeamB()
|
|
_u.mutation.SetScoreTeamB(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableScoreTeamB sets the "score_team_b" field if the given value is not nil.
|
|
func (_u *MatchUpdateOne) SetNillableScoreTeamB(v *int) *MatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetScoreTeamB(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddScoreTeamB adds value to the "score_team_b" field.
|
|
func (_u *MatchUpdateOne) AddScoreTeamB(v int) *MatchUpdateOne {
|
|
_u.mutation.AddScoreTeamB(v)
|
|
return _u
|
|
}
|
|
|
|
// SetReplayURL sets the "replay_url" field.
|
|
func (_u *MatchUpdateOne) SetReplayURL(v string) *MatchUpdateOne {
|
|
_u.mutation.SetReplayURL(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableReplayURL sets the "replay_url" field if the given value is not nil.
|
|
func (_u *MatchUpdateOne) SetNillableReplayURL(v *string) *MatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetReplayURL(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearReplayURL clears the value of the "replay_url" field.
|
|
func (_u *MatchUpdateOne) ClearReplayURL() *MatchUpdateOne {
|
|
_u.mutation.ClearReplayURL()
|
|
return _u
|
|
}
|
|
|
|
// SetDuration sets the "duration" field.
|
|
func (_u *MatchUpdateOne) SetDuration(v int) *MatchUpdateOne {
|
|
_u.mutation.ResetDuration()
|
|
_u.mutation.SetDuration(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDuration sets the "duration" field if the given value is not nil.
|
|
func (_u *MatchUpdateOne) SetNillableDuration(v *int) *MatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetDuration(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddDuration adds value to the "duration" field.
|
|
func (_u *MatchUpdateOne) AddDuration(v int) *MatchUpdateOne {
|
|
_u.mutation.AddDuration(v)
|
|
return _u
|
|
}
|
|
|
|
// SetMatchResult sets the "match_result" field.
|
|
func (_u *MatchUpdateOne) SetMatchResult(v int) *MatchUpdateOne {
|
|
_u.mutation.ResetMatchResult()
|
|
_u.mutation.SetMatchResult(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMatchResult sets the "match_result" field if the given value is not nil.
|
|
func (_u *MatchUpdateOne) SetNillableMatchResult(v *int) *MatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetMatchResult(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddMatchResult adds value to the "match_result" field.
|
|
func (_u *MatchUpdateOne) AddMatchResult(v int) *MatchUpdateOne {
|
|
_u.mutation.AddMatchResult(v)
|
|
return _u
|
|
}
|
|
|
|
// SetMaxRounds sets the "max_rounds" field.
|
|
func (_u *MatchUpdateOne) SetMaxRounds(v int) *MatchUpdateOne {
|
|
_u.mutation.ResetMaxRounds()
|
|
_u.mutation.SetMaxRounds(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableMaxRounds sets the "max_rounds" field if the given value is not nil.
|
|
func (_u *MatchUpdateOne) SetNillableMaxRounds(v *int) *MatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetMaxRounds(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddMaxRounds adds value to the "max_rounds" field.
|
|
func (_u *MatchUpdateOne) AddMaxRounds(v int) *MatchUpdateOne {
|
|
_u.mutation.AddMaxRounds(v)
|
|
return _u
|
|
}
|
|
|
|
// SetDemoParsed sets the "demo_parsed" field.
|
|
func (_u *MatchUpdateOne) SetDemoParsed(v bool) *MatchUpdateOne {
|
|
_u.mutation.SetDemoParsed(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableDemoParsed sets the "demo_parsed" field if the given value is not nil.
|
|
func (_u *MatchUpdateOne) SetNillableDemoParsed(v *bool) *MatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetDemoParsed(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetVacPresent sets the "vac_present" field.
|
|
func (_u *MatchUpdateOne) SetVacPresent(v bool) *MatchUpdateOne {
|
|
_u.mutation.SetVacPresent(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableVacPresent sets the "vac_present" field if the given value is not nil.
|
|
func (_u *MatchUpdateOne) SetNillableVacPresent(v *bool) *MatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetVacPresent(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetGamebanPresent sets the "gameban_present" field.
|
|
func (_u *MatchUpdateOne) SetGamebanPresent(v bool) *MatchUpdateOne {
|
|
_u.mutation.SetGamebanPresent(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableGamebanPresent sets the "gameban_present" field if the given value is not nil.
|
|
func (_u *MatchUpdateOne) SetNillableGamebanPresent(v *bool) *MatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetGamebanPresent(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetDecryptionKey sets the "decryption_key" field.
|
|
func (_u *MatchUpdateOne) SetDecryptionKey(v []byte) *MatchUpdateOne {
|
|
_u.mutation.SetDecryptionKey(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearDecryptionKey clears the value of the "decryption_key" field.
|
|
func (_u *MatchUpdateOne) ClearDecryptionKey() *MatchUpdateOne {
|
|
_u.mutation.ClearDecryptionKey()
|
|
return _u
|
|
}
|
|
|
|
// SetTickRate sets the "tick_rate" field.
|
|
func (_u *MatchUpdateOne) SetTickRate(v float64) *MatchUpdateOne {
|
|
_u.mutation.ResetTickRate()
|
|
_u.mutation.SetTickRate(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTickRate sets the "tick_rate" field if the given value is not nil.
|
|
func (_u *MatchUpdateOne) SetNillableTickRate(v *float64) *MatchUpdateOne {
|
|
if v != nil {
|
|
_u.SetTickRate(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// AddTickRate adds value to the "tick_rate" field.
|
|
func (_u *MatchUpdateOne) AddTickRate(v float64) *MatchUpdateOne {
|
|
_u.mutation.AddTickRate(v)
|
|
return _u
|
|
}
|
|
|
|
// ClearTickRate clears the value of the "tick_rate" field.
|
|
func (_u *MatchUpdateOne) ClearTickRate() *MatchUpdateOne {
|
|
_u.mutation.ClearTickRate()
|
|
return _u
|
|
}
|
|
|
|
// AddStatIDs adds the "stats" edge to the MatchPlayer entity by IDs.
|
|
func (_u *MatchUpdateOne) AddStatIDs(ids ...int) *MatchUpdateOne {
|
|
_u.mutation.AddStatIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddStats adds the "stats" edges to the MatchPlayer entity.
|
|
func (_u *MatchUpdateOne) AddStats(v ...*MatchPlayer) *MatchUpdateOne {
|
|
ids := make([]int, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddStatIDs(ids...)
|
|
}
|
|
|
|
// AddPlayerIDs adds the "players" edge to the Player entity by IDs.
|
|
func (_u *MatchUpdateOne) AddPlayerIDs(ids ...uint64) *MatchUpdateOne {
|
|
_u.mutation.AddPlayerIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// AddPlayers adds the "players" edges to the Player entity.
|
|
func (_u *MatchUpdateOne) AddPlayers(v ...*Player) *MatchUpdateOne {
|
|
ids := make([]uint64, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.AddPlayerIDs(ids...)
|
|
}
|
|
|
|
// Mutation returns the MatchMutation object of the builder.
|
|
func (_u *MatchUpdateOne) Mutation() *MatchMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearStats clears all "stats" edges to the MatchPlayer entity.
|
|
func (_u *MatchUpdateOne) ClearStats() *MatchUpdateOne {
|
|
_u.mutation.ClearStats()
|
|
return _u
|
|
}
|
|
|
|
// RemoveStatIDs removes the "stats" edge to MatchPlayer entities by IDs.
|
|
func (_u *MatchUpdateOne) RemoveStatIDs(ids ...int) *MatchUpdateOne {
|
|
_u.mutation.RemoveStatIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemoveStats removes "stats" edges to MatchPlayer entities.
|
|
func (_u *MatchUpdateOne) RemoveStats(v ...*MatchPlayer) *MatchUpdateOne {
|
|
ids := make([]int, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemoveStatIDs(ids...)
|
|
}
|
|
|
|
// ClearPlayers clears all "players" edges to the Player entity.
|
|
func (_u *MatchUpdateOne) ClearPlayers() *MatchUpdateOne {
|
|
_u.mutation.ClearPlayers()
|
|
return _u
|
|
}
|
|
|
|
// RemovePlayerIDs removes the "players" edge to Player entities by IDs.
|
|
func (_u *MatchUpdateOne) RemovePlayerIDs(ids ...uint64) *MatchUpdateOne {
|
|
_u.mutation.RemovePlayerIDs(ids...)
|
|
return _u
|
|
}
|
|
|
|
// RemovePlayers removes "players" edges to Player entities.
|
|
func (_u *MatchUpdateOne) RemovePlayers(v ...*Player) *MatchUpdateOne {
|
|
ids := make([]uint64, len(v))
|
|
for i := range v {
|
|
ids[i] = v[i].ID
|
|
}
|
|
return _u.RemovePlayerIDs(ids...)
|
|
}
|
|
|
|
// Where appends a list predicates to the MatchUpdate builder.
|
|
func (_u *MatchUpdateOne) Where(ps ...predicate.Match) *MatchUpdateOne {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (_u *MatchUpdateOne) Select(field string, fields ...string) *MatchUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated Match entity.
|
|
func (_u *MatchUpdateOne) Save(ctx context.Context) (*Match, error) {
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *MatchUpdateOne) SaveX(ctx context.Context) *Match {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *MatchUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *MatchUpdateOne) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// Modify adds a statement modifier for attaching custom logic to the UPDATE statement.
|
|
func (_u *MatchUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MatchUpdateOne {
|
|
_u.modifiers = append(_u.modifiers, modifiers...)
|
|
return _u
|
|
}
|
|
|
|
func (_u *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error) {
|
|
_spec := sqlgraph.NewUpdateSpec(match.Table, match.Columns, sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Match.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := _u.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, match.FieldID)
|
|
for _, f := range fields {
|
|
if !match.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != match.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.ShareCode(); ok {
|
|
_spec.SetField(match.FieldShareCode, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Map(); ok {
|
|
_spec.SetField(match.FieldMap, field.TypeString, value)
|
|
}
|
|
if _u.mutation.MapCleared() {
|
|
_spec.ClearField(match.FieldMap, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Date(); ok {
|
|
_spec.SetField(match.FieldDate, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.ScoreTeamA(); ok {
|
|
_spec.SetField(match.FieldScoreTeamA, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedScoreTeamA(); ok {
|
|
_spec.AddField(match.FieldScoreTeamA, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.ScoreTeamB(); ok {
|
|
_spec.SetField(match.FieldScoreTeamB, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedScoreTeamB(); ok {
|
|
_spec.AddField(match.FieldScoreTeamB, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.ReplayURL(); ok {
|
|
_spec.SetField(match.FieldReplayURL, field.TypeString, value)
|
|
}
|
|
if _u.mutation.ReplayURLCleared() {
|
|
_spec.ClearField(match.FieldReplayURL, field.TypeString)
|
|
}
|
|
if value, ok := _u.mutation.Duration(); ok {
|
|
_spec.SetField(match.FieldDuration, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedDuration(); ok {
|
|
_spec.AddField(match.FieldDuration, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.MatchResult(); ok {
|
|
_spec.SetField(match.FieldMatchResult, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedMatchResult(); ok {
|
|
_spec.AddField(match.FieldMatchResult, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.MaxRounds(); ok {
|
|
_spec.SetField(match.FieldMaxRounds, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedMaxRounds(); ok {
|
|
_spec.AddField(match.FieldMaxRounds, field.TypeInt, value)
|
|
}
|
|
if value, ok := _u.mutation.DemoParsed(); ok {
|
|
_spec.SetField(match.FieldDemoParsed, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.VacPresent(); ok {
|
|
_spec.SetField(match.FieldVacPresent, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.GamebanPresent(); ok {
|
|
_spec.SetField(match.FieldGamebanPresent, field.TypeBool, value)
|
|
}
|
|
if value, ok := _u.mutation.DecryptionKey(); ok {
|
|
_spec.SetField(match.FieldDecryptionKey, field.TypeBytes, value)
|
|
}
|
|
if _u.mutation.DecryptionKeyCleared() {
|
|
_spec.ClearField(match.FieldDecryptionKey, field.TypeBytes)
|
|
}
|
|
if value, ok := _u.mutation.TickRate(); ok {
|
|
_spec.SetField(match.FieldTickRate, field.TypeFloat64, value)
|
|
}
|
|
if value, ok := _u.mutation.AddedTickRate(); ok {
|
|
_spec.AddField(match.FieldTickRate, field.TypeFloat64, value)
|
|
}
|
|
if _u.mutation.TickRateCleared() {
|
|
_spec.ClearField(match.FieldTickRate, field.TypeFloat64)
|
|
}
|
|
if _u.mutation.StatsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: match.StatsTable,
|
|
Columns: []string{match.StatsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedStatsIDs(); len(nodes) > 0 && !_u.mutation.StatsCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: match.StatsTable,
|
|
Columns: []string{match.StatsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.StatsIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2M,
|
|
Inverse: false,
|
|
Table: match.StatsTable,
|
|
Columns: []string{match.StatsColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.PlayersCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: match.PlayersTable,
|
|
Columns: match.PlayersPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.RemovedPlayersIDs(); len(nodes) > 0 && !_u.mutation.PlayersCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: match.PlayersTable,
|
|
Columns: match.PlayersPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.PlayersIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2M,
|
|
Inverse: true,
|
|
Table: match.PlayersTable,
|
|
Columns: match.PlayersPrimaryKey,
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_spec.AddModifiers(_u.modifiers...)
|
|
_node = &Match{config: _u.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{match.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|