diff --git a/ent/client.go b/ent/client.go index c62ac3a..3ebb408 100644 --- a/ent/client.go +++ b/ent/client.go @@ -10,6 +10,10 @@ import ( "git.harting.dev/csgowtf/csgowtfd/ent/migrate" + "entgo.io/ent" + "entgo.io/ent/dialect" + "entgo.io/ent/dialect/sql" + "entgo.io/ent/dialect/sql/sqlgraph" "git.harting.dev/csgowtf/csgowtfd/ent/match" "git.harting.dev/csgowtf/csgowtfd/ent/matchplayer" "git.harting.dev/csgowtf/csgowtfd/ent/messages" @@ -17,10 +21,6 @@ import ( "git.harting.dev/csgowtf/csgowtfd/ent/roundstats" "git.harting.dev/csgowtf/csgowtfd/ent/spray" "git.harting.dev/csgowtf/csgowtfd/ent/weapon" - - "entgo.io/ent/dialect" - "entgo.io/ent/dialect/sql" - "entgo.io/ent/dialect/sql/sqlgraph" ) // Client is the client that holds all ent builders. @@ -46,7 +46,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{}} + cfg := config{log: log.Println, hooks: &hooks{}, inters: &inters{}} cfg.options(opts...) client := &Client{config: cfg} client.init() @@ -64,6 +64,55 @@ func (c *Client) init() { c.Weapon = NewWeaponClient(c.config) } +type ( + // config is the configuration for the client and its builder. + config struct { + // driver used for executing database requests. + driver dialect.Driver + // debug enable a debug logging. + debug bool + // log used for logging on debug mode. + log func(...any) + // hooks to execute on mutations. + hooks *hooks + // interceptors to execute on queries. + inters *inters + } + // Option function to configure the client. + Option func(*config) +) + +// options applies the options on the config object. +func (c *config) options(opts ...Option) { + for _, opt := range opts { + opt(c) + } + if c.debug { + c.driver = dialect.Debug(c.driver, c.log) + } +} + +// Debug enables debug logging on the ent.Driver. +func Debug() Option { + return func(c *config) { + c.debug = true + } +} + +// Log sets the logging function for debug mode. +func Log(fn func(...any)) Option { + return func(c *config) { + c.log = fn + } +} + +// Driver configures the client driver. +func Driver(driver dialect.Driver) Option { + return func(c *config) { + c.driver = driver + } +} + // Open opens a database/sql.DB specified by the driver name and // the data source name, and returns a new client attached to it. // Optional parameters can be added for configuring the client. @@ -156,13 +205,43 @@ func (c *Client) Close() error { // Use adds the mutation hooks to all the entity clients. // In order to add hooks to a specific client, call: `client.Node.Use(...)`. func (c *Client) Use(hooks ...Hook) { - c.Match.Use(hooks...) - c.MatchPlayer.Use(hooks...) - c.Messages.Use(hooks...) - c.Player.Use(hooks...) - c.RoundStats.Use(hooks...) - c.Spray.Use(hooks...) - c.Weapon.Use(hooks...) + for _, n := range []interface{ Use(...Hook) }{ + c.Match, c.MatchPlayer, c.Messages, c.Player, c.RoundStats, c.Spray, c.Weapon, + } { + n.Use(hooks...) + } +} + +// Intercept adds the query interceptors to all the entity clients. +// In order to add interceptors to a specific client, call: `client.Node.Intercept(...)`. +func (c *Client) Intercept(interceptors ...Interceptor) { + for _, n := range []interface{ Intercept(...Interceptor) }{ + c.Match, c.MatchPlayer, c.Messages, c.Player, c.RoundStats, c.Spray, c.Weapon, + } { + n.Intercept(interceptors...) + } +} + +// Mutate implements the ent.Mutator interface. +func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) { + switch m := m.(type) { + case *MatchMutation: + return c.Match.mutate(ctx, m) + case *MatchPlayerMutation: + return c.MatchPlayer.mutate(ctx, m) + case *MessagesMutation: + return c.Messages.mutate(ctx, m) + case *PlayerMutation: + return c.Player.mutate(ctx, m) + case *RoundStatsMutation: + return c.RoundStats.mutate(ctx, m) + case *SprayMutation: + return c.Spray.mutate(ctx, m) + case *WeaponMutation: + return c.Weapon.mutate(ctx, m) + default: + return nil, fmt.Errorf("ent: unknown mutation type %T", m) + } } // MatchClient is a client for the Match schema. @@ -181,6 +260,12 @@ func (c *MatchClient) Use(hooks ...Hook) { c.hooks.Match = append(c.hooks.Match, hooks...) } +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `match.Intercept(f(g(h())))`. +func (c *MatchClient) Intercept(interceptors ...Interceptor) { + c.inters.Match = append(c.inters.Match, interceptors...) +} + // Create returns a builder for creating a Match entity. func (c *MatchClient) Create() *MatchCreate { mutation := newMatchMutation(c.config, OpCreate) @@ -233,6 +318,8 @@ func (c *MatchClient) DeleteOneID(id uint64) *MatchDeleteOne { func (c *MatchClient) Query() *MatchQuery { return &MatchQuery{ config: c.config, + ctx: &QueryContext{Type: TypeMatch}, + inters: c.Interceptors(), } } @@ -252,7 +339,7 @@ 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 { - query := &MatchPlayerQuery{config: c.config} + query := (&MatchPlayerClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := m.ID step := sqlgraph.NewStep( @@ -268,7 +355,7 @@ func (c *MatchClient) QueryStats(m *Match) *MatchPlayerQuery { // QueryPlayers queries the players edge of a Match. func (c *MatchClient) QueryPlayers(m *Match) *PlayerQuery { - query := &PlayerQuery{config: c.config} + query := (&PlayerClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := m.ID step := sqlgraph.NewStep( @@ -287,6 +374,26 @@ func (c *MatchClient) Hooks() []Hook { return c.hooks.Match } +// Interceptors returns the client interceptors. +func (c *MatchClient) Interceptors() []Interceptor { + return c.inters.Match +} + +func (c *MatchClient) mutate(ctx context.Context, m *MatchMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&MatchCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&MatchUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&MatchUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&MatchDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Match mutation op: %q", m.Op()) + } +} + // MatchPlayerClient is a client for the MatchPlayer schema. type MatchPlayerClient struct { config @@ -303,6 +410,12 @@ func (c *MatchPlayerClient) Use(hooks ...Hook) { c.hooks.MatchPlayer = append(c.hooks.MatchPlayer, hooks...) } +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `matchplayer.Intercept(f(g(h())))`. +func (c *MatchPlayerClient) Intercept(interceptors ...Interceptor) { + c.inters.MatchPlayer = append(c.inters.MatchPlayer, interceptors...) +} + // Create returns a builder for creating a MatchPlayer entity. func (c *MatchPlayerClient) Create() *MatchPlayerCreate { mutation := newMatchPlayerMutation(c.config, OpCreate) @@ -355,6 +468,8 @@ func (c *MatchPlayerClient) DeleteOneID(id int) *MatchPlayerDeleteOne { func (c *MatchPlayerClient) Query() *MatchPlayerQuery { return &MatchPlayerQuery{ config: c.config, + ctx: &QueryContext{Type: TypeMatchPlayer}, + inters: c.Interceptors(), } } @@ -374,7 +489,7 @@ 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 { - query := &MatchQuery{config: c.config} + query := (&MatchClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := mp.ID step := sqlgraph.NewStep( @@ -390,7 +505,7 @@ func (c *MatchPlayerClient) QueryMatches(mp *MatchPlayer) *MatchQuery { // QueryPlayers queries the players edge of a MatchPlayer. func (c *MatchPlayerClient) QueryPlayers(mp *MatchPlayer) *PlayerQuery { - query := &PlayerQuery{config: c.config} + query := (&PlayerClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := mp.ID step := sqlgraph.NewStep( @@ -406,7 +521,7 @@ func (c *MatchPlayerClient) QueryPlayers(mp *MatchPlayer) *PlayerQuery { // QueryWeaponStats queries the weapon_stats edge of a MatchPlayer. func (c *MatchPlayerClient) QueryWeaponStats(mp *MatchPlayer) *WeaponQuery { - query := &WeaponQuery{config: c.config} + query := (&WeaponClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := mp.ID step := sqlgraph.NewStep( @@ -422,7 +537,7 @@ func (c *MatchPlayerClient) QueryWeaponStats(mp *MatchPlayer) *WeaponQuery { // QueryRoundStats queries the round_stats edge of a MatchPlayer. func (c *MatchPlayerClient) QueryRoundStats(mp *MatchPlayer) *RoundStatsQuery { - query := &RoundStatsQuery{config: c.config} + query := (&RoundStatsClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := mp.ID step := sqlgraph.NewStep( @@ -438,7 +553,7 @@ func (c *MatchPlayerClient) QueryRoundStats(mp *MatchPlayer) *RoundStatsQuery { // QuerySpray queries the spray edge of a MatchPlayer. func (c *MatchPlayerClient) QuerySpray(mp *MatchPlayer) *SprayQuery { - query := &SprayQuery{config: c.config} + query := (&SprayClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := mp.ID step := sqlgraph.NewStep( @@ -454,7 +569,7 @@ func (c *MatchPlayerClient) QuerySpray(mp *MatchPlayer) *SprayQuery { // QueryMessages queries the messages edge of a MatchPlayer. func (c *MatchPlayerClient) QueryMessages(mp *MatchPlayer) *MessagesQuery { - query := &MessagesQuery{config: c.config} + query := (&MessagesClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := mp.ID step := sqlgraph.NewStep( @@ -473,6 +588,26 @@ func (c *MatchPlayerClient) Hooks() []Hook { return c.hooks.MatchPlayer } +// Interceptors returns the client interceptors. +func (c *MatchPlayerClient) Interceptors() []Interceptor { + return c.inters.MatchPlayer +} + +func (c *MatchPlayerClient) mutate(ctx context.Context, m *MatchPlayerMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&MatchPlayerCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&MatchPlayerUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&MatchPlayerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&MatchPlayerDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown MatchPlayer mutation op: %q", m.Op()) + } +} + // MessagesClient is a client for the Messages schema. type MessagesClient struct { config @@ -489,6 +624,12 @@ func (c *MessagesClient) Use(hooks ...Hook) { c.hooks.Messages = append(c.hooks.Messages, hooks...) } +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `messages.Intercept(f(g(h())))`. +func (c *MessagesClient) Intercept(interceptors ...Interceptor) { + c.inters.Messages = append(c.inters.Messages, interceptors...) +} + // Create returns a builder for creating a Messages entity. func (c *MessagesClient) Create() *MessagesCreate { mutation := newMessagesMutation(c.config, OpCreate) @@ -541,6 +682,8 @@ func (c *MessagesClient) DeleteOneID(id int) *MessagesDeleteOne { func (c *MessagesClient) Query() *MessagesQuery { return &MessagesQuery{ config: c.config, + ctx: &QueryContext{Type: TypeMessages}, + inters: c.Interceptors(), } } @@ -560,7 +703,7 @@ 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 { - query := &MatchPlayerQuery{config: c.config} + query := (&MatchPlayerClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := m.ID step := sqlgraph.NewStep( @@ -579,6 +722,26 @@ func (c *MessagesClient) Hooks() []Hook { return c.hooks.Messages } +// Interceptors returns the client interceptors. +func (c *MessagesClient) Interceptors() []Interceptor { + return c.inters.Messages +} + +func (c *MessagesClient) mutate(ctx context.Context, m *MessagesMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&MessagesCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&MessagesUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&MessagesUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&MessagesDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Messages mutation op: %q", m.Op()) + } +} + // PlayerClient is a client for the Player schema. type PlayerClient struct { config @@ -595,6 +758,12 @@ func (c *PlayerClient) Use(hooks ...Hook) { c.hooks.Player = append(c.hooks.Player, hooks...) } +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `player.Intercept(f(g(h())))`. +func (c *PlayerClient) Intercept(interceptors ...Interceptor) { + c.inters.Player = append(c.inters.Player, interceptors...) +} + // Create returns a builder for creating a Player entity. func (c *PlayerClient) Create() *PlayerCreate { mutation := newPlayerMutation(c.config, OpCreate) @@ -647,6 +816,8 @@ func (c *PlayerClient) DeleteOneID(id uint64) *PlayerDeleteOne { func (c *PlayerClient) Query() *PlayerQuery { return &PlayerQuery{ config: c.config, + ctx: &QueryContext{Type: TypePlayer}, + inters: c.Interceptors(), } } @@ -666,7 +837,7 @@ 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 { - query := &MatchPlayerQuery{config: c.config} + query := (&MatchPlayerClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := pl.ID step := sqlgraph.NewStep( @@ -682,7 +853,7 @@ func (c *PlayerClient) QueryStats(pl *Player) *MatchPlayerQuery { // QueryMatches queries the matches edge of a Player. func (c *PlayerClient) QueryMatches(pl *Player) *MatchQuery { - query := &MatchQuery{config: c.config} + query := (&MatchClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := pl.ID step := sqlgraph.NewStep( @@ -701,6 +872,26 @@ func (c *PlayerClient) Hooks() []Hook { return c.hooks.Player } +// Interceptors returns the client interceptors. +func (c *PlayerClient) Interceptors() []Interceptor { + return c.inters.Player +} + +func (c *PlayerClient) mutate(ctx context.Context, m *PlayerMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&PlayerCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&PlayerUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&PlayerUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&PlayerDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Player mutation op: %q", m.Op()) + } +} + // RoundStatsClient is a client for the RoundStats schema. type RoundStatsClient struct { config @@ -717,6 +908,12 @@ func (c *RoundStatsClient) Use(hooks ...Hook) { c.hooks.RoundStats = append(c.hooks.RoundStats, hooks...) } +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `roundstats.Intercept(f(g(h())))`. +func (c *RoundStatsClient) Intercept(interceptors ...Interceptor) { + c.inters.RoundStats = append(c.inters.RoundStats, interceptors...) +} + // Create returns a builder for creating a RoundStats entity. func (c *RoundStatsClient) Create() *RoundStatsCreate { mutation := newRoundStatsMutation(c.config, OpCreate) @@ -769,6 +966,8 @@ func (c *RoundStatsClient) DeleteOneID(id int) *RoundStatsDeleteOne { func (c *RoundStatsClient) Query() *RoundStatsQuery { return &RoundStatsQuery{ config: c.config, + ctx: &QueryContext{Type: TypeRoundStats}, + inters: c.Interceptors(), } } @@ -788,7 +987,7 @@ 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 { - query := &MatchPlayerQuery{config: c.config} + query := (&MatchPlayerClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := rs.ID step := sqlgraph.NewStep( @@ -807,6 +1006,26 @@ func (c *RoundStatsClient) Hooks() []Hook { return c.hooks.RoundStats } +// Interceptors returns the client interceptors. +func (c *RoundStatsClient) Interceptors() []Interceptor { + return c.inters.RoundStats +} + +func (c *RoundStatsClient) mutate(ctx context.Context, m *RoundStatsMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&RoundStatsCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&RoundStatsUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&RoundStatsUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&RoundStatsDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown RoundStats mutation op: %q", m.Op()) + } +} + // SprayClient is a client for the Spray schema. type SprayClient struct { config @@ -823,6 +1042,12 @@ func (c *SprayClient) Use(hooks ...Hook) { c.hooks.Spray = append(c.hooks.Spray, hooks...) } +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `spray.Intercept(f(g(h())))`. +func (c *SprayClient) Intercept(interceptors ...Interceptor) { + c.inters.Spray = append(c.inters.Spray, interceptors...) +} + // Create returns a builder for creating a Spray entity. func (c *SprayClient) Create() *SprayCreate { mutation := newSprayMutation(c.config, OpCreate) @@ -875,6 +1100,8 @@ func (c *SprayClient) DeleteOneID(id int) *SprayDeleteOne { func (c *SprayClient) Query() *SprayQuery { return &SprayQuery{ config: c.config, + ctx: &QueryContext{Type: TypeSpray}, + inters: c.Interceptors(), } } @@ -894,7 +1121,7 @@ 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 { - query := &MatchPlayerQuery{config: c.config} + query := (&MatchPlayerClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := s.ID step := sqlgraph.NewStep( @@ -913,6 +1140,26 @@ func (c *SprayClient) Hooks() []Hook { return c.hooks.Spray } +// Interceptors returns the client interceptors. +func (c *SprayClient) Interceptors() []Interceptor { + return c.inters.Spray +} + +func (c *SprayClient) mutate(ctx context.Context, m *SprayMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&SprayCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&SprayUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&SprayUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&SprayDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Spray mutation op: %q", m.Op()) + } +} + // WeaponClient is a client for the Weapon schema. type WeaponClient struct { config @@ -929,6 +1176,12 @@ func (c *WeaponClient) Use(hooks ...Hook) { c.hooks.Weapon = append(c.hooks.Weapon, hooks...) } +// Intercept adds a list of query interceptors to the interceptors stack. +// A call to `Intercept(f, g, h)` equals to `weapon.Intercept(f(g(h())))`. +func (c *WeaponClient) Intercept(interceptors ...Interceptor) { + c.inters.Weapon = append(c.inters.Weapon, interceptors...) +} + // Create returns a builder for creating a Weapon entity. func (c *WeaponClient) Create() *WeaponCreate { mutation := newWeaponMutation(c.config, OpCreate) @@ -981,6 +1234,8 @@ func (c *WeaponClient) DeleteOneID(id int) *WeaponDeleteOne { func (c *WeaponClient) Query() *WeaponQuery { return &WeaponQuery{ config: c.config, + ctx: &QueryContext{Type: TypeWeapon}, + inters: c.Interceptors(), } } @@ -1000,7 +1255,7 @@ 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 { - query := &MatchPlayerQuery{config: c.config} + query := (&MatchPlayerClient{config: c.config}).Query() query.path = func(context.Context) (fromV *sql.Selector, _ error) { id := w.ID step := sqlgraph.NewStep( @@ -1018,3 +1273,34 @@ func (c *WeaponClient) QueryStat(w *Weapon) *MatchPlayerQuery { func (c *WeaponClient) Hooks() []Hook { return c.hooks.Weapon } + +// Interceptors returns the client interceptors. +func (c *WeaponClient) Interceptors() []Interceptor { + return c.inters.Weapon +} + +func (c *WeaponClient) mutate(ctx context.Context, m *WeaponMutation) (Value, error) { + switch m.Op() { + case OpCreate: + return (&WeaponCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdate: + return (&WeaponUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpUpdateOne: + return (&WeaponUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx) + case OpDelete, OpDeleteOne: + return (&WeaponDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx) + default: + return nil, fmt.Errorf("ent: unknown Weapon mutation op: %q", m.Op()) + } +} + +// hooks and interceptors per client, for fast access. +type ( + hooks struct { + Match, MatchPlayer, Messages, Player, RoundStats, Spray, Weapon []ent.Hook + } + inters struct { + Match, MatchPlayer, Messages, Player, RoundStats, Spray, + Weapon []ent.Interceptor + } +) diff --git a/ent/config.go b/ent/config.go deleted file mode 100644 index 4de64c7..0000000 --- a/ent/config.go +++ /dev/null @@ -1,65 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "entgo.io/ent" - "entgo.io/ent/dialect" -) - -// Option function to configure the client. -type Option func(*config) - -// Config is the configuration for the client and its builder. -type config struct { - // driver used for executing database requests. - driver dialect.Driver - // debug enable a debug logging. - debug bool - // log used for logging on debug mode. - log func(...any) - // hooks to execute on mutations. - hooks *hooks -} - -// hooks per client, for fast access. -type hooks struct { - Match []ent.Hook - MatchPlayer []ent.Hook - Messages []ent.Hook - Player []ent.Hook - RoundStats []ent.Hook - Spray []ent.Hook - Weapon []ent.Hook -} - -// Options applies the options on the config object. -func (c *config) options(opts ...Option) { - for _, opt := range opts { - opt(c) - } - if c.debug { - c.driver = dialect.Debug(c.driver, c.log) - } -} - -// Debug enables debug logging on the ent.Driver. -func Debug() Option { - return func(c *config) { - c.debug = true - } -} - -// Log sets the logging function for debug mode. -func Log(fn func(...any)) Option { - return func(c *config) { - c.log = fn - } -} - -// Driver configures the client driver. -func Driver(driver dialect.Driver) Option { - return func(c *config) { - c.driver = driver - } -} diff --git a/ent/context.go b/ent/context.go deleted file mode 100644 index 7811bfa..0000000 --- a/ent/context.go +++ /dev/null @@ -1,33 +0,0 @@ -// Code generated by ent, DO NOT EDIT. - -package ent - -import ( - "context" -) - -type clientCtxKey struct{} - -// FromContext returns a Client stored inside a context, or nil if there isn't one. -func FromContext(ctx context.Context) *Client { - c, _ := ctx.Value(clientCtxKey{}).(*Client) - return c -} - -// NewContext returns a new context with the given Client attached. -func NewContext(parent context.Context, c *Client) context.Context { - return context.WithValue(parent, clientCtxKey{}, c) -} - -type txCtxKey struct{} - -// TxFromContext returns a Tx stored inside a context, or nil if there isn't one. -func TxFromContext(ctx context.Context) *Tx { - tx, _ := ctx.Value(txCtxKey{}).(*Tx) - return tx -} - -// NewTxContext returns a new context with the given Tx attached. -func NewTxContext(parent context.Context, tx *Tx) context.Context { - return context.WithValue(parent, txCtxKey{}, tx) -} diff --git a/ent/ent.go b/ent/ent.go index a4f9d54..b0914bb 100644 --- a/ent/ent.go +++ b/ent/ent.go @@ -6,6 +6,7 @@ import ( "context" "errors" "fmt" + "reflect" "entgo.io/ent" "entgo.io/ent/dialect/sql" @@ -21,16 +22,49 @@ import ( // ent aliases to avoid import conflicts in user's code. type ( - Op = ent.Op - Hook = ent.Hook - Value = ent.Value - Query = ent.Query - Policy = ent.Policy - Mutator = ent.Mutator - Mutation = ent.Mutation - MutateFunc = ent.MutateFunc + Op = ent.Op + Hook = ent.Hook + Value = ent.Value + Query = ent.Query + QueryContext = ent.QueryContext + Querier = ent.Querier + QuerierFunc = ent.QuerierFunc + Interceptor = ent.Interceptor + InterceptFunc = ent.InterceptFunc + Traverser = ent.Traverser + TraverseFunc = ent.TraverseFunc + Policy = ent.Policy + Mutator = ent.Mutator + Mutation = ent.Mutation + MutateFunc = ent.MutateFunc ) +type clientCtxKey struct{} + +// FromContext returns a Client stored inside a context, or nil if there isn't one. +func FromContext(ctx context.Context) *Client { + c, _ := ctx.Value(clientCtxKey{}).(*Client) + return c +} + +// NewContext returns a new context with the given Client attached. +func NewContext(parent context.Context, c *Client) context.Context { + return context.WithValue(parent, clientCtxKey{}, c) +} + +type txCtxKey struct{} + +// TxFromContext returns a Tx stored inside a context, or nil if there isn't one. +func TxFromContext(ctx context.Context) *Tx { + tx, _ := ctx.Value(txCtxKey{}).(*Tx) + return tx +} + +// NewTxContext returns a new context with the given Tx attached. +func NewTxContext(parent context.Context, tx *Tx) context.Context { + return context.WithValue(parent, txCtxKey{}, tx) +} + // OrderFunc applies an ordering on the sql selector. type OrderFunc func(*sql.Selector) @@ -474,5 +508,121 @@ func (s *selector) BoolX(ctx context.Context) bool { return v } +// withHooks invokes the builder operation with the given hooks, if any. +func withHooks[V Value, M any, PM interface { + *M + Mutation +}](ctx context.Context, exec func(context.Context) (V, error), mutation PM, hooks []Hook) (value V, err error) { + if len(hooks) == 0 { + return exec(ctx) + } + var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { + mutationT, ok := m.(PM) + if !ok { + return nil, fmt.Errorf("unexpected mutation type %T", m) + } + // Set the mutation to the builder. + *mutation = *mutationT + return exec(ctx) + }) + for i := len(hooks) - 1; i >= 0; i-- { + if hooks[i] == nil { + return value, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") + } + mut = hooks[i](mut) + } + v, err := mut.Mutate(ctx, mutation) + if err != nil { + return value, err + } + nv, ok := v.(V) + if !ok { + return value, fmt.Errorf("unexpected node type %T returned from %T", v, mutation) + } + return nv, nil +} + +// setContextOp returns a new context with the given QueryContext attached (including its op) in case it does not exist. +func setContextOp(ctx context.Context, qc *QueryContext, op string) context.Context { + if ent.QueryFromContext(ctx) == nil { + qc.Op = op + ctx = ent.NewQueryContext(ctx, qc) + } + return ctx +} + +func querierAll[V Value, Q interface { + sqlAll(context.Context, ...queryHook) (V, error) +}]() Querier { + return QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + return query.sqlAll(ctx) + }) +} + +func querierCount[Q interface { + sqlCount(context.Context) (int, error) +}]() Querier { + return QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + return query.sqlCount(ctx) + }) +} + +func withInterceptors[V Value](ctx context.Context, q Query, qr Querier, inters []Interceptor) (v V, err error) { + for i := len(inters) - 1; i >= 0; i-- { + qr = inters[i].Intercept(qr) + } + rv, err := qr.Query(ctx, q) + if err != nil { + return v, err + } + vt, ok := rv.(V) + if !ok { + return v, fmt.Errorf("unexpected type %T returned from %T. expected type: %T", vt, q, v) + } + return vt, nil +} + +func scanWithInterceptors[Q1 ent.Query, Q2 interface { + sqlScan(context.Context, Q1, any) error +}](ctx context.Context, rootQuery Q1, selectOrGroup Q2, inters []Interceptor, v any) error { + rv := reflect.ValueOf(v) + var qr Querier = QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + query, ok := q.(Q1) + if !ok { + return nil, fmt.Errorf("unexpected query type %T", q) + } + if err := selectOrGroup.sqlScan(ctx, query, v); err != nil { + return nil, err + } + if k := rv.Kind(); k == reflect.Pointer && rv.Elem().CanInterface() { + return rv.Elem().Interface(), nil + } + return v, nil + }) + for i := len(inters) - 1; i >= 0; i-- { + qr = inters[i].Intercept(qr) + } + vv, err := qr.Query(ctx, rootQuery) + if err != nil { + return err + } + switch rv2 := reflect.ValueOf(vv); { + case rv.IsNil(), rv2.IsNil(), rv.Kind() != reflect.Pointer: + case rv.Type() == rv2.Type(): + rv.Elem().Set(rv2.Elem()) + case rv.Elem().Type() == rv2.Type(): + rv.Elem().Set(rv2) + } + return nil +} + // queryHook describes an internal hook for the different sqlAll methods. type queryHook func(context.Context, *sqlgraph.QuerySpec) diff --git a/ent/hook/hook.go b/ent/hook/hook.go index 859cdb5..874a0ce 100644 --- a/ent/hook/hook.go +++ b/ent/hook/hook.go @@ -15,11 +15,10 @@ type MatchFunc func(context.Context, *ent.MatchMutation) (ent.Value, error) // Mutate calls f(ctx, m). func (f MatchFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - mv, ok := m.(*ent.MatchMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MatchMutation", m) + if mv, ok := m.(*ent.MatchMutation); ok { + return f(ctx, mv) } - return f(ctx, mv) + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MatchMutation", m) } // The MatchPlayerFunc type is an adapter to allow the use of ordinary @@ -28,11 +27,10 @@ type MatchPlayerFunc func(context.Context, *ent.MatchPlayerMutation) (ent.Value, // Mutate calls f(ctx, m). func (f MatchPlayerFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - mv, ok := m.(*ent.MatchPlayerMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MatchPlayerMutation", m) + if mv, ok := m.(*ent.MatchPlayerMutation); ok { + return f(ctx, mv) } - return f(ctx, mv) + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MatchPlayerMutation", m) } // The MessagesFunc type is an adapter to allow the use of ordinary @@ -41,11 +39,10 @@ type MessagesFunc func(context.Context, *ent.MessagesMutation) (ent.Value, error // Mutate calls f(ctx, m). func (f MessagesFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - mv, ok := m.(*ent.MessagesMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MessagesMutation", m) + if mv, ok := m.(*ent.MessagesMutation); ok { + return f(ctx, mv) } - return f(ctx, mv) + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.MessagesMutation", m) } // The PlayerFunc type is an adapter to allow the use of ordinary @@ -54,11 +51,10 @@ type PlayerFunc func(context.Context, *ent.PlayerMutation) (ent.Value, error) // Mutate calls f(ctx, m). func (f PlayerFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - mv, ok := m.(*ent.PlayerMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.PlayerMutation", m) + if mv, ok := m.(*ent.PlayerMutation); ok { + return f(ctx, mv) } - return f(ctx, mv) + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.PlayerMutation", m) } // The RoundStatsFunc type is an adapter to allow the use of ordinary @@ -67,11 +63,10 @@ type RoundStatsFunc func(context.Context, *ent.RoundStatsMutation) (ent.Value, e // Mutate calls f(ctx, m). func (f RoundStatsFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - mv, ok := m.(*ent.RoundStatsMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.RoundStatsMutation", m) + if mv, ok := m.(*ent.RoundStatsMutation); ok { + return f(ctx, mv) } - return f(ctx, mv) + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.RoundStatsMutation", m) } // The SprayFunc type is an adapter to allow the use of ordinary @@ -80,11 +75,10 @@ type SprayFunc func(context.Context, *ent.SprayMutation) (ent.Value, error) // Mutate calls f(ctx, m). func (f SprayFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - mv, ok := m.(*ent.SprayMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SprayMutation", m) + if mv, ok := m.(*ent.SprayMutation); ok { + return f(ctx, mv) } - return f(ctx, mv) + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.SprayMutation", m) } // The WeaponFunc type is an adapter to allow the use of ordinary @@ -93,11 +87,10 @@ type WeaponFunc func(context.Context, *ent.WeaponMutation) (ent.Value, error) // Mutate calls f(ctx, m). func (f WeaponFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) { - mv, ok := m.(*ent.WeaponMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.WeaponMutation", m) + if mv, ok := m.(*ent.WeaponMutation); ok { + return f(ctx, mv) } - return f(ctx, mv) + return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.WeaponMutation", m) } // Condition is a hook condition function. diff --git a/ent/match.go b/ent/match.go index e7c3f3a..2701aad 100644 --- a/ent/match.go +++ b/ent/match.go @@ -207,19 +207,19 @@ func (m *Match) assignValues(columns []string, values []any) error { // QueryStats queries the "stats" edge of the Match entity. func (m *Match) QueryStats() *MatchPlayerQuery { - return (&MatchClient{config: m.config}).QueryStats(m) + return NewMatchClient(m.config).QueryStats(m) } // QueryPlayers queries the "players" edge of the Match entity. func (m *Match) QueryPlayers() *PlayerQuery { - return (&MatchClient{config: m.config}).QueryPlayers(m) + 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 (&MatchClient{config: m.config}).UpdateOne(m) + return NewMatchClient(m.config).UpdateOne(m) } // Unwrap unwraps the Match entity that was returned from a transaction after it was closed, @@ -285,9 +285,3 @@ func (m *Match) String() string { // Matches is a parsable slice of Match. type Matches []*Match - -func (m Matches) config(cfg config) { - for _i := range m { - m[_i].config = cfg - } -} diff --git a/ent/match/where.go b/ent/match/where.go index 6a1b1b5..bacd358 100644 --- a/ent/match/where.go +++ b/ent/match/where.go @@ -12,1078 +12,702 @@ import ( // ID filters vertices based on their ID field. func ID(id uint64) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) + return predicate.Match(sql.FieldEQ(FieldID, id)) } // IDEQ applies the EQ predicate on the ID field. func IDEQ(id uint64) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) + return predicate.Match(sql.FieldEQ(FieldID, id)) } // IDNEQ applies the NEQ predicate on the ID field. func IDNEQ(id uint64) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldID), id)) - }) + return predicate.Match(sql.FieldNEQ(FieldID, id)) } // IDIn applies the In predicate on the ID field. func IDIn(ids ...uint64) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - v := make([]any, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.In(s.C(FieldID), v...)) - }) + return predicate.Match(sql.FieldIn(FieldID, ids...)) } // IDNotIn applies the NotIn predicate on the ID field. func IDNotIn(ids ...uint64) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - v := make([]any, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.NotIn(s.C(FieldID), v...)) - }) + return predicate.Match(sql.FieldNotIn(FieldID, ids...)) } // IDGT applies the GT predicate on the ID field. func IDGT(id uint64) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldID), id)) - }) + return predicate.Match(sql.FieldGT(FieldID, id)) } // IDGTE applies the GTE predicate on the ID field. func IDGTE(id uint64) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldID), id)) - }) + return predicate.Match(sql.FieldGTE(FieldID, id)) } // IDLT applies the LT predicate on the ID field. func IDLT(id uint64) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldID), id)) - }) + return predicate.Match(sql.FieldLT(FieldID, id)) } // IDLTE applies the LTE predicate on the ID field. func IDLTE(id uint64) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldID), id)) - }) + return predicate.Match(sql.FieldLTE(FieldID, id)) } // ShareCode applies equality check predicate on the "share_code" field. It's identical to ShareCodeEQ. func ShareCode(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldShareCode), v)) - }) + return predicate.Match(sql.FieldEQ(FieldShareCode, v)) } // Map applies equality check predicate on the "map" field. It's identical to MapEQ. func Map(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldMap), v)) - }) + return predicate.Match(sql.FieldEQ(FieldMap, v)) } // Date applies equality check predicate on the "date" field. It's identical to DateEQ. func Date(v time.Time) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldDate), v)) - }) + return predicate.Match(sql.FieldEQ(FieldDate, v)) } // ScoreTeamA applies equality check predicate on the "score_team_a" field. It's identical to ScoreTeamAEQ. func ScoreTeamA(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldScoreTeamA), v)) - }) + return predicate.Match(sql.FieldEQ(FieldScoreTeamA, v)) } // ScoreTeamB applies equality check predicate on the "score_team_b" field. It's identical to ScoreTeamBEQ. func ScoreTeamB(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldScoreTeamB), v)) - }) + return predicate.Match(sql.FieldEQ(FieldScoreTeamB, v)) } // ReplayURL applies equality check predicate on the "replay_url" field. It's identical to ReplayURLEQ. func ReplayURL(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldReplayURL), v)) - }) + return predicate.Match(sql.FieldEQ(FieldReplayURL, v)) } // Duration applies equality check predicate on the "duration" field. It's identical to DurationEQ. func Duration(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldDuration), v)) - }) + return predicate.Match(sql.FieldEQ(FieldDuration, v)) } // MatchResult applies equality check predicate on the "match_result" field. It's identical to MatchResultEQ. func MatchResult(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldMatchResult), v)) - }) + return predicate.Match(sql.FieldEQ(FieldMatchResult, v)) } // MaxRounds applies equality check predicate on the "max_rounds" field. It's identical to MaxRoundsEQ. func MaxRounds(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldMaxRounds), v)) - }) + return predicate.Match(sql.FieldEQ(FieldMaxRounds, v)) } // DemoParsed applies equality check predicate on the "demo_parsed" field. It's identical to DemoParsedEQ. func DemoParsed(v bool) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldDemoParsed), v)) - }) + return predicate.Match(sql.FieldEQ(FieldDemoParsed, v)) } // VacPresent applies equality check predicate on the "vac_present" field. It's identical to VacPresentEQ. func VacPresent(v bool) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldVacPresent), v)) - }) + return predicate.Match(sql.FieldEQ(FieldVacPresent, v)) } // GamebanPresent applies equality check predicate on the "gameban_present" field. It's identical to GamebanPresentEQ. func GamebanPresent(v bool) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldGamebanPresent), v)) - }) + return predicate.Match(sql.FieldEQ(FieldGamebanPresent, v)) } // DecryptionKey applies equality check predicate on the "decryption_key" field. It's identical to DecryptionKeyEQ. func DecryptionKey(v []byte) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldDecryptionKey), v)) - }) + return predicate.Match(sql.FieldEQ(FieldDecryptionKey, v)) } // TickRate applies equality check predicate on the "tick_rate" field. It's identical to TickRateEQ. func TickRate(v float64) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldTickRate), v)) - }) + return predicate.Match(sql.FieldEQ(FieldTickRate, v)) } // ShareCodeEQ applies the EQ predicate on the "share_code" field. func ShareCodeEQ(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldShareCode), v)) - }) + return predicate.Match(sql.FieldEQ(FieldShareCode, v)) } // ShareCodeNEQ applies the NEQ predicate on the "share_code" field. func ShareCodeNEQ(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldShareCode), v)) - }) + return predicate.Match(sql.FieldNEQ(FieldShareCode, v)) } // ShareCodeIn applies the In predicate on the "share_code" field. func ShareCodeIn(vs ...string) predicate.Match { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldShareCode), v...)) - }) + return predicate.Match(sql.FieldIn(FieldShareCode, vs...)) } // ShareCodeNotIn applies the NotIn predicate on the "share_code" field. func ShareCodeNotIn(vs ...string) predicate.Match { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldShareCode), v...)) - }) + return predicate.Match(sql.FieldNotIn(FieldShareCode, vs...)) } // ShareCodeGT applies the GT predicate on the "share_code" field. func ShareCodeGT(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldShareCode), v)) - }) + return predicate.Match(sql.FieldGT(FieldShareCode, v)) } // ShareCodeGTE applies the GTE predicate on the "share_code" field. func ShareCodeGTE(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldShareCode), v)) - }) + return predicate.Match(sql.FieldGTE(FieldShareCode, v)) } // ShareCodeLT applies the LT predicate on the "share_code" field. func ShareCodeLT(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldShareCode), v)) - }) + return predicate.Match(sql.FieldLT(FieldShareCode, v)) } // ShareCodeLTE applies the LTE predicate on the "share_code" field. func ShareCodeLTE(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldShareCode), v)) - }) + return predicate.Match(sql.FieldLTE(FieldShareCode, v)) } // ShareCodeContains applies the Contains predicate on the "share_code" field. func ShareCodeContains(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldShareCode), v)) - }) + return predicate.Match(sql.FieldContains(FieldShareCode, v)) } // ShareCodeHasPrefix applies the HasPrefix predicate on the "share_code" field. func ShareCodeHasPrefix(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldShareCode), v)) - }) + return predicate.Match(sql.FieldHasPrefix(FieldShareCode, v)) } // ShareCodeHasSuffix applies the HasSuffix predicate on the "share_code" field. func ShareCodeHasSuffix(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldShareCode), v)) - }) + return predicate.Match(sql.FieldHasSuffix(FieldShareCode, v)) } // ShareCodeEqualFold applies the EqualFold predicate on the "share_code" field. func ShareCodeEqualFold(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldShareCode), v)) - }) + return predicate.Match(sql.FieldEqualFold(FieldShareCode, v)) } // ShareCodeContainsFold applies the ContainsFold predicate on the "share_code" field. func ShareCodeContainsFold(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldShareCode), v)) - }) + return predicate.Match(sql.FieldContainsFold(FieldShareCode, v)) } // MapEQ applies the EQ predicate on the "map" field. func MapEQ(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldMap), v)) - }) + return predicate.Match(sql.FieldEQ(FieldMap, v)) } // MapNEQ applies the NEQ predicate on the "map" field. func MapNEQ(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldMap), v)) - }) + return predicate.Match(sql.FieldNEQ(FieldMap, v)) } // MapIn applies the In predicate on the "map" field. func MapIn(vs ...string) predicate.Match { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldMap), v...)) - }) + return predicate.Match(sql.FieldIn(FieldMap, vs...)) } // MapNotIn applies the NotIn predicate on the "map" field. func MapNotIn(vs ...string) predicate.Match { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldMap), v...)) - }) + return predicate.Match(sql.FieldNotIn(FieldMap, vs...)) } // MapGT applies the GT predicate on the "map" field. func MapGT(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldMap), v)) - }) + return predicate.Match(sql.FieldGT(FieldMap, v)) } // MapGTE applies the GTE predicate on the "map" field. func MapGTE(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldMap), v)) - }) + return predicate.Match(sql.FieldGTE(FieldMap, v)) } // MapLT applies the LT predicate on the "map" field. func MapLT(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldMap), v)) - }) + return predicate.Match(sql.FieldLT(FieldMap, v)) } // MapLTE applies the LTE predicate on the "map" field. func MapLTE(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldMap), v)) - }) + return predicate.Match(sql.FieldLTE(FieldMap, v)) } // MapContains applies the Contains predicate on the "map" field. func MapContains(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldMap), v)) - }) + return predicate.Match(sql.FieldContains(FieldMap, v)) } // MapHasPrefix applies the HasPrefix predicate on the "map" field. func MapHasPrefix(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldMap), v)) - }) + return predicate.Match(sql.FieldHasPrefix(FieldMap, v)) } // MapHasSuffix applies the HasSuffix predicate on the "map" field. func MapHasSuffix(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldMap), v)) - }) + return predicate.Match(sql.FieldHasSuffix(FieldMap, v)) } // MapIsNil applies the IsNil predicate on the "map" field. func MapIsNil() predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldMap))) - }) + return predicate.Match(sql.FieldIsNull(FieldMap)) } // MapNotNil applies the NotNil predicate on the "map" field. func MapNotNil() predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldMap))) - }) + return predicate.Match(sql.FieldNotNull(FieldMap)) } // MapEqualFold applies the EqualFold predicate on the "map" field. func MapEqualFold(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldMap), v)) - }) + return predicate.Match(sql.FieldEqualFold(FieldMap, v)) } // MapContainsFold applies the ContainsFold predicate on the "map" field. func MapContainsFold(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldMap), v)) - }) + return predicate.Match(sql.FieldContainsFold(FieldMap, v)) } // DateEQ applies the EQ predicate on the "date" field. func DateEQ(v time.Time) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldDate), v)) - }) + return predicate.Match(sql.FieldEQ(FieldDate, v)) } // DateNEQ applies the NEQ predicate on the "date" field. func DateNEQ(v time.Time) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldDate), v)) - }) + return predicate.Match(sql.FieldNEQ(FieldDate, v)) } // DateIn applies the In predicate on the "date" field. func DateIn(vs ...time.Time) predicate.Match { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldDate), v...)) - }) + return predicate.Match(sql.FieldIn(FieldDate, vs...)) } // DateNotIn applies the NotIn predicate on the "date" field. func DateNotIn(vs ...time.Time) predicate.Match { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldDate), v...)) - }) + return predicate.Match(sql.FieldNotIn(FieldDate, vs...)) } // DateGT applies the GT predicate on the "date" field. func DateGT(v time.Time) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldDate), v)) - }) + return predicate.Match(sql.FieldGT(FieldDate, v)) } // DateGTE applies the GTE predicate on the "date" field. func DateGTE(v time.Time) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldDate), v)) - }) + return predicate.Match(sql.FieldGTE(FieldDate, v)) } // DateLT applies the LT predicate on the "date" field. func DateLT(v time.Time) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldDate), v)) - }) + return predicate.Match(sql.FieldLT(FieldDate, v)) } // DateLTE applies the LTE predicate on the "date" field. func DateLTE(v time.Time) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldDate), v)) - }) + return predicate.Match(sql.FieldLTE(FieldDate, v)) } // ScoreTeamAEQ applies the EQ predicate on the "score_team_a" field. func ScoreTeamAEQ(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldScoreTeamA), v)) - }) + return predicate.Match(sql.FieldEQ(FieldScoreTeamA, v)) } // ScoreTeamANEQ applies the NEQ predicate on the "score_team_a" field. func ScoreTeamANEQ(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldScoreTeamA), v)) - }) + return predicate.Match(sql.FieldNEQ(FieldScoreTeamA, v)) } // ScoreTeamAIn applies the In predicate on the "score_team_a" field. func ScoreTeamAIn(vs ...int) predicate.Match { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldScoreTeamA), v...)) - }) + return predicate.Match(sql.FieldIn(FieldScoreTeamA, vs...)) } // ScoreTeamANotIn applies the NotIn predicate on the "score_team_a" field. func ScoreTeamANotIn(vs ...int) predicate.Match { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldScoreTeamA), v...)) - }) + return predicate.Match(sql.FieldNotIn(FieldScoreTeamA, vs...)) } // ScoreTeamAGT applies the GT predicate on the "score_team_a" field. func ScoreTeamAGT(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldScoreTeamA), v)) - }) + return predicate.Match(sql.FieldGT(FieldScoreTeamA, v)) } // ScoreTeamAGTE applies the GTE predicate on the "score_team_a" field. func ScoreTeamAGTE(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldScoreTeamA), v)) - }) + return predicate.Match(sql.FieldGTE(FieldScoreTeamA, v)) } // ScoreTeamALT applies the LT predicate on the "score_team_a" field. func ScoreTeamALT(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldScoreTeamA), v)) - }) + return predicate.Match(sql.FieldLT(FieldScoreTeamA, v)) } // ScoreTeamALTE applies the LTE predicate on the "score_team_a" field. func ScoreTeamALTE(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldScoreTeamA), v)) - }) + return predicate.Match(sql.FieldLTE(FieldScoreTeamA, v)) } // ScoreTeamBEQ applies the EQ predicate on the "score_team_b" field. func ScoreTeamBEQ(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldScoreTeamB), v)) - }) + return predicate.Match(sql.FieldEQ(FieldScoreTeamB, v)) } // ScoreTeamBNEQ applies the NEQ predicate on the "score_team_b" field. func ScoreTeamBNEQ(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldScoreTeamB), v)) - }) + return predicate.Match(sql.FieldNEQ(FieldScoreTeamB, v)) } // ScoreTeamBIn applies the In predicate on the "score_team_b" field. func ScoreTeamBIn(vs ...int) predicate.Match { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldScoreTeamB), v...)) - }) + return predicate.Match(sql.FieldIn(FieldScoreTeamB, vs...)) } // ScoreTeamBNotIn applies the NotIn predicate on the "score_team_b" field. func ScoreTeamBNotIn(vs ...int) predicate.Match { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldScoreTeamB), v...)) - }) + return predicate.Match(sql.FieldNotIn(FieldScoreTeamB, vs...)) } // ScoreTeamBGT applies the GT predicate on the "score_team_b" field. func ScoreTeamBGT(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldScoreTeamB), v)) - }) + return predicate.Match(sql.FieldGT(FieldScoreTeamB, v)) } // ScoreTeamBGTE applies the GTE predicate on the "score_team_b" field. func ScoreTeamBGTE(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldScoreTeamB), v)) - }) + return predicate.Match(sql.FieldGTE(FieldScoreTeamB, v)) } // ScoreTeamBLT applies the LT predicate on the "score_team_b" field. func ScoreTeamBLT(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldScoreTeamB), v)) - }) + return predicate.Match(sql.FieldLT(FieldScoreTeamB, v)) } // ScoreTeamBLTE applies the LTE predicate on the "score_team_b" field. func ScoreTeamBLTE(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldScoreTeamB), v)) - }) + return predicate.Match(sql.FieldLTE(FieldScoreTeamB, v)) } // ReplayURLEQ applies the EQ predicate on the "replay_url" field. func ReplayURLEQ(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldReplayURL), v)) - }) + return predicate.Match(sql.FieldEQ(FieldReplayURL, v)) } // ReplayURLNEQ applies the NEQ predicate on the "replay_url" field. func ReplayURLNEQ(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldReplayURL), v)) - }) + return predicate.Match(sql.FieldNEQ(FieldReplayURL, v)) } // ReplayURLIn applies the In predicate on the "replay_url" field. func ReplayURLIn(vs ...string) predicate.Match { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldReplayURL), v...)) - }) + return predicate.Match(sql.FieldIn(FieldReplayURL, vs...)) } // ReplayURLNotIn applies the NotIn predicate on the "replay_url" field. func ReplayURLNotIn(vs ...string) predicate.Match { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldReplayURL), v...)) - }) + return predicate.Match(sql.FieldNotIn(FieldReplayURL, vs...)) } // ReplayURLGT applies the GT predicate on the "replay_url" field. func ReplayURLGT(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldReplayURL), v)) - }) + return predicate.Match(sql.FieldGT(FieldReplayURL, v)) } // ReplayURLGTE applies the GTE predicate on the "replay_url" field. func ReplayURLGTE(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldReplayURL), v)) - }) + return predicate.Match(sql.FieldGTE(FieldReplayURL, v)) } // ReplayURLLT applies the LT predicate on the "replay_url" field. func ReplayURLLT(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldReplayURL), v)) - }) + return predicate.Match(sql.FieldLT(FieldReplayURL, v)) } // ReplayURLLTE applies the LTE predicate on the "replay_url" field. func ReplayURLLTE(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldReplayURL), v)) - }) + return predicate.Match(sql.FieldLTE(FieldReplayURL, v)) } // ReplayURLContains applies the Contains predicate on the "replay_url" field. func ReplayURLContains(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldReplayURL), v)) - }) + return predicate.Match(sql.FieldContains(FieldReplayURL, v)) } // ReplayURLHasPrefix applies the HasPrefix predicate on the "replay_url" field. func ReplayURLHasPrefix(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldReplayURL), v)) - }) + return predicate.Match(sql.FieldHasPrefix(FieldReplayURL, v)) } // ReplayURLHasSuffix applies the HasSuffix predicate on the "replay_url" field. func ReplayURLHasSuffix(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldReplayURL), v)) - }) + return predicate.Match(sql.FieldHasSuffix(FieldReplayURL, v)) } // ReplayURLIsNil applies the IsNil predicate on the "replay_url" field. func ReplayURLIsNil() predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldReplayURL))) - }) + return predicate.Match(sql.FieldIsNull(FieldReplayURL)) } // ReplayURLNotNil applies the NotNil predicate on the "replay_url" field. func ReplayURLNotNil() predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldReplayURL))) - }) + return predicate.Match(sql.FieldNotNull(FieldReplayURL)) } // ReplayURLEqualFold applies the EqualFold predicate on the "replay_url" field. func ReplayURLEqualFold(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldReplayURL), v)) - }) + return predicate.Match(sql.FieldEqualFold(FieldReplayURL, v)) } // ReplayURLContainsFold applies the ContainsFold predicate on the "replay_url" field. func ReplayURLContainsFold(v string) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldReplayURL), v)) - }) + return predicate.Match(sql.FieldContainsFold(FieldReplayURL, v)) } // DurationEQ applies the EQ predicate on the "duration" field. func DurationEQ(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldDuration), v)) - }) + return predicate.Match(sql.FieldEQ(FieldDuration, v)) } // DurationNEQ applies the NEQ predicate on the "duration" field. func DurationNEQ(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldDuration), v)) - }) + return predicate.Match(sql.FieldNEQ(FieldDuration, v)) } // DurationIn applies the In predicate on the "duration" field. func DurationIn(vs ...int) predicate.Match { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldDuration), v...)) - }) + return predicate.Match(sql.FieldIn(FieldDuration, vs...)) } // DurationNotIn applies the NotIn predicate on the "duration" field. func DurationNotIn(vs ...int) predicate.Match { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldDuration), v...)) - }) + return predicate.Match(sql.FieldNotIn(FieldDuration, vs...)) } // DurationGT applies the GT predicate on the "duration" field. func DurationGT(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldDuration), v)) - }) + return predicate.Match(sql.FieldGT(FieldDuration, v)) } // DurationGTE applies the GTE predicate on the "duration" field. func DurationGTE(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldDuration), v)) - }) + return predicate.Match(sql.FieldGTE(FieldDuration, v)) } // DurationLT applies the LT predicate on the "duration" field. func DurationLT(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldDuration), v)) - }) + return predicate.Match(sql.FieldLT(FieldDuration, v)) } // DurationLTE applies the LTE predicate on the "duration" field. func DurationLTE(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldDuration), v)) - }) + return predicate.Match(sql.FieldLTE(FieldDuration, v)) } // MatchResultEQ applies the EQ predicate on the "match_result" field. func MatchResultEQ(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldMatchResult), v)) - }) + return predicate.Match(sql.FieldEQ(FieldMatchResult, v)) } // MatchResultNEQ applies the NEQ predicate on the "match_result" field. func MatchResultNEQ(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldMatchResult), v)) - }) + return predicate.Match(sql.FieldNEQ(FieldMatchResult, v)) } // MatchResultIn applies the In predicate on the "match_result" field. func MatchResultIn(vs ...int) predicate.Match { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldMatchResult), v...)) - }) + return predicate.Match(sql.FieldIn(FieldMatchResult, vs...)) } // MatchResultNotIn applies the NotIn predicate on the "match_result" field. func MatchResultNotIn(vs ...int) predicate.Match { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldMatchResult), v...)) - }) + return predicate.Match(sql.FieldNotIn(FieldMatchResult, vs...)) } // MatchResultGT applies the GT predicate on the "match_result" field. func MatchResultGT(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldMatchResult), v)) - }) + return predicate.Match(sql.FieldGT(FieldMatchResult, v)) } // MatchResultGTE applies the GTE predicate on the "match_result" field. func MatchResultGTE(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldMatchResult), v)) - }) + return predicate.Match(sql.FieldGTE(FieldMatchResult, v)) } // MatchResultLT applies the LT predicate on the "match_result" field. func MatchResultLT(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldMatchResult), v)) - }) + return predicate.Match(sql.FieldLT(FieldMatchResult, v)) } // MatchResultLTE applies the LTE predicate on the "match_result" field. func MatchResultLTE(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldMatchResult), v)) - }) + return predicate.Match(sql.FieldLTE(FieldMatchResult, v)) } // MaxRoundsEQ applies the EQ predicate on the "max_rounds" field. func MaxRoundsEQ(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldMaxRounds), v)) - }) + return predicate.Match(sql.FieldEQ(FieldMaxRounds, v)) } // MaxRoundsNEQ applies the NEQ predicate on the "max_rounds" field. func MaxRoundsNEQ(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldMaxRounds), v)) - }) + return predicate.Match(sql.FieldNEQ(FieldMaxRounds, v)) } // MaxRoundsIn applies the In predicate on the "max_rounds" field. func MaxRoundsIn(vs ...int) predicate.Match { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldMaxRounds), v...)) - }) + return predicate.Match(sql.FieldIn(FieldMaxRounds, vs...)) } // MaxRoundsNotIn applies the NotIn predicate on the "max_rounds" field. func MaxRoundsNotIn(vs ...int) predicate.Match { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldMaxRounds), v...)) - }) + return predicate.Match(sql.FieldNotIn(FieldMaxRounds, vs...)) } // MaxRoundsGT applies the GT predicate on the "max_rounds" field. func MaxRoundsGT(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldMaxRounds), v)) - }) + return predicate.Match(sql.FieldGT(FieldMaxRounds, v)) } // MaxRoundsGTE applies the GTE predicate on the "max_rounds" field. func MaxRoundsGTE(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldMaxRounds), v)) - }) + return predicate.Match(sql.FieldGTE(FieldMaxRounds, v)) } // MaxRoundsLT applies the LT predicate on the "max_rounds" field. func MaxRoundsLT(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldMaxRounds), v)) - }) + return predicate.Match(sql.FieldLT(FieldMaxRounds, v)) } // MaxRoundsLTE applies the LTE predicate on the "max_rounds" field. func MaxRoundsLTE(v int) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldMaxRounds), v)) - }) + return predicate.Match(sql.FieldLTE(FieldMaxRounds, v)) } // DemoParsedEQ applies the EQ predicate on the "demo_parsed" field. func DemoParsedEQ(v bool) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldDemoParsed), v)) - }) + return predicate.Match(sql.FieldEQ(FieldDemoParsed, v)) } // DemoParsedNEQ applies the NEQ predicate on the "demo_parsed" field. func DemoParsedNEQ(v bool) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldDemoParsed), v)) - }) + return predicate.Match(sql.FieldNEQ(FieldDemoParsed, v)) } // VacPresentEQ applies the EQ predicate on the "vac_present" field. func VacPresentEQ(v bool) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldVacPresent), v)) - }) + return predicate.Match(sql.FieldEQ(FieldVacPresent, v)) } // VacPresentNEQ applies the NEQ predicate on the "vac_present" field. func VacPresentNEQ(v bool) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldVacPresent), v)) - }) + return predicate.Match(sql.FieldNEQ(FieldVacPresent, v)) } // GamebanPresentEQ applies the EQ predicate on the "gameban_present" field. func GamebanPresentEQ(v bool) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldGamebanPresent), v)) - }) + return predicate.Match(sql.FieldEQ(FieldGamebanPresent, v)) } // GamebanPresentNEQ applies the NEQ predicate on the "gameban_present" field. func GamebanPresentNEQ(v bool) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldGamebanPresent), v)) - }) + return predicate.Match(sql.FieldNEQ(FieldGamebanPresent, v)) } // DecryptionKeyEQ applies the EQ predicate on the "decryption_key" field. func DecryptionKeyEQ(v []byte) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldDecryptionKey), v)) - }) + return predicate.Match(sql.FieldEQ(FieldDecryptionKey, v)) } // DecryptionKeyNEQ applies the NEQ predicate on the "decryption_key" field. func DecryptionKeyNEQ(v []byte) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldDecryptionKey), v)) - }) + return predicate.Match(sql.FieldNEQ(FieldDecryptionKey, v)) } // DecryptionKeyIn applies the In predicate on the "decryption_key" field. func DecryptionKeyIn(vs ...[]byte) predicate.Match { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldDecryptionKey), v...)) - }) + return predicate.Match(sql.FieldIn(FieldDecryptionKey, vs...)) } // DecryptionKeyNotIn applies the NotIn predicate on the "decryption_key" field. func DecryptionKeyNotIn(vs ...[]byte) predicate.Match { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldDecryptionKey), v...)) - }) + return predicate.Match(sql.FieldNotIn(FieldDecryptionKey, vs...)) } // DecryptionKeyGT applies the GT predicate on the "decryption_key" field. func DecryptionKeyGT(v []byte) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldDecryptionKey), v)) - }) + return predicate.Match(sql.FieldGT(FieldDecryptionKey, v)) } // DecryptionKeyGTE applies the GTE predicate on the "decryption_key" field. func DecryptionKeyGTE(v []byte) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldDecryptionKey), v)) - }) + return predicate.Match(sql.FieldGTE(FieldDecryptionKey, v)) } // DecryptionKeyLT applies the LT predicate on the "decryption_key" field. func DecryptionKeyLT(v []byte) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldDecryptionKey), v)) - }) + return predicate.Match(sql.FieldLT(FieldDecryptionKey, v)) } // DecryptionKeyLTE applies the LTE predicate on the "decryption_key" field. func DecryptionKeyLTE(v []byte) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldDecryptionKey), v)) - }) + return predicate.Match(sql.FieldLTE(FieldDecryptionKey, v)) } // DecryptionKeyIsNil applies the IsNil predicate on the "decryption_key" field. func DecryptionKeyIsNil() predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldDecryptionKey))) - }) + return predicate.Match(sql.FieldIsNull(FieldDecryptionKey)) } // DecryptionKeyNotNil applies the NotNil predicate on the "decryption_key" field. func DecryptionKeyNotNil() predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldDecryptionKey))) - }) + return predicate.Match(sql.FieldNotNull(FieldDecryptionKey)) } // TickRateEQ applies the EQ predicate on the "tick_rate" field. func TickRateEQ(v float64) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldTickRate), v)) - }) + return predicate.Match(sql.FieldEQ(FieldTickRate, v)) } // TickRateNEQ applies the NEQ predicate on the "tick_rate" field. func TickRateNEQ(v float64) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldTickRate), v)) - }) + return predicate.Match(sql.FieldNEQ(FieldTickRate, v)) } // TickRateIn applies the In predicate on the "tick_rate" field. func TickRateIn(vs ...float64) predicate.Match { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldTickRate), v...)) - }) + return predicate.Match(sql.FieldIn(FieldTickRate, vs...)) } // TickRateNotIn applies the NotIn predicate on the "tick_rate" field. func TickRateNotIn(vs ...float64) predicate.Match { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldTickRate), v...)) - }) + return predicate.Match(sql.FieldNotIn(FieldTickRate, vs...)) } // TickRateGT applies the GT predicate on the "tick_rate" field. func TickRateGT(v float64) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldTickRate), v)) - }) + return predicate.Match(sql.FieldGT(FieldTickRate, v)) } // TickRateGTE applies the GTE predicate on the "tick_rate" field. func TickRateGTE(v float64) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldTickRate), v)) - }) + return predicate.Match(sql.FieldGTE(FieldTickRate, v)) } // TickRateLT applies the LT predicate on the "tick_rate" field. func TickRateLT(v float64) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldTickRate), v)) - }) + return predicate.Match(sql.FieldLT(FieldTickRate, v)) } // TickRateLTE applies the LTE predicate on the "tick_rate" field. func TickRateLTE(v float64) predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldTickRate), v)) - }) + return predicate.Match(sql.FieldLTE(FieldTickRate, v)) } // TickRateIsNil applies the IsNil predicate on the "tick_rate" field. func TickRateIsNil() predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldTickRate))) - }) + return predicate.Match(sql.FieldIsNull(FieldTickRate)) } // TickRateNotNil applies the NotNil predicate on the "tick_rate" field. func TickRateNotNil() predicate.Match { - return predicate.Match(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldTickRate))) - }) + return predicate.Match(sql.FieldNotNull(FieldTickRate)) } // HasStats applies the HasEdge predicate on the "stats" edge. @@ -1091,7 +715,6 @@ func HasStats() predicate.Match { return predicate.Match(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(StatsTable, FieldID), sqlgraph.Edge(sqlgraph.O2M, false, StatsTable, StatsColumn), ) sqlgraph.HasNeighbors(s, step) @@ -1119,7 +742,6 @@ func HasPlayers() predicate.Match { return predicate.Match(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(PlayersTable, FieldID), sqlgraph.Edge(sqlgraph.M2M, true, PlayersTable, PlayersPrimaryKey...), ) sqlgraph.HasNeighbors(s, step) diff --git a/ent/match_create.go b/ent/match_create.go index 3b7ff98..0a07c60 100644 --- a/ent/match_create.go +++ b/ent/match_create.go @@ -197,50 +197,8 @@ func (mc *MatchCreate) Mutation() *MatchMutation { // Save creates the Match in the database. func (mc *MatchCreate) Save(ctx context.Context) (*Match, error) { - var ( - err error - node *Match - ) mc.defaults() - if len(mc.hooks) == 0 { - if err = mc.check(); err != nil { - return nil, err - } - node, err = mc.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*MatchMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err = mc.check(); err != nil { - return nil, err - } - mc.mutation = mutation - if node, err = mc.sqlSave(ctx); err != nil { - return nil, err - } - mutation.id = &node.ID - mutation.done = true - return node, err - }) - for i := len(mc.hooks) - 1; i >= 0; i-- { - if mc.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = mc.hooks[i](mut) - } - v, err := mut.Mutate(ctx, mc.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*Match) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from MatchMutation", v) - } - node = nv - } - return node, err + return withHooks[*Match, MatchMutation](ctx, mc.sqlSave, mc.mutation, mc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -317,6 +275,9 @@ func (mc *MatchCreate) check() error { } func (mc *MatchCreate) sqlSave(ctx context.Context) (*Match, error) { + if err := mc.check(); err != nil { + return nil, err + } _node, _spec := mc.createSpec() if err := sqlgraph.CreateNode(ctx, mc.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { @@ -328,19 +289,15 @@ 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 return _node, nil } func (mc *MatchCreate) createSpec() (*Match, *sqlgraph.CreateSpec) { var ( _node = &Match{config: mc.config} - _spec = &sqlgraph.CreateSpec{ - Table: match.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeUint64, - Column: match.FieldID, - }, - } + _spec = sqlgraph.NewCreateSpec(match.Table, sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64)) ) if id, ok := mc.mutation.ID(); ok { _node.ID = id diff --git a/ent/match_delete.go b/ent/match_delete.go index 179a0f5..89a0d0e 100644 --- a/ent/match_delete.go +++ b/ent/match_delete.go @@ -4,7 +4,6 @@ package ent import ( "context" - "fmt" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -28,34 +27,7 @@ func (md *MatchDelete) Where(ps ...predicate.Match) *MatchDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (md *MatchDelete) Exec(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(md.hooks) == 0 { - affected, err = md.sqlExec(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*MatchMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - md.mutation = mutation - affected, err = md.sqlExec(ctx) - mutation.done = true - return affected, err - }) - for i := len(md.hooks) - 1; i >= 0; i-- { - if md.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = md.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, md.mutation); err != nil { - return 0, err - } - } - return affected, err + return withHooks[int, MatchMutation](ctx, md.sqlExec, md.mutation, md.hooks) } // ExecX is like Exec, but panics if an error occurs. @@ -68,15 +40,7 @@ func (md *MatchDelete) ExecX(ctx context.Context) int { } func (md *MatchDelete) sqlExec(ctx context.Context) (int, error) { - _spec := &sqlgraph.DeleteSpec{ - Node: &sqlgraph.NodeSpec{ - Table: match.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeUint64, - Column: match.FieldID, - }, - }, - } + _spec := sqlgraph.NewDeleteSpec(match.Table, sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64)) if ps := md.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -88,6 +52,7 @@ func (md *MatchDelete) sqlExec(ctx context.Context) (int, error) { if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } + md.mutation.done = true return affected, err } @@ -96,6 +61,12 @@ type MatchDeleteOne struct { md *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 +} + // Exec executes the deletion query. func (mdo *MatchDeleteOne) Exec(ctx context.Context) error { n, err := mdo.md.Exec(ctx) @@ -111,5 +82,7 @@ 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) { - mdo.md.ExecX(ctx) + if err := mdo.Exec(ctx); err != nil { + panic(err) + } } diff --git a/ent/match_query.go b/ent/match_query.go index c414ddb..02cea9b 100644 --- a/ent/match_query.go +++ b/ent/match_query.go @@ -20,11 +20,9 @@ import ( // MatchQuery is the builder for querying Match entities. type MatchQuery struct { config - limit *int - offset *int - unique *bool + ctx *QueryContext order []OrderFunc - fields []string + inters []Interceptor predicates []predicate.Match withStats *MatchPlayerQuery withPlayers *PlayerQuery @@ -40,26 +38,26 @@ func (mq *MatchQuery) Where(ps ...predicate.Match) *MatchQuery { return mq } -// Limit adds a limit step to the query. +// Limit the number of records to be returned by this query. func (mq *MatchQuery) Limit(limit int) *MatchQuery { - mq.limit = &limit + mq.ctx.Limit = &limit return mq } -// Offset adds an offset step to the query. +// Offset to start from. func (mq *MatchQuery) Offset(offset int) *MatchQuery { - mq.offset = &offset + mq.ctx.Offset = &offset return mq } // 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.unique = &unique + mq.ctx.Unique = &unique return mq } -// Order adds an order step to the query. +// Order specifies how the records should be ordered. func (mq *MatchQuery) Order(o ...OrderFunc) *MatchQuery { mq.order = append(mq.order, o...) return mq @@ -67,7 +65,7 @@ func (mq *MatchQuery) Order(o ...OrderFunc) *MatchQuery { // QueryStats chains the current query on the "stats" edge. func (mq *MatchQuery) QueryStats() *MatchPlayerQuery { - query := &MatchPlayerQuery{config: mq.config} + query := (&MatchPlayerClient{config: mq.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := mq.prepareQuery(ctx); err != nil { return nil, err @@ -89,7 +87,7 @@ func (mq *MatchQuery) QueryStats() *MatchPlayerQuery { // QueryPlayers chains the current query on the "players" edge. func (mq *MatchQuery) QueryPlayers() *PlayerQuery { - query := &PlayerQuery{config: mq.config} + query := (&PlayerClient{config: mq.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := mq.prepareQuery(ctx); err != nil { return nil, err @@ -112,7 +110,7 @@ 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(ctx) + nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, "First")) if err != nil { return nil, err } @@ -135,7 +133,7 @@ func (mq *MatchQuery) FirstX(ctx context.Context) *Match { // Returns a *NotFoundError when no Match ID was found. func (mq *MatchQuery) FirstID(ctx context.Context) (id uint64, err error) { var ids []uint64 - if ids, err = mq.Limit(1).IDs(ctx); err != nil { + if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, "FirstID")); err != nil { return } if len(ids) == 0 { @@ -158,7 +156,7 @@ func (mq *MatchQuery) FirstIDX(ctx context.Context) uint64 { // 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(ctx) + nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, "Only")) if err != nil { return nil, err } @@ -186,7 +184,7 @@ func (mq *MatchQuery) OnlyX(ctx context.Context) *Match { // Returns a *NotFoundError when no entities are found. func (mq *MatchQuery) OnlyID(ctx context.Context) (id uint64, err error) { var ids []uint64 - if ids, err = mq.Limit(2).IDs(ctx); err != nil { + if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, "OnlyID")); err != nil { return } switch len(ids) { @@ -211,10 +209,12 @@ 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 { return nil, err } - return mq.sqlAll(ctx) + qr := querierAll[[]*Match, *MatchQuery]() + return withInterceptors[[]*Match](ctx, mq, qr, mq.inters) } // AllX is like All, but panics if an error occurs. @@ -227,9 +227,12 @@ 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) ([]uint64, error) { - var ids []uint64 - if err := mq.Select(match.FieldID).Scan(ctx, &ids); err != nil { +func (mq *MatchQuery) IDs(ctx context.Context) (ids []uint64, err error) { + if mq.ctx.Unique == nil && mq.path != nil { + mq.Unique(true) + } + ctx = setContextOp(ctx, mq.ctx, "IDs") + if err = mq.Select(match.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil @@ -246,10 +249,11 @@ 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 { return 0, err } - return mq.sqlCount(ctx) + return withInterceptors[int](ctx, mq, querierCount[*MatchQuery](), mq.inters) } // CountX is like Count, but panics if an error occurs. @@ -263,10 +267,15 @@ 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) { - if err := mq.prepareQuery(ctx); err != nil { - return false, err + ctx = setContextOp(ctx, mq.ctx, "Exist") + switch _, err := mq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil } - return mq.sqlExist(ctx) } // ExistX is like Exist, but panics if an error occurs. @@ -286,23 +295,22 @@ func (mq *MatchQuery) Clone() *MatchQuery { } return &MatchQuery{ config: mq.config, - limit: mq.limit, - offset: mq.offset, + ctx: mq.ctx.Clone(), order: append([]OrderFunc{}, mq.order...), + inters: append([]Interceptor{}, mq.inters...), predicates: append([]predicate.Match{}, mq.predicates...), withStats: mq.withStats.Clone(), withPlayers: mq.withPlayers.Clone(), // clone intermediate query. - sql: mq.sql.Clone(), - path: mq.path, - unique: mq.unique, + sql: mq.sql.Clone(), + path: mq.path, } } // 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 := &MatchPlayerQuery{config: mq.config} + query := (&MatchPlayerClient{config: mq.config}).Query() for _, opt := range opts { opt(query) } @@ -313,7 +321,7 @@ func (mq *MatchQuery) WithStats(opts ...func(*MatchPlayerQuery)) *MatchQuery { // 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 := &PlayerQuery{config: mq.config} + query := (&PlayerClient{config: mq.config}).Query() for _, opt := range opts { opt(query) } @@ -336,16 +344,11 @@ func (mq *MatchQuery) WithPlayers(opts ...func(*PlayerQuery)) *MatchQuery { // Aggregate(ent.Count()). // Scan(ctx, &v) func (mq *MatchQuery) GroupBy(field string, fields ...string) *MatchGroupBy { - grbuild := &MatchGroupBy{config: mq.config} - grbuild.fields = append([]string{field}, fields...) - grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { - if err := mq.prepareQuery(ctx); err != nil { - return nil, err - } - return mq.sqlQuery(ctx), nil - } + mq.ctx.Fields = append([]string{field}, fields...) + grbuild := &MatchGroupBy{build: mq} + grbuild.flds = &mq.ctx.Fields grbuild.label = match.Label - grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan + grbuild.scan = grbuild.Scan return grbuild } @@ -362,11 +365,11 @@ func (mq *MatchQuery) GroupBy(field string, fields ...string) *MatchGroupBy { // Select(match.FieldShareCode). // Scan(ctx, &v) func (mq *MatchQuery) Select(fields ...string) *MatchSelect { - mq.fields = append(mq.fields, fields...) - selbuild := &MatchSelect{MatchQuery: mq} - selbuild.label = match.Label - selbuild.flds, selbuild.scan = &mq.fields, selbuild.Scan - return selbuild + mq.ctx.Fields = append(mq.ctx.Fields, fields...) + sbuild := &MatchSelect{MatchQuery: mq} + sbuild.label = match.Label + sbuild.flds, sbuild.scan = &mq.ctx.Fields, sbuild.Scan + return sbuild } // Aggregate returns a MatchSelect configured with the given aggregations. @@ -375,7 +378,17 @@ func (mq *MatchQuery) Aggregate(fns ...AggregateFunc) *MatchSelect { } func (mq *MatchQuery) prepareQuery(ctx context.Context) error { - for _, f := range mq.fields { + for _, inter := range mq.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 { + return err + } + } + } + for _, f := range mq.ctx.Fields { if !match.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } @@ -487,27 +500,30 @@ func (mq *MatchQuery) loadPlayers(ctx context.Context, query *PlayerQuery, nodes if err := query.prepareQuery(ctx); err != nil { return err } - neighbors, err := query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { - assign := spec.Assign - values := spec.ScanValues - spec.ScanValues = func(columns []string) ([]any, error) { - values, err := values(columns[1:]) - if err != nil { - return nil, err + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullInt64)}, values...), nil } - return append([]any{new(sql.NullInt64)}, values...), nil - } - spec.Assign = func(columns []string, values []any) error { - outValue := uint64(values[0].(*sql.NullInt64).Int64) - inValue := uint64(values[1].(*sql.NullInt64).Int64) - if nids[inValue] == nil { - nids[inValue] = map[*Match]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) + spec.Assign = func(columns []string, values []any) error { + outValue := uint64(values[0].(*sql.NullInt64).Int64) + inValue := uint64(values[1].(*sql.NullInt64).Int64) + if nids[inValue] == nil { + nids[inValue] = map[*Match]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } + }) }) + neighbors, err := withInterceptors[[]*Player](ctx, query, qr, query.inters) if err != nil { return err } @@ -528,41 +544,22 @@ func (mq *MatchQuery) sqlCount(ctx context.Context) (int, error) { if len(mq.modifiers) > 0 { _spec.Modifiers = mq.modifiers } - _spec.Node.Columns = mq.fields - if len(mq.fields) > 0 { - _spec.Unique = mq.unique != nil && *mq.unique + _spec.Node.Columns = mq.ctx.Fields + if len(mq.ctx.Fields) > 0 { + _spec.Unique = mq.ctx.Unique != nil && *mq.ctx.Unique } return sqlgraph.CountNodes(ctx, mq.driver, _spec) } -func (mq *MatchQuery) sqlExist(ctx context.Context) (bool, error) { - switch _, err := mq.FirstID(ctx); { - case IsNotFound(err): - return false, nil - case err != nil: - return false, fmt.Errorf("ent: check existence: %w", err) - default: - return true, nil - } -} - func (mq *MatchQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: match.Table, - Columns: match.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeUint64, - Column: match.FieldID, - }, - }, - From: mq.sql, - Unique: true, - } - if unique := mq.unique; unique != nil { + _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.Unique = *unique + } else if mq.path != nil { + _spec.Unique = true } - if fields := mq.fields; len(fields) > 0 { + if fields := mq.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 { @@ -578,10 +575,10 @@ func (mq *MatchQuery) querySpec() *sqlgraph.QuerySpec { } } } - if limit := mq.limit; limit != nil { + if limit := mq.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := mq.offset; offset != nil { + if offset := mq.ctx.Offset; offset != nil { _spec.Offset = *offset } if ps := mq.order; len(ps) > 0 { @@ -597,7 +594,7 @@ func (mq *MatchQuery) querySpec() *sqlgraph.QuerySpec { func (mq *MatchQuery) sqlQuery(ctx context.Context) *sql.Selector { builder := sql.Dialect(mq.driver.Dialect()) t1 := builder.Table(match.Table) - columns := mq.fields + columns := mq.ctx.Fields if len(columns) == 0 { columns = match.Columns } @@ -606,7 +603,7 @@ func (mq *MatchQuery) sqlQuery(ctx context.Context) *sql.Selector { selector = mq.sql selector.Select(selector.Columns(columns...)...) } - if mq.unique != nil && *mq.unique { + if mq.ctx.Unique != nil && *mq.ctx.Unique { selector.Distinct() } for _, m := range mq.modifiers { @@ -618,12 +615,12 @@ func (mq *MatchQuery) sqlQuery(ctx context.Context) *sql.Selector { for _, p := range mq.order { p(selector) } - if offset := mq.offset; offset != nil { + if offset := mq.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.limit; limit != nil { + if limit := mq.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector @@ -637,13 +634,8 @@ func (mq *MatchQuery) Modify(modifiers ...func(s *sql.Selector)) *MatchSelect { // MatchGroupBy is the group-by builder for Match entities. type MatchGroupBy struct { - config selector - fields []string - fns []AggregateFunc - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) + build *MatchQuery } // Aggregate adds the given aggregation functions to the group-by query. @@ -652,58 +644,46 @@ func (mgb *MatchGroupBy) Aggregate(fns ...AggregateFunc) *MatchGroupBy { return mgb } -// Scan applies the group-by query and scans the result into the given value. +// Scan applies the selector query and scans the result into the given value. func (mgb *MatchGroupBy) Scan(ctx context.Context, v any) error { - query, err := mgb.path(ctx) - if err != nil { + ctx = setContextOp(ctx, mgb.build.ctx, "GroupBy") + if err := mgb.build.prepareQuery(ctx); err != nil { return err } - mgb.sql = query - return mgb.sqlScan(ctx, v) + return scanWithInterceptors[*MatchQuery, *MatchGroupBy](ctx, mgb.build, mgb, mgb.build.inters, v) } -func (mgb *MatchGroupBy) sqlScan(ctx context.Context, v any) error { - for _, f := range mgb.fields { - if !match.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} - } +func (mgb *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 = append(aggregation, fn(selector)) } - selector := mgb.sqlQuery() + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*mgb.flds)+len(mgb.fns)) + for _, f := range *mgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*mgb.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := mgb.driver.Query(ctx, query, args, rows); err != nil { + if err := mgb.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() return sql.ScanSlice(rows, v) } -func (mgb *MatchGroupBy) sqlQuery() *sql.Selector { - selector := mgb.sql.Select() - aggregation := make([]string, 0, len(mgb.fns)) - for _, fn := range mgb.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(mgb.fields)+len(mgb.fns)) - for _, f := range mgb.fields { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - return selector.GroupBy(selector.Columns(mgb.fields...)...) -} - // MatchSelect is the builder for selecting fields of Match entities. type MatchSelect struct { *MatchQuery selector - // intermediate query (i.e. traversal path). - sql *sql.Selector } // Aggregate adds the given aggregation functions to the selector query. @@ -714,26 +694,27 @@ func (ms *MatchSelect) Aggregate(fns ...AggregateFunc) *MatchSelect { // 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 { return err } - ms.sql = ms.MatchQuery.sqlQuery(ctx) - return ms.sqlScan(ctx, v) + return scanWithInterceptors[*MatchQuery, *MatchSelect](ctx, ms.MatchQuery, ms, ms.inters, v) } -func (ms *MatchSelect) sqlScan(ctx context.Context, v any) error { +func (ms *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 = append(aggregation, fn(ms.sql)) + aggregation = append(aggregation, fn(selector)) } switch n := len(*ms.selector.flds); { case n == 0 && len(aggregation) > 0: - ms.sql.Select(aggregation...) + selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: - ms.sql.AppendSelect(aggregation...) + selector.AppendSelect(aggregation...) } rows := &sql.Rows{} - query, args := ms.sql.Query() + query, args := selector.Query() if err := ms.driver.Query(ctx, query, args, rows); err != nil { return err } diff --git a/ent/match_update.go b/ent/match_update.go index ddf599c..d65f4f0 100644 --- a/ent/match_update.go +++ b/ent/match_update.go @@ -308,34 +308,7 @@ func (mu *MatchUpdate) RemovePlayers(p ...*Player) *MatchUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (mu *MatchUpdate) Save(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(mu.hooks) == 0 { - affected, err = mu.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*MatchMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - mu.mutation = mutation - affected, err = mu.sqlSave(ctx) - mutation.done = true - return affected, err - }) - for i := len(mu.hooks) - 1; i >= 0; i-- { - if mu.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = mu.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, mu.mutation); err != nil { - return 0, err - } - } - return affected, err + return withHooks[int, MatchMutation](ctx, mu.sqlSave, mu.mutation, mu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -367,16 +340,7 @@ func (mu *MatchUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *MatchUpd } func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: match.Table, - Columns: match.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeUint64, - Column: match.FieldID, - }, - }, - } + _spec := sqlgraph.NewUpdateSpec(match.Table, match.Columns, sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64)) if ps := mu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -573,6 +537,7 @@ func (mu *MatchUpdate) sqlSave(ctx context.Context) (n int, err error) { } return 0, err } + mu.mutation.done = true return n, nil } @@ -860,6 +825,12 @@ func (muo *MatchUpdateOne) RemovePlayers(p ...*Player) *MatchUpdateOne { return muo.RemovePlayerIDs(ids...) } +// Where appends a list predicates to the MatchUpdate builder. +func (muo *MatchUpdateOne) Where(ps ...predicate.Match) *MatchUpdateOne { + muo.mutation.Where(ps...) + return muo +} + // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. func (muo *MatchUpdateOne) Select(field string, fields ...string) *MatchUpdateOne { @@ -869,40 +840,7 @@ func (muo *MatchUpdateOne) Select(field string, fields ...string) *MatchUpdateOn // Save executes the query and returns the updated Match entity. func (muo *MatchUpdateOne) Save(ctx context.Context) (*Match, error) { - var ( - err error - node *Match - ) - if len(muo.hooks) == 0 { - node, err = muo.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*MatchMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - muo.mutation = mutation - node, err = muo.sqlSave(ctx) - mutation.done = true - return node, err - }) - for i := len(muo.hooks) - 1; i >= 0; i-- { - if muo.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = muo.hooks[i](mut) - } - v, err := mut.Mutate(ctx, muo.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*Match) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from MatchMutation", v) - } - node = nv - } - return node, err + return withHooks[*Match, MatchMutation](ctx, muo.sqlSave, muo.mutation, muo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -934,16 +872,7 @@ func (muo *MatchUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *Matc } func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: match.Table, - Columns: match.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeUint64, - Column: match.FieldID, - }, - }, - } + _spec := sqlgraph.NewUpdateSpec(match.Table, match.Columns, sqlgraph.NewFieldSpec(match.FieldID, field.TypeUint64)) id, ok := muo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Match.id" for update`)} @@ -1160,5 +1089,6 @@ func (muo *MatchUpdateOne) sqlSave(ctx context.Context) (_node *Match, err error } return nil, err } + muo.mutation.done = true return _node, nil } diff --git a/ent/matchplayer.go b/ent/matchplayer.go index b6e61fb..b12912b 100644 --- a/ent/matchplayer.go +++ b/ent/matchplayer.go @@ -406,39 +406,39 @@ func (mp *MatchPlayer) assignValues(columns []string, values []any) error { // QueryMatches queries the "matches" edge of the MatchPlayer entity. func (mp *MatchPlayer) QueryMatches() *MatchQuery { - return (&MatchPlayerClient{config: mp.config}).QueryMatches(mp) + return NewMatchPlayerClient(mp.config).QueryMatches(mp) } // QueryPlayers queries the "players" edge of the MatchPlayer entity. func (mp *MatchPlayer) QueryPlayers() *PlayerQuery { - return (&MatchPlayerClient{config: mp.config}).QueryPlayers(mp) + return NewMatchPlayerClient(mp.config).QueryPlayers(mp) } // QueryWeaponStats queries the "weapon_stats" edge of the MatchPlayer entity. func (mp *MatchPlayer) QueryWeaponStats() *WeaponQuery { - return (&MatchPlayerClient{config: mp.config}).QueryWeaponStats(mp) + return NewMatchPlayerClient(mp.config).QueryWeaponStats(mp) } // QueryRoundStats queries the "round_stats" edge of the MatchPlayer entity. func (mp *MatchPlayer) QueryRoundStats() *RoundStatsQuery { - return (&MatchPlayerClient{config: mp.config}).QueryRoundStats(mp) + return NewMatchPlayerClient(mp.config).QueryRoundStats(mp) } // QuerySpray queries the "spray" edge of the MatchPlayer entity. func (mp *MatchPlayer) QuerySpray() *SprayQuery { - return (&MatchPlayerClient{config: mp.config}).QuerySpray(mp) + return NewMatchPlayerClient(mp.config).QuerySpray(mp) } // QueryMessages queries the "messages" edge of the MatchPlayer entity. func (mp *MatchPlayer) QueryMessages() *MessagesQuery { - return (&MatchPlayerClient{config: mp.config}).QueryMessages(mp) + return NewMatchPlayerClient(mp.config).QueryMessages(mp) } // 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 (&MatchPlayerClient{config: mp.config}).UpdateOne(mp) + return NewMatchPlayerClient(mp.config).UpdateOne(mp) } // Unwrap unwraps the MatchPlayer entity that was returned from a transaction after it was closed, @@ -561,9 +561,3 @@ func (mp *MatchPlayer) String() string { // MatchPlayers is a parsable slice of MatchPlayer. type MatchPlayers []*MatchPlayer - -func (mp MatchPlayers) config(cfg config) { - for _i := range mp { - mp[_i].config = cfg - } -} diff --git a/ent/matchplayer/where.go b/ent/matchplayer/where.go index e189a3c..665c874 100644 --- a/ent/matchplayer/where.go +++ b/ent/matchplayer/where.go @@ -10,2724 +10,1752 @@ import ( // ID filters vertices based on their ID field. func ID(id int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldID, id)) } // IDEQ applies the EQ predicate on the ID field. func IDEQ(id int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldID, id)) } // IDNEQ applies the NEQ predicate on the ID field. func IDNEQ(id int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldID), id)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldID, id)) } // IDIn applies the In predicate on the ID field. func IDIn(ids ...int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - v := make([]any, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.In(s.C(FieldID), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldID, ids...)) } // IDNotIn applies the NotIn predicate on the ID field. func IDNotIn(ids ...int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - v := make([]any, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.NotIn(s.C(FieldID), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldID, ids...)) } // IDGT applies the GT predicate on the ID field. func IDGT(id int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldID), id)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldID, id)) } // IDGTE applies the GTE predicate on the ID field. func IDGTE(id int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldID), id)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldID, id)) } // IDLT applies the LT predicate on the ID field. func IDLT(id int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldID), id)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldID, id)) } // IDLTE applies the LTE predicate on the ID field. func IDLTE(id int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldID), id)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldID, id)) } // TeamID applies equality check predicate on the "team_id" field. It's identical to TeamIDEQ. func TeamID(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldTeamID), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldTeamID, v)) } // Kills applies equality check predicate on the "kills" field. It's identical to KillsEQ. func Kills(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldKills), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldKills, v)) } // Deaths applies equality check predicate on the "deaths" field. It's identical to DeathsEQ. func Deaths(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldDeaths), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldDeaths, v)) } // Assists applies equality check predicate on the "assists" field. It's identical to AssistsEQ. func Assists(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldAssists), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldAssists, v)) } // Headshot applies equality check predicate on the "headshot" field. It's identical to HeadshotEQ. func Headshot(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldHeadshot), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldHeadshot, v)) } // Mvp applies equality check predicate on the "mvp" field. It's identical to MvpEQ. func Mvp(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldMvp), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldMvp, v)) } // Score applies equality check predicate on the "score" field. It's identical to ScoreEQ. func Score(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldScore), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldScore, v)) } // RankNew applies equality check predicate on the "rank_new" field. It's identical to RankNewEQ. func RankNew(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldRankNew), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldRankNew, v)) } // RankOld applies equality check predicate on the "rank_old" field. It's identical to RankOldEQ. func RankOld(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldRankOld), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldRankOld, v)) } // Mk2 applies equality check predicate on the "mk_2" field. It's identical to Mk2EQ. func Mk2(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldMk2), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldMk2, v)) } // Mk3 applies equality check predicate on the "mk_3" field. It's identical to Mk3EQ. func Mk3(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldMk3), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldMk3, v)) } // Mk4 applies equality check predicate on the "mk_4" field. It's identical to Mk4EQ. func Mk4(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldMk4), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldMk4, v)) } // Mk5 applies equality check predicate on the "mk_5" field. It's identical to Mk5EQ. func Mk5(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldMk5), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldMk5, v)) } // DmgEnemy applies equality check predicate on the "dmg_enemy" field. It's identical to DmgEnemyEQ. func DmgEnemy(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldDmgEnemy), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldDmgEnemy, v)) } // DmgTeam applies equality check predicate on the "dmg_team" field. It's identical to DmgTeamEQ. func DmgTeam(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldDmgTeam), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldDmgTeam, v)) } // UdHe applies equality check predicate on the "ud_he" field. It's identical to UdHeEQ. func UdHe(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldUdHe), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldUdHe, v)) } // UdFlames applies equality check predicate on the "ud_flames" field. It's identical to UdFlamesEQ. func UdFlames(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldUdFlames), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldUdFlames, v)) } // UdFlash applies equality check predicate on the "ud_flash" field. It's identical to UdFlashEQ. func UdFlash(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldUdFlash), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldUdFlash, v)) } // UdDecoy applies equality check predicate on the "ud_decoy" field. It's identical to UdDecoyEQ. func UdDecoy(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldUdDecoy), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldUdDecoy, v)) } // UdSmoke applies equality check predicate on the "ud_smoke" field. It's identical to UdSmokeEQ. func UdSmoke(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldUdSmoke), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldUdSmoke, v)) } // Crosshair applies equality check predicate on the "crosshair" field. It's identical to CrosshairEQ. func Crosshair(v string) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldCrosshair), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldCrosshair, v)) } // Kast applies equality check predicate on the "kast" field. It's identical to KastEQ. func Kast(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldKast), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldKast, v)) } // FlashDurationSelf applies equality check predicate on the "flash_duration_self" field. It's identical to FlashDurationSelfEQ. func FlashDurationSelf(v float32) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldFlashDurationSelf), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldFlashDurationSelf, v)) } // FlashDurationTeam applies equality check predicate on the "flash_duration_team" field. It's identical to FlashDurationTeamEQ. func FlashDurationTeam(v float32) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldFlashDurationTeam), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldFlashDurationTeam, v)) } // FlashDurationEnemy applies equality check predicate on the "flash_duration_enemy" field. It's identical to FlashDurationEnemyEQ. func FlashDurationEnemy(v float32) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldFlashDurationEnemy), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldFlashDurationEnemy, v)) } // FlashTotalSelf applies equality check predicate on the "flash_total_self" field. It's identical to FlashTotalSelfEQ. func FlashTotalSelf(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldFlashTotalSelf), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldFlashTotalSelf, v)) } // FlashTotalTeam applies equality check predicate on the "flash_total_team" field. It's identical to FlashTotalTeamEQ. func FlashTotalTeam(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldFlashTotalTeam), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldFlashTotalTeam, v)) } // FlashTotalEnemy applies equality check predicate on the "flash_total_enemy" field. It's identical to FlashTotalEnemyEQ. func FlashTotalEnemy(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldFlashTotalEnemy), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldFlashTotalEnemy, v)) } // MatchStats applies equality check predicate on the "match_stats" field. It's identical to MatchStatsEQ. func MatchStats(v uint64) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldMatchStats), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldMatchStats, v)) } // PlayerStats applies equality check predicate on the "player_stats" field. It's identical to PlayerStatsEQ. func PlayerStats(v uint64) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldPlayerStats), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldPlayerStats, v)) } // FlashAssists applies equality check predicate on the "flash_assists" field. It's identical to FlashAssistsEQ. func FlashAssists(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldFlashAssists), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldFlashAssists, v)) } // AvgPing applies equality check predicate on the "avg_ping" field. It's identical to AvgPingEQ. func AvgPing(v float64) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldAvgPing), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldAvgPing, v)) } // TeamIDEQ applies the EQ predicate on the "team_id" field. func TeamIDEQ(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldTeamID), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldTeamID, v)) } // TeamIDNEQ applies the NEQ predicate on the "team_id" field. func TeamIDNEQ(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldTeamID), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldTeamID, v)) } // TeamIDIn applies the In predicate on the "team_id" field. func TeamIDIn(vs ...int) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldTeamID), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldTeamID, vs...)) } // TeamIDNotIn applies the NotIn predicate on the "team_id" field. func TeamIDNotIn(vs ...int) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldTeamID), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldTeamID, vs...)) } // TeamIDGT applies the GT predicate on the "team_id" field. func TeamIDGT(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldTeamID), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldTeamID, v)) } // TeamIDGTE applies the GTE predicate on the "team_id" field. func TeamIDGTE(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldTeamID), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldTeamID, v)) } // TeamIDLT applies the LT predicate on the "team_id" field. func TeamIDLT(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldTeamID), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldTeamID, v)) } // TeamIDLTE applies the LTE predicate on the "team_id" field. func TeamIDLTE(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldTeamID), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldTeamID, v)) } // KillsEQ applies the EQ predicate on the "kills" field. func KillsEQ(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldKills), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldKills, v)) } // KillsNEQ applies the NEQ predicate on the "kills" field. func KillsNEQ(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldKills), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldKills, v)) } // KillsIn applies the In predicate on the "kills" field. func KillsIn(vs ...int) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldKills), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldKills, vs...)) } // KillsNotIn applies the NotIn predicate on the "kills" field. func KillsNotIn(vs ...int) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldKills), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldKills, vs...)) } // KillsGT applies the GT predicate on the "kills" field. func KillsGT(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldKills), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldKills, v)) } // KillsGTE applies the GTE predicate on the "kills" field. func KillsGTE(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldKills), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldKills, v)) } // KillsLT applies the LT predicate on the "kills" field. func KillsLT(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldKills), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldKills, v)) } // KillsLTE applies the LTE predicate on the "kills" field. func KillsLTE(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldKills), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldKills, v)) } // DeathsEQ applies the EQ predicate on the "deaths" field. func DeathsEQ(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldDeaths), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldDeaths, v)) } // DeathsNEQ applies the NEQ predicate on the "deaths" field. func DeathsNEQ(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldDeaths), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldDeaths, v)) } // DeathsIn applies the In predicate on the "deaths" field. func DeathsIn(vs ...int) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldDeaths), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldDeaths, vs...)) } // DeathsNotIn applies the NotIn predicate on the "deaths" field. func DeathsNotIn(vs ...int) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldDeaths), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldDeaths, vs...)) } // DeathsGT applies the GT predicate on the "deaths" field. func DeathsGT(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldDeaths), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldDeaths, v)) } // DeathsGTE applies the GTE predicate on the "deaths" field. func DeathsGTE(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldDeaths), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldDeaths, v)) } // DeathsLT applies the LT predicate on the "deaths" field. func DeathsLT(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldDeaths), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldDeaths, v)) } // DeathsLTE applies the LTE predicate on the "deaths" field. func DeathsLTE(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldDeaths), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldDeaths, v)) } // AssistsEQ applies the EQ predicate on the "assists" field. func AssistsEQ(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldAssists), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldAssists, v)) } // AssistsNEQ applies the NEQ predicate on the "assists" field. func AssistsNEQ(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldAssists), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldAssists, v)) } // AssistsIn applies the In predicate on the "assists" field. func AssistsIn(vs ...int) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldAssists), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldAssists, vs...)) } // AssistsNotIn applies the NotIn predicate on the "assists" field. func AssistsNotIn(vs ...int) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldAssists), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldAssists, vs...)) } // AssistsGT applies the GT predicate on the "assists" field. func AssistsGT(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldAssists), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldAssists, v)) } // AssistsGTE applies the GTE predicate on the "assists" field. func AssistsGTE(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldAssists), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldAssists, v)) } // AssistsLT applies the LT predicate on the "assists" field. func AssistsLT(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldAssists), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldAssists, v)) } // AssistsLTE applies the LTE predicate on the "assists" field. func AssistsLTE(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldAssists), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldAssists, v)) } // HeadshotEQ applies the EQ predicate on the "headshot" field. func HeadshotEQ(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldHeadshot), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldHeadshot, v)) } // HeadshotNEQ applies the NEQ predicate on the "headshot" field. func HeadshotNEQ(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldHeadshot), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldHeadshot, v)) } // HeadshotIn applies the In predicate on the "headshot" field. func HeadshotIn(vs ...int) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldHeadshot), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldHeadshot, vs...)) } // HeadshotNotIn applies the NotIn predicate on the "headshot" field. func HeadshotNotIn(vs ...int) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldHeadshot), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldHeadshot, vs...)) } // HeadshotGT applies the GT predicate on the "headshot" field. func HeadshotGT(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldHeadshot), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldHeadshot, v)) } // HeadshotGTE applies the GTE predicate on the "headshot" field. func HeadshotGTE(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldHeadshot), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldHeadshot, v)) } // HeadshotLT applies the LT predicate on the "headshot" field. func HeadshotLT(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldHeadshot), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldHeadshot, v)) } // HeadshotLTE applies the LTE predicate on the "headshot" field. func HeadshotLTE(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldHeadshot), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldHeadshot, v)) } // MvpEQ applies the EQ predicate on the "mvp" field. func MvpEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldMvp), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldMvp, v)) } // MvpNEQ applies the NEQ predicate on the "mvp" field. func MvpNEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldMvp), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldMvp, v)) } // MvpIn applies the In predicate on the "mvp" field. func MvpIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldMvp), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldMvp, vs...)) } // MvpNotIn applies the NotIn predicate on the "mvp" field. func MvpNotIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldMvp), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldMvp, vs...)) } // MvpGT applies the GT predicate on the "mvp" field. func MvpGT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldMvp), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldMvp, v)) } // MvpGTE applies the GTE predicate on the "mvp" field. func MvpGTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldMvp), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldMvp, v)) } // MvpLT applies the LT predicate on the "mvp" field. func MvpLT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldMvp), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldMvp, v)) } // MvpLTE applies the LTE predicate on the "mvp" field. func MvpLTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldMvp), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldMvp, v)) } // ScoreEQ applies the EQ predicate on the "score" field. func ScoreEQ(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldScore), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldScore, v)) } // ScoreNEQ applies the NEQ predicate on the "score" field. func ScoreNEQ(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldScore), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldScore, v)) } // ScoreIn applies the In predicate on the "score" field. func ScoreIn(vs ...int) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldScore), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldScore, vs...)) } // ScoreNotIn applies the NotIn predicate on the "score" field. func ScoreNotIn(vs ...int) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldScore), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldScore, vs...)) } // ScoreGT applies the GT predicate on the "score" field. func ScoreGT(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldScore), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldScore, v)) } // ScoreGTE applies the GTE predicate on the "score" field. func ScoreGTE(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldScore), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldScore, v)) } // ScoreLT applies the LT predicate on the "score" field. func ScoreLT(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldScore), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldScore, v)) } // ScoreLTE applies the LTE predicate on the "score" field. func ScoreLTE(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldScore), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldScore, v)) } // RankNewEQ applies the EQ predicate on the "rank_new" field. func RankNewEQ(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldRankNew), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldRankNew, v)) } // RankNewNEQ applies the NEQ predicate on the "rank_new" field. func RankNewNEQ(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldRankNew), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldRankNew, v)) } // RankNewIn applies the In predicate on the "rank_new" field. func RankNewIn(vs ...int) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldRankNew), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldRankNew, vs...)) } // RankNewNotIn applies the NotIn predicate on the "rank_new" field. func RankNewNotIn(vs ...int) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldRankNew), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldRankNew, vs...)) } // RankNewGT applies the GT predicate on the "rank_new" field. func RankNewGT(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldRankNew), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldRankNew, v)) } // RankNewGTE applies the GTE predicate on the "rank_new" field. func RankNewGTE(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldRankNew), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldRankNew, v)) } // RankNewLT applies the LT predicate on the "rank_new" field. func RankNewLT(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldRankNew), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldRankNew, v)) } // RankNewLTE applies the LTE predicate on the "rank_new" field. func RankNewLTE(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldRankNew), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldRankNew, v)) } // RankNewIsNil applies the IsNil predicate on the "rank_new" field. func RankNewIsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldRankNew))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldRankNew)) } // RankNewNotNil applies the NotNil predicate on the "rank_new" field. func RankNewNotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldRankNew))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldRankNew)) } // RankOldEQ applies the EQ predicate on the "rank_old" field. func RankOldEQ(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldRankOld), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldRankOld, v)) } // RankOldNEQ applies the NEQ predicate on the "rank_old" field. func RankOldNEQ(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldRankOld), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldRankOld, v)) } // RankOldIn applies the In predicate on the "rank_old" field. func RankOldIn(vs ...int) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldRankOld), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldRankOld, vs...)) } // RankOldNotIn applies the NotIn predicate on the "rank_old" field. func RankOldNotIn(vs ...int) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldRankOld), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldRankOld, vs...)) } // RankOldGT applies the GT predicate on the "rank_old" field. func RankOldGT(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldRankOld), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldRankOld, v)) } // RankOldGTE applies the GTE predicate on the "rank_old" field. func RankOldGTE(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldRankOld), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldRankOld, v)) } // RankOldLT applies the LT predicate on the "rank_old" field. func RankOldLT(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldRankOld), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldRankOld, v)) } // RankOldLTE applies the LTE predicate on the "rank_old" field. func RankOldLTE(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldRankOld), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldRankOld, v)) } // RankOldIsNil applies the IsNil predicate on the "rank_old" field. func RankOldIsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldRankOld))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldRankOld)) } // RankOldNotNil applies the NotNil predicate on the "rank_old" field. func RankOldNotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldRankOld))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldRankOld)) } // Mk2EQ applies the EQ predicate on the "mk_2" field. func Mk2EQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldMk2), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldMk2, v)) } // Mk2NEQ applies the NEQ predicate on the "mk_2" field. func Mk2NEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldMk2), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldMk2, v)) } // Mk2In applies the In predicate on the "mk_2" field. func Mk2In(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldMk2), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldMk2, vs...)) } // Mk2NotIn applies the NotIn predicate on the "mk_2" field. func Mk2NotIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldMk2), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldMk2, vs...)) } // Mk2GT applies the GT predicate on the "mk_2" field. func Mk2GT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldMk2), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldMk2, v)) } // Mk2GTE applies the GTE predicate on the "mk_2" field. func Mk2GTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldMk2), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldMk2, v)) } // Mk2LT applies the LT predicate on the "mk_2" field. func Mk2LT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldMk2), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldMk2, v)) } // Mk2LTE applies the LTE predicate on the "mk_2" field. func Mk2LTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldMk2), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldMk2, v)) } // Mk2IsNil applies the IsNil predicate on the "mk_2" field. func Mk2IsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldMk2))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldMk2)) } // Mk2NotNil applies the NotNil predicate on the "mk_2" field. func Mk2NotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldMk2))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldMk2)) } // Mk3EQ applies the EQ predicate on the "mk_3" field. func Mk3EQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldMk3), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldMk3, v)) } // Mk3NEQ applies the NEQ predicate on the "mk_3" field. func Mk3NEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldMk3), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldMk3, v)) } // Mk3In applies the In predicate on the "mk_3" field. func Mk3In(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldMk3), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldMk3, vs...)) } // Mk3NotIn applies the NotIn predicate on the "mk_3" field. func Mk3NotIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldMk3), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldMk3, vs...)) } // Mk3GT applies the GT predicate on the "mk_3" field. func Mk3GT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldMk3), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldMk3, v)) } // Mk3GTE applies the GTE predicate on the "mk_3" field. func Mk3GTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldMk3), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldMk3, v)) } // Mk3LT applies the LT predicate on the "mk_3" field. func Mk3LT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldMk3), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldMk3, v)) } // Mk3LTE applies the LTE predicate on the "mk_3" field. func Mk3LTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldMk3), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldMk3, v)) } // Mk3IsNil applies the IsNil predicate on the "mk_3" field. func Mk3IsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldMk3))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldMk3)) } // Mk3NotNil applies the NotNil predicate on the "mk_3" field. func Mk3NotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldMk3))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldMk3)) } // Mk4EQ applies the EQ predicate on the "mk_4" field. func Mk4EQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldMk4), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldMk4, v)) } // Mk4NEQ applies the NEQ predicate on the "mk_4" field. func Mk4NEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldMk4), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldMk4, v)) } // Mk4In applies the In predicate on the "mk_4" field. func Mk4In(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldMk4), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldMk4, vs...)) } // Mk4NotIn applies the NotIn predicate on the "mk_4" field. func Mk4NotIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldMk4), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldMk4, vs...)) } // Mk4GT applies the GT predicate on the "mk_4" field. func Mk4GT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldMk4), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldMk4, v)) } // Mk4GTE applies the GTE predicate on the "mk_4" field. func Mk4GTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldMk4), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldMk4, v)) } // Mk4LT applies the LT predicate on the "mk_4" field. func Mk4LT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldMk4), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldMk4, v)) } // Mk4LTE applies the LTE predicate on the "mk_4" field. func Mk4LTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldMk4), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldMk4, v)) } // Mk4IsNil applies the IsNil predicate on the "mk_4" field. func Mk4IsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldMk4))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldMk4)) } // Mk4NotNil applies the NotNil predicate on the "mk_4" field. func Mk4NotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldMk4))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldMk4)) } // Mk5EQ applies the EQ predicate on the "mk_5" field. func Mk5EQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldMk5), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldMk5, v)) } // Mk5NEQ applies the NEQ predicate on the "mk_5" field. func Mk5NEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldMk5), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldMk5, v)) } // Mk5In applies the In predicate on the "mk_5" field. func Mk5In(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldMk5), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldMk5, vs...)) } // Mk5NotIn applies the NotIn predicate on the "mk_5" field. func Mk5NotIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldMk5), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldMk5, vs...)) } // Mk5GT applies the GT predicate on the "mk_5" field. func Mk5GT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldMk5), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldMk5, v)) } // Mk5GTE applies the GTE predicate on the "mk_5" field. func Mk5GTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldMk5), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldMk5, v)) } // Mk5LT applies the LT predicate on the "mk_5" field. func Mk5LT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldMk5), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldMk5, v)) } // Mk5LTE applies the LTE predicate on the "mk_5" field. func Mk5LTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldMk5), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldMk5, v)) } // Mk5IsNil applies the IsNil predicate on the "mk_5" field. func Mk5IsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldMk5))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldMk5)) } // Mk5NotNil applies the NotNil predicate on the "mk_5" field. func Mk5NotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldMk5))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldMk5)) } // DmgEnemyEQ applies the EQ predicate on the "dmg_enemy" field. func DmgEnemyEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldDmgEnemy), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldDmgEnemy, v)) } // DmgEnemyNEQ applies the NEQ predicate on the "dmg_enemy" field. func DmgEnemyNEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldDmgEnemy), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldDmgEnemy, v)) } // DmgEnemyIn applies the In predicate on the "dmg_enemy" field. func DmgEnemyIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldDmgEnemy), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldDmgEnemy, vs...)) } // DmgEnemyNotIn applies the NotIn predicate on the "dmg_enemy" field. func DmgEnemyNotIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldDmgEnemy), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldDmgEnemy, vs...)) } // DmgEnemyGT applies the GT predicate on the "dmg_enemy" field. func DmgEnemyGT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldDmgEnemy), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldDmgEnemy, v)) } // DmgEnemyGTE applies the GTE predicate on the "dmg_enemy" field. func DmgEnemyGTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldDmgEnemy), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldDmgEnemy, v)) } // DmgEnemyLT applies the LT predicate on the "dmg_enemy" field. func DmgEnemyLT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldDmgEnemy), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldDmgEnemy, v)) } // DmgEnemyLTE applies the LTE predicate on the "dmg_enemy" field. func DmgEnemyLTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldDmgEnemy), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldDmgEnemy, v)) } // DmgEnemyIsNil applies the IsNil predicate on the "dmg_enemy" field. func DmgEnemyIsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldDmgEnemy))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldDmgEnemy)) } // DmgEnemyNotNil applies the NotNil predicate on the "dmg_enemy" field. func DmgEnemyNotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldDmgEnemy))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldDmgEnemy)) } // DmgTeamEQ applies the EQ predicate on the "dmg_team" field. func DmgTeamEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldDmgTeam), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldDmgTeam, v)) } // DmgTeamNEQ applies the NEQ predicate on the "dmg_team" field. func DmgTeamNEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldDmgTeam), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldDmgTeam, v)) } // DmgTeamIn applies the In predicate on the "dmg_team" field. func DmgTeamIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldDmgTeam), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldDmgTeam, vs...)) } // DmgTeamNotIn applies the NotIn predicate on the "dmg_team" field. func DmgTeamNotIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldDmgTeam), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldDmgTeam, vs...)) } // DmgTeamGT applies the GT predicate on the "dmg_team" field. func DmgTeamGT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldDmgTeam), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldDmgTeam, v)) } // DmgTeamGTE applies the GTE predicate on the "dmg_team" field. func DmgTeamGTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldDmgTeam), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldDmgTeam, v)) } // DmgTeamLT applies the LT predicate on the "dmg_team" field. func DmgTeamLT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldDmgTeam), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldDmgTeam, v)) } // DmgTeamLTE applies the LTE predicate on the "dmg_team" field. func DmgTeamLTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldDmgTeam), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldDmgTeam, v)) } // DmgTeamIsNil applies the IsNil predicate on the "dmg_team" field. func DmgTeamIsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldDmgTeam))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldDmgTeam)) } // DmgTeamNotNil applies the NotNil predicate on the "dmg_team" field. func DmgTeamNotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldDmgTeam))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldDmgTeam)) } // UdHeEQ applies the EQ predicate on the "ud_he" field. func UdHeEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldUdHe), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldUdHe, v)) } // UdHeNEQ applies the NEQ predicate on the "ud_he" field. func UdHeNEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldUdHe), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldUdHe, v)) } // UdHeIn applies the In predicate on the "ud_he" field. func UdHeIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldUdHe), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldUdHe, vs...)) } // UdHeNotIn applies the NotIn predicate on the "ud_he" field. func UdHeNotIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldUdHe), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldUdHe, vs...)) } // UdHeGT applies the GT predicate on the "ud_he" field. func UdHeGT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldUdHe), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldUdHe, v)) } // UdHeGTE applies the GTE predicate on the "ud_he" field. func UdHeGTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldUdHe), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldUdHe, v)) } // UdHeLT applies the LT predicate on the "ud_he" field. func UdHeLT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldUdHe), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldUdHe, v)) } // UdHeLTE applies the LTE predicate on the "ud_he" field. func UdHeLTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldUdHe), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldUdHe, v)) } // UdHeIsNil applies the IsNil predicate on the "ud_he" field. func UdHeIsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldUdHe))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldUdHe)) } // UdHeNotNil applies the NotNil predicate on the "ud_he" field. func UdHeNotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldUdHe))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldUdHe)) } // UdFlamesEQ applies the EQ predicate on the "ud_flames" field. func UdFlamesEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldUdFlames), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldUdFlames, v)) } // UdFlamesNEQ applies the NEQ predicate on the "ud_flames" field. func UdFlamesNEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldUdFlames), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldUdFlames, v)) } // UdFlamesIn applies the In predicate on the "ud_flames" field. func UdFlamesIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldUdFlames), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldUdFlames, vs...)) } // UdFlamesNotIn applies the NotIn predicate on the "ud_flames" field. func UdFlamesNotIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldUdFlames), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldUdFlames, vs...)) } // UdFlamesGT applies the GT predicate on the "ud_flames" field. func UdFlamesGT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldUdFlames), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldUdFlames, v)) } // UdFlamesGTE applies the GTE predicate on the "ud_flames" field. func UdFlamesGTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldUdFlames), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldUdFlames, v)) } // UdFlamesLT applies the LT predicate on the "ud_flames" field. func UdFlamesLT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldUdFlames), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldUdFlames, v)) } // UdFlamesLTE applies the LTE predicate on the "ud_flames" field. func UdFlamesLTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldUdFlames), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldUdFlames, v)) } // UdFlamesIsNil applies the IsNil predicate on the "ud_flames" field. func UdFlamesIsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldUdFlames))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldUdFlames)) } // UdFlamesNotNil applies the NotNil predicate on the "ud_flames" field. func UdFlamesNotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldUdFlames))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldUdFlames)) } // UdFlashEQ applies the EQ predicate on the "ud_flash" field. func UdFlashEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldUdFlash), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldUdFlash, v)) } // UdFlashNEQ applies the NEQ predicate on the "ud_flash" field. func UdFlashNEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldUdFlash), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldUdFlash, v)) } // UdFlashIn applies the In predicate on the "ud_flash" field. func UdFlashIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldUdFlash), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldUdFlash, vs...)) } // UdFlashNotIn applies the NotIn predicate on the "ud_flash" field. func UdFlashNotIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldUdFlash), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldUdFlash, vs...)) } // UdFlashGT applies the GT predicate on the "ud_flash" field. func UdFlashGT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldUdFlash), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldUdFlash, v)) } // UdFlashGTE applies the GTE predicate on the "ud_flash" field. func UdFlashGTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldUdFlash), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldUdFlash, v)) } // UdFlashLT applies the LT predicate on the "ud_flash" field. func UdFlashLT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldUdFlash), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldUdFlash, v)) } // UdFlashLTE applies the LTE predicate on the "ud_flash" field. func UdFlashLTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldUdFlash), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldUdFlash, v)) } // UdFlashIsNil applies the IsNil predicate on the "ud_flash" field. func UdFlashIsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldUdFlash))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldUdFlash)) } // UdFlashNotNil applies the NotNil predicate on the "ud_flash" field. func UdFlashNotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldUdFlash))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldUdFlash)) } // UdDecoyEQ applies the EQ predicate on the "ud_decoy" field. func UdDecoyEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldUdDecoy), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldUdDecoy, v)) } // UdDecoyNEQ applies the NEQ predicate on the "ud_decoy" field. func UdDecoyNEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldUdDecoy), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldUdDecoy, v)) } // UdDecoyIn applies the In predicate on the "ud_decoy" field. func UdDecoyIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldUdDecoy), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldUdDecoy, vs...)) } // UdDecoyNotIn applies the NotIn predicate on the "ud_decoy" field. func UdDecoyNotIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldUdDecoy), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldUdDecoy, vs...)) } // UdDecoyGT applies the GT predicate on the "ud_decoy" field. func UdDecoyGT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldUdDecoy), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldUdDecoy, v)) } // UdDecoyGTE applies the GTE predicate on the "ud_decoy" field. func UdDecoyGTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldUdDecoy), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldUdDecoy, v)) } // UdDecoyLT applies the LT predicate on the "ud_decoy" field. func UdDecoyLT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldUdDecoy), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldUdDecoy, v)) } // UdDecoyLTE applies the LTE predicate on the "ud_decoy" field. func UdDecoyLTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldUdDecoy), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldUdDecoy, v)) } // UdDecoyIsNil applies the IsNil predicate on the "ud_decoy" field. func UdDecoyIsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldUdDecoy))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldUdDecoy)) } // UdDecoyNotNil applies the NotNil predicate on the "ud_decoy" field. func UdDecoyNotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldUdDecoy))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldUdDecoy)) } // UdSmokeEQ applies the EQ predicate on the "ud_smoke" field. func UdSmokeEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldUdSmoke), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldUdSmoke, v)) } // UdSmokeNEQ applies the NEQ predicate on the "ud_smoke" field. func UdSmokeNEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldUdSmoke), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldUdSmoke, v)) } // UdSmokeIn applies the In predicate on the "ud_smoke" field. func UdSmokeIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldUdSmoke), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldUdSmoke, vs...)) } // UdSmokeNotIn applies the NotIn predicate on the "ud_smoke" field. func UdSmokeNotIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldUdSmoke), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldUdSmoke, vs...)) } // UdSmokeGT applies the GT predicate on the "ud_smoke" field. func UdSmokeGT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldUdSmoke), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldUdSmoke, v)) } // UdSmokeGTE applies the GTE predicate on the "ud_smoke" field. func UdSmokeGTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldUdSmoke), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldUdSmoke, v)) } // UdSmokeLT applies the LT predicate on the "ud_smoke" field. func UdSmokeLT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldUdSmoke), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldUdSmoke, v)) } // UdSmokeLTE applies the LTE predicate on the "ud_smoke" field. func UdSmokeLTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldUdSmoke), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldUdSmoke, v)) } // UdSmokeIsNil applies the IsNil predicate on the "ud_smoke" field. func UdSmokeIsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldUdSmoke))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldUdSmoke)) } // UdSmokeNotNil applies the NotNil predicate on the "ud_smoke" field. func UdSmokeNotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldUdSmoke))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldUdSmoke)) } // CrosshairEQ applies the EQ predicate on the "crosshair" field. func CrosshairEQ(v string) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldCrosshair), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldCrosshair, v)) } // CrosshairNEQ applies the NEQ predicate on the "crosshair" field. func CrosshairNEQ(v string) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldCrosshair), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldCrosshair, v)) } // CrosshairIn applies the In predicate on the "crosshair" field. func CrosshairIn(vs ...string) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldCrosshair), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldCrosshair, vs...)) } // CrosshairNotIn applies the NotIn predicate on the "crosshair" field. func CrosshairNotIn(vs ...string) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldCrosshair), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldCrosshair, vs...)) } // CrosshairGT applies the GT predicate on the "crosshair" field. func CrosshairGT(v string) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldCrosshair), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldCrosshair, v)) } // CrosshairGTE applies the GTE predicate on the "crosshair" field. func CrosshairGTE(v string) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldCrosshair), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldCrosshair, v)) } // CrosshairLT applies the LT predicate on the "crosshair" field. func CrosshairLT(v string) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldCrosshair), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldCrosshair, v)) } // CrosshairLTE applies the LTE predicate on the "crosshair" field. func CrosshairLTE(v string) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldCrosshair), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldCrosshair, v)) } // CrosshairContains applies the Contains predicate on the "crosshair" field. func CrosshairContains(v string) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldCrosshair), v)) - }) + return predicate.MatchPlayer(sql.FieldContains(FieldCrosshair, v)) } // CrosshairHasPrefix applies the HasPrefix predicate on the "crosshair" field. func CrosshairHasPrefix(v string) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldCrosshair), v)) - }) + return predicate.MatchPlayer(sql.FieldHasPrefix(FieldCrosshair, v)) } // CrosshairHasSuffix applies the HasSuffix predicate on the "crosshair" field. func CrosshairHasSuffix(v string) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldCrosshair), v)) - }) + return predicate.MatchPlayer(sql.FieldHasSuffix(FieldCrosshair, v)) } // CrosshairIsNil applies the IsNil predicate on the "crosshair" field. func CrosshairIsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldCrosshair))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldCrosshair)) } // CrosshairNotNil applies the NotNil predicate on the "crosshair" field. func CrosshairNotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldCrosshair))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldCrosshair)) } // CrosshairEqualFold applies the EqualFold predicate on the "crosshair" field. func CrosshairEqualFold(v string) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldCrosshair), v)) - }) + return predicate.MatchPlayer(sql.FieldEqualFold(FieldCrosshair, v)) } // CrosshairContainsFold applies the ContainsFold predicate on the "crosshair" field. func CrosshairContainsFold(v string) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldCrosshair), v)) - }) + return predicate.MatchPlayer(sql.FieldContainsFold(FieldCrosshair, v)) } // ColorEQ applies the EQ predicate on the "color" field. func ColorEQ(v Color) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldColor), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldColor, v)) } // ColorNEQ applies the NEQ predicate on the "color" field. func ColorNEQ(v Color) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldColor), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldColor, v)) } // ColorIn applies the In predicate on the "color" field. func ColorIn(vs ...Color) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldColor), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldColor, vs...)) } // ColorNotIn applies the NotIn predicate on the "color" field. func ColorNotIn(vs ...Color) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldColor), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldColor, vs...)) } // ColorIsNil applies the IsNil predicate on the "color" field. func ColorIsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldColor))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldColor)) } // ColorNotNil applies the NotNil predicate on the "color" field. func ColorNotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldColor))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldColor)) } // KastEQ applies the EQ predicate on the "kast" field. func KastEQ(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldKast), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldKast, v)) } // KastNEQ applies the NEQ predicate on the "kast" field. func KastNEQ(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldKast), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldKast, v)) } // KastIn applies the In predicate on the "kast" field. func KastIn(vs ...int) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldKast), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldKast, vs...)) } // KastNotIn applies the NotIn predicate on the "kast" field. func KastNotIn(vs ...int) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldKast), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldKast, vs...)) } // KastGT applies the GT predicate on the "kast" field. func KastGT(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldKast), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldKast, v)) } // KastGTE applies the GTE predicate on the "kast" field. func KastGTE(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldKast), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldKast, v)) } // KastLT applies the LT predicate on the "kast" field. func KastLT(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldKast), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldKast, v)) } // KastLTE applies the LTE predicate on the "kast" field. func KastLTE(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldKast), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldKast, v)) } // KastIsNil applies the IsNil predicate on the "kast" field. func KastIsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldKast))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldKast)) } // KastNotNil applies the NotNil predicate on the "kast" field. func KastNotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldKast))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldKast)) } // FlashDurationSelfEQ applies the EQ predicate on the "flash_duration_self" field. func FlashDurationSelfEQ(v float32) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldFlashDurationSelf), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldFlashDurationSelf, v)) } // FlashDurationSelfNEQ applies the NEQ predicate on the "flash_duration_self" field. func FlashDurationSelfNEQ(v float32) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldFlashDurationSelf), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldFlashDurationSelf, v)) } // FlashDurationSelfIn applies the In predicate on the "flash_duration_self" field. func FlashDurationSelfIn(vs ...float32) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldFlashDurationSelf), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldFlashDurationSelf, vs...)) } // FlashDurationSelfNotIn applies the NotIn predicate on the "flash_duration_self" field. func FlashDurationSelfNotIn(vs ...float32) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldFlashDurationSelf), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldFlashDurationSelf, vs...)) } // FlashDurationSelfGT applies the GT predicate on the "flash_duration_self" field. func FlashDurationSelfGT(v float32) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldFlashDurationSelf), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldFlashDurationSelf, v)) } // FlashDurationSelfGTE applies the GTE predicate on the "flash_duration_self" field. func FlashDurationSelfGTE(v float32) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldFlashDurationSelf), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldFlashDurationSelf, v)) } // FlashDurationSelfLT applies the LT predicate on the "flash_duration_self" field. func FlashDurationSelfLT(v float32) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldFlashDurationSelf), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldFlashDurationSelf, v)) } // FlashDurationSelfLTE applies the LTE predicate on the "flash_duration_self" field. func FlashDurationSelfLTE(v float32) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldFlashDurationSelf), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldFlashDurationSelf, v)) } // FlashDurationSelfIsNil applies the IsNil predicate on the "flash_duration_self" field. func FlashDurationSelfIsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldFlashDurationSelf))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldFlashDurationSelf)) } // FlashDurationSelfNotNil applies the NotNil predicate on the "flash_duration_self" field. func FlashDurationSelfNotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldFlashDurationSelf))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldFlashDurationSelf)) } // FlashDurationTeamEQ applies the EQ predicate on the "flash_duration_team" field. func FlashDurationTeamEQ(v float32) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldFlashDurationTeam), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldFlashDurationTeam, v)) } // FlashDurationTeamNEQ applies the NEQ predicate on the "flash_duration_team" field. func FlashDurationTeamNEQ(v float32) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldFlashDurationTeam), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldFlashDurationTeam, v)) } // FlashDurationTeamIn applies the In predicate on the "flash_duration_team" field. func FlashDurationTeamIn(vs ...float32) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldFlashDurationTeam), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldFlashDurationTeam, vs...)) } // FlashDurationTeamNotIn applies the NotIn predicate on the "flash_duration_team" field. func FlashDurationTeamNotIn(vs ...float32) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldFlashDurationTeam), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldFlashDurationTeam, vs...)) } // FlashDurationTeamGT applies the GT predicate on the "flash_duration_team" field. func FlashDurationTeamGT(v float32) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldFlashDurationTeam), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldFlashDurationTeam, v)) } // FlashDurationTeamGTE applies the GTE predicate on the "flash_duration_team" field. func FlashDurationTeamGTE(v float32) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldFlashDurationTeam), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldFlashDurationTeam, v)) } // FlashDurationTeamLT applies the LT predicate on the "flash_duration_team" field. func FlashDurationTeamLT(v float32) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldFlashDurationTeam), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldFlashDurationTeam, v)) } // FlashDurationTeamLTE applies the LTE predicate on the "flash_duration_team" field. func FlashDurationTeamLTE(v float32) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldFlashDurationTeam), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldFlashDurationTeam, v)) } // FlashDurationTeamIsNil applies the IsNil predicate on the "flash_duration_team" field. func FlashDurationTeamIsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldFlashDurationTeam))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldFlashDurationTeam)) } // FlashDurationTeamNotNil applies the NotNil predicate on the "flash_duration_team" field. func FlashDurationTeamNotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldFlashDurationTeam))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldFlashDurationTeam)) } // FlashDurationEnemyEQ applies the EQ predicate on the "flash_duration_enemy" field. func FlashDurationEnemyEQ(v float32) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldFlashDurationEnemy), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldFlashDurationEnemy, v)) } // FlashDurationEnemyNEQ applies the NEQ predicate on the "flash_duration_enemy" field. func FlashDurationEnemyNEQ(v float32) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldFlashDurationEnemy), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldFlashDurationEnemy, v)) } // FlashDurationEnemyIn applies the In predicate on the "flash_duration_enemy" field. func FlashDurationEnemyIn(vs ...float32) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldFlashDurationEnemy), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldFlashDurationEnemy, vs...)) } // FlashDurationEnemyNotIn applies the NotIn predicate on the "flash_duration_enemy" field. func FlashDurationEnemyNotIn(vs ...float32) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldFlashDurationEnemy), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldFlashDurationEnemy, vs...)) } // FlashDurationEnemyGT applies the GT predicate on the "flash_duration_enemy" field. func FlashDurationEnemyGT(v float32) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldFlashDurationEnemy), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldFlashDurationEnemy, v)) } // FlashDurationEnemyGTE applies the GTE predicate on the "flash_duration_enemy" field. func FlashDurationEnemyGTE(v float32) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldFlashDurationEnemy), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldFlashDurationEnemy, v)) } // FlashDurationEnemyLT applies the LT predicate on the "flash_duration_enemy" field. func FlashDurationEnemyLT(v float32) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldFlashDurationEnemy), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldFlashDurationEnemy, v)) } // FlashDurationEnemyLTE applies the LTE predicate on the "flash_duration_enemy" field. func FlashDurationEnemyLTE(v float32) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldFlashDurationEnemy), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldFlashDurationEnemy, v)) } // FlashDurationEnemyIsNil applies the IsNil predicate on the "flash_duration_enemy" field. func FlashDurationEnemyIsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldFlashDurationEnemy))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldFlashDurationEnemy)) } // FlashDurationEnemyNotNil applies the NotNil predicate on the "flash_duration_enemy" field. func FlashDurationEnemyNotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldFlashDurationEnemy))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldFlashDurationEnemy)) } // FlashTotalSelfEQ applies the EQ predicate on the "flash_total_self" field. func FlashTotalSelfEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldFlashTotalSelf), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldFlashTotalSelf, v)) } // FlashTotalSelfNEQ applies the NEQ predicate on the "flash_total_self" field. func FlashTotalSelfNEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldFlashTotalSelf), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldFlashTotalSelf, v)) } // FlashTotalSelfIn applies the In predicate on the "flash_total_self" field. func FlashTotalSelfIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldFlashTotalSelf), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldFlashTotalSelf, vs...)) } // FlashTotalSelfNotIn applies the NotIn predicate on the "flash_total_self" field. func FlashTotalSelfNotIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldFlashTotalSelf), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldFlashTotalSelf, vs...)) } // FlashTotalSelfGT applies the GT predicate on the "flash_total_self" field. func FlashTotalSelfGT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldFlashTotalSelf), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldFlashTotalSelf, v)) } // FlashTotalSelfGTE applies the GTE predicate on the "flash_total_self" field. func FlashTotalSelfGTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldFlashTotalSelf), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldFlashTotalSelf, v)) } // FlashTotalSelfLT applies the LT predicate on the "flash_total_self" field. func FlashTotalSelfLT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldFlashTotalSelf), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldFlashTotalSelf, v)) } // FlashTotalSelfLTE applies the LTE predicate on the "flash_total_self" field. func FlashTotalSelfLTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldFlashTotalSelf), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldFlashTotalSelf, v)) } // FlashTotalSelfIsNil applies the IsNil predicate on the "flash_total_self" field. func FlashTotalSelfIsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldFlashTotalSelf))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldFlashTotalSelf)) } // FlashTotalSelfNotNil applies the NotNil predicate on the "flash_total_self" field. func FlashTotalSelfNotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldFlashTotalSelf))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldFlashTotalSelf)) } // FlashTotalTeamEQ applies the EQ predicate on the "flash_total_team" field. func FlashTotalTeamEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldFlashTotalTeam), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldFlashTotalTeam, v)) } // FlashTotalTeamNEQ applies the NEQ predicate on the "flash_total_team" field. func FlashTotalTeamNEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldFlashTotalTeam), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldFlashTotalTeam, v)) } // FlashTotalTeamIn applies the In predicate on the "flash_total_team" field. func FlashTotalTeamIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldFlashTotalTeam), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldFlashTotalTeam, vs...)) } // FlashTotalTeamNotIn applies the NotIn predicate on the "flash_total_team" field. func FlashTotalTeamNotIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldFlashTotalTeam), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldFlashTotalTeam, vs...)) } // FlashTotalTeamGT applies the GT predicate on the "flash_total_team" field. func FlashTotalTeamGT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldFlashTotalTeam), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldFlashTotalTeam, v)) } // FlashTotalTeamGTE applies the GTE predicate on the "flash_total_team" field. func FlashTotalTeamGTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldFlashTotalTeam), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldFlashTotalTeam, v)) } // FlashTotalTeamLT applies the LT predicate on the "flash_total_team" field. func FlashTotalTeamLT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldFlashTotalTeam), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldFlashTotalTeam, v)) } // FlashTotalTeamLTE applies the LTE predicate on the "flash_total_team" field. func FlashTotalTeamLTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldFlashTotalTeam), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldFlashTotalTeam, v)) } // FlashTotalTeamIsNil applies the IsNil predicate on the "flash_total_team" field. func FlashTotalTeamIsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldFlashTotalTeam))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldFlashTotalTeam)) } // FlashTotalTeamNotNil applies the NotNil predicate on the "flash_total_team" field. func FlashTotalTeamNotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldFlashTotalTeam))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldFlashTotalTeam)) } // FlashTotalEnemyEQ applies the EQ predicate on the "flash_total_enemy" field. func FlashTotalEnemyEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldFlashTotalEnemy), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldFlashTotalEnemy, v)) } // FlashTotalEnemyNEQ applies the NEQ predicate on the "flash_total_enemy" field. func FlashTotalEnemyNEQ(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldFlashTotalEnemy), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldFlashTotalEnemy, v)) } // FlashTotalEnemyIn applies the In predicate on the "flash_total_enemy" field. func FlashTotalEnemyIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldFlashTotalEnemy), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldFlashTotalEnemy, vs...)) } // FlashTotalEnemyNotIn applies the NotIn predicate on the "flash_total_enemy" field. func FlashTotalEnemyNotIn(vs ...uint) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldFlashTotalEnemy), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldFlashTotalEnemy, vs...)) } // FlashTotalEnemyGT applies the GT predicate on the "flash_total_enemy" field. func FlashTotalEnemyGT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldFlashTotalEnemy), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldFlashTotalEnemy, v)) } // FlashTotalEnemyGTE applies the GTE predicate on the "flash_total_enemy" field. func FlashTotalEnemyGTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldFlashTotalEnemy), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldFlashTotalEnemy, v)) } // FlashTotalEnemyLT applies the LT predicate on the "flash_total_enemy" field. func FlashTotalEnemyLT(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldFlashTotalEnemy), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldFlashTotalEnemy, v)) } // FlashTotalEnemyLTE applies the LTE predicate on the "flash_total_enemy" field. func FlashTotalEnemyLTE(v uint) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldFlashTotalEnemy), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldFlashTotalEnemy, v)) } // FlashTotalEnemyIsNil applies the IsNil predicate on the "flash_total_enemy" field. func FlashTotalEnemyIsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldFlashTotalEnemy))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldFlashTotalEnemy)) } // FlashTotalEnemyNotNil applies the NotNil predicate on the "flash_total_enemy" field. func FlashTotalEnemyNotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldFlashTotalEnemy))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldFlashTotalEnemy)) } // MatchStatsEQ applies the EQ predicate on the "match_stats" field. func MatchStatsEQ(v uint64) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldMatchStats), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldMatchStats, v)) } // MatchStatsNEQ applies the NEQ predicate on the "match_stats" field. func MatchStatsNEQ(v uint64) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldMatchStats), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldMatchStats, v)) } // MatchStatsIn applies the In predicate on the "match_stats" field. func MatchStatsIn(vs ...uint64) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldMatchStats), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldMatchStats, vs...)) } // MatchStatsNotIn applies the NotIn predicate on the "match_stats" field. func MatchStatsNotIn(vs ...uint64) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldMatchStats), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldMatchStats, vs...)) } // MatchStatsIsNil applies the IsNil predicate on the "match_stats" field. func MatchStatsIsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldMatchStats))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldMatchStats)) } // MatchStatsNotNil applies the NotNil predicate on the "match_stats" field. func MatchStatsNotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldMatchStats))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldMatchStats)) } // PlayerStatsEQ applies the EQ predicate on the "player_stats" field. func PlayerStatsEQ(v uint64) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldPlayerStats), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldPlayerStats, v)) } // PlayerStatsNEQ applies the NEQ predicate on the "player_stats" field. func PlayerStatsNEQ(v uint64) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldPlayerStats), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldPlayerStats, v)) } // PlayerStatsIn applies the In predicate on the "player_stats" field. func PlayerStatsIn(vs ...uint64) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldPlayerStats), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldPlayerStats, vs...)) } // PlayerStatsNotIn applies the NotIn predicate on the "player_stats" field. func PlayerStatsNotIn(vs ...uint64) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldPlayerStats), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldPlayerStats, vs...)) } // PlayerStatsIsNil applies the IsNil predicate on the "player_stats" field. func PlayerStatsIsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldPlayerStats))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldPlayerStats)) } // PlayerStatsNotNil applies the NotNil predicate on the "player_stats" field. func PlayerStatsNotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldPlayerStats))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldPlayerStats)) } // FlashAssistsEQ applies the EQ predicate on the "flash_assists" field. func FlashAssistsEQ(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldFlashAssists), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldFlashAssists, v)) } // FlashAssistsNEQ applies the NEQ predicate on the "flash_assists" field. func FlashAssistsNEQ(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldFlashAssists), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldFlashAssists, v)) } // FlashAssistsIn applies the In predicate on the "flash_assists" field. func FlashAssistsIn(vs ...int) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldFlashAssists), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldFlashAssists, vs...)) } // FlashAssistsNotIn applies the NotIn predicate on the "flash_assists" field. func FlashAssistsNotIn(vs ...int) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldFlashAssists), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldFlashAssists, vs...)) } // FlashAssistsGT applies the GT predicate on the "flash_assists" field. func FlashAssistsGT(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldFlashAssists), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldFlashAssists, v)) } // FlashAssistsGTE applies the GTE predicate on the "flash_assists" field. func FlashAssistsGTE(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldFlashAssists), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldFlashAssists, v)) } // FlashAssistsLT applies the LT predicate on the "flash_assists" field. func FlashAssistsLT(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldFlashAssists), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldFlashAssists, v)) } // FlashAssistsLTE applies the LTE predicate on the "flash_assists" field. func FlashAssistsLTE(v int) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldFlashAssists), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldFlashAssists, v)) } // FlashAssistsIsNil applies the IsNil predicate on the "flash_assists" field. func FlashAssistsIsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldFlashAssists))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldFlashAssists)) } // FlashAssistsNotNil applies the NotNil predicate on the "flash_assists" field. func FlashAssistsNotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldFlashAssists))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldFlashAssists)) } // AvgPingEQ applies the EQ predicate on the "avg_ping" field. func AvgPingEQ(v float64) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldAvgPing), v)) - }) + return predicate.MatchPlayer(sql.FieldEQ(FieldAvgPing, v)) } // AvgPingNEQ applies the NEQ predicate on the "avg_ping" field. func AvgPingNEQ(v float64) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldAvgPing), v)) - }) + return predicate.MatchPlayer(sql.FieldNEQ(FieldAvgPing, v)) } // AvgPingIn applies the In predicate on the "avg_ping" field. func AvgPingIn(vs ...float64) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldAvgPing), v...)) - }) + return predicate.MatchPlayer(sql.FieldIn(FieldAvgPing, vs...)) } // AvgPingNotIn applies the NotIn predicate on the "avg_ping" field. func AvgPingNotIn(vs ...float64) predicate.MatchPlayer { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldAvgPing), v...)) - }) + return predicate.MatchPlayer(sql.FieldNotIn(FieldAvgPing, vs...)) } // AvgPingGT applies the GT predicate on the "avg_ping" field. func AvgPingGT(v float64) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldAvgPing), v)) - }) + return predicate.MatchPlayer(sql.FieldGT(FieldAvgPing, v)) } // AvgPingGTE applies the GTE predicate on the "avg_ping" field. func AvgPingGTE(v float64) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldAvgPing), v)) - }) + return predicate.MatchPlayer(sql.FieldGTE(FieldAvgPing, v)) } // AvgPingLT applies the LT predicate on the "avg_ping" field. func AvgPingLT(v float64) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldAvgPing), v)) - }) + return predicate.MatchPlayer(sql.FieldLT(FieldAvgPing, v)) } // AvgPingLTE applies the LTE predicate on the "avg_ping" field. func AvgPingLTE(v float64) predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldAvgPing), v)) - }) + return predicate.MatchPlayer(sql.FieldLTE(FieldAvgPing, v)) } // AvgPingIsNil applies the IsNil predicate on the "avg_ping" field. func AvgPingIsNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldAvgPing))) - }) + return predicate.MatchPlayer(sql.FieldIsNull(FieldAvgPing)) } // AvgPingNotNil applies the NotNil predicate on the "avg_ping" field. func AvgPingNotNil() predicate.MatchPlayer { - return predicate.MatchPlayer(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldAvgPing))) - }) + return predicate.MatchPlayer(sql.FieldNotNull(FieldAvgPing)) } // HasMatches applies the HasEdge predicate on the "matches" edge. @@ -2735,7 +1763,6 @@ func HasMatches() predicate.MatchPlayer { return predicate.MatchPlayer(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(MatchesTable, FieldID), sqlgraph.Edge(sqlgraph.M2O, true, MatchesTable, MatchesColumn), ) sqlgraph.HasNeighbors(s, step) @@ -2763,7 +1790,6 @@ func HasPlayers() predicate.MatchPlayer { return predicate.MatchPlayer(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(PlayersTable, FieldID), sqlgraph.Edge(sqlgraph.M2O, true, PlayersTable, PlayersColumn), ) sqlgraph.HasNeighbors(s, step) @@ -2791,7 +1817,6 @@ func HasWeaponStats() predicate.MatchPlayer { return predicate.MatchPlayer(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(WeaponStatsTable, FieldID), sqlgraph.Edge(sqlgraph.O2M, false, WeaponStatsTable, WeaponStatsColumn), ) sqlgraph.HasNeighbors(s, step) @@ -2819,7 +1844,6 @@ func HasRoundStats() predicate.MatchPlayer { return predicate.MatchPlayer(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(RoundStatsTable, FieldID), sqlgraph.Edge(sqlgraph.O2M, false, RoundStatsTable, RoundStatsColumn), ) sqlgraph.HasNeighbors(s, step) @@ -2847,7 +1871,6 @@ func HasSpray() predicate.MatchPlayer { return predicate.MatchPlayer(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(SprayTable, FieldID), sqlgraph.Edge(sqlgraph.O2M, false, SprayTable, SprayColumn), ) sqlgraph.HasNeighbors(s, step) @@ -2875,7 +1898,6 @@ func HasMessages() predicate.MatchPlayer { return predicate.MatchPlayer(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(MessagesTable, FieldID), sqlgraph.Edge(sqlgraph.O2M, false, MessagesTable, MessagesColumn), ) sqlgraph.HasNeighbors(s, step) diff --git a/ent/matchplayer_create.go b/ent/matchplayer_create.go index 98a0b6b..837adab 100644 --- a/ent/matchplayer_create.go +++ b/ent/matchplayer_create.go @@ -536,49 +536,7 @@ func (mpc *MatchPlayerCreate) Mutation() *MatchPlayerMutation { // Save creates the MatchPlayer in the database. func (mpc *MatchPlayerCreate) Save(ctx context.Context) (*MatchPlayer, error) { - var ( - err error - node *MatchPlayer - ) - if len(mpc.hooks) == 0 { - if err = mpc.check(); err != nil { - return nil, err - } - node, err = mpc.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*MatchPlayerMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err = mpc.check(); err != nil { - return nil, err - } - mpc.mutation = mutation - if node, err = mpc.sqlSave(ctx); err != nil { - return nil, err - } - mutation.id = &node.ID - mutation.done = true - return node, err - }) - for i := len(mpc.hooks) - 1; i >= 0; i-- { - if mpc.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = mpc.hooks[i](mut) - } - v, err := mut.Mutate(ctx, mpc.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*MatchPlayer) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from MatchPlayerMutation", v) - } - node = nv - } - return node, err + return withHooks[*MatchPlayer, MatchPlayerMutation](ctx, mpc.sqlSave, mpc.mutation, mpc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -635,6 +593,9 @@ func (mpc *MatchPlayerCreate) check() error { } func (mpc *MatchPlayerCreate) sqlSave(ctx context.Context) (*MatchPlayer, error) { + if err := mpc.check(); err != nil { + return nil, err + } _node, _spec := mpc.createSpec() if err := sqlgraph.CreateNode(ctx, mpc.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { @@ -644,19 +605,15 @@ func (mpc *MatchPlayerCreate) sqlSave(ctx context.Context) (*MatchPlayer, error) } id := _spec.ID.Value.(int64) _node.ID = int(id) + mpc.mutation.id = &_node.ID + mpc.mutation.done = true return _node, nil } func (mpc *MatchPlayerCreate) createSpec() (*MatchPlayer, *sqlgraph.CreateSpec) { var ( _node = &MatchPlayer{config: mpc.config} - _spec = &sqlgraph.CreateSpec{ - Table: matchplayer.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: matchplayer.FieldID, - }, - } + _spec = sqlgraph.NewCreateSpec(matchplayer.Table, sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt)) ) if value, ok := mpc.mutation.TeamID(); ok { _spec.SetField(matchplayer.FieldTeamID, field.TypeInt, value) diff --git a/ent/matchplayer_delete.go b/ent/matchplayer_delete.go index 1a6bcbf..ed5dc21 100644 --- a/ent/matchplayer_delete.go +++ b/ent/matchplayer_delete.go @@ -4,7 +4,6 @@ package ent import ( "context" - "fmt" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -28,34 +27,7 @@ func (mpd *MatchPlayerDelete) Where(ps ...predicate.MatchPlayer) *MatchPlayerDel // Exec executes the deletion query and returns how many vertices were deleted. func (mpd *MatchPlayerDelete) Exec(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(mpd.hooks) == 0 { - affected, err = mpd.sqlExec(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*MatchPlayerMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - mpd.mutation = mutation - affected, err = mpd.sqlExec(ctx) - mutation.done = true - return affected, err - }) - for i := len(mpd.hooks) - 1; i >= 0; i-- { - if mpd.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = mpd.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, mpd.mutation); err != nil { - return 0, err - } - } - return affected, err + return withHooks[int, MatchPlayerMutation](ctx, mpd.sqlExec, mpd.mutation, mpd.hooks) } // ExecX is like Exec, but panics if an error occurs. @@ -68,15 +40,7 @@ func (mpd *MatchPlayerDelete) ExecX(ctx context.Context) int { } func (mpd *MatchPlayerDelete) sqlExec(ctx context.Context) (int, error) { - _spec := &sqlgraph.DeleteSpec{ - Node: &sqlgraph.NodeSpec{ - Table: matchplayer.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: matchplayer.FieldID, - }, - }, - } + _spec := sqlgraph.NewDeleteSpec(matchplayer.Table, sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt)) if ps := mpd.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -88,6 +52,7 @@ func (mpd *MatchPlayerDelete) sqlExec(ctx context.Context) (int, error) { if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } + mpd.mutation.done = true return affected, err } @@ -96,6 +61,12 @@ type MatchPlayerDeleteOne struct { mpd *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 +} + // Exec executes the deletion query. func (mpdo *MatchPlayerDeleteOne) Exec(ctx context.Context) error { n, err := mpdo.mpd.Exec(ctx) @@ -111,5 +82,7 @@ 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) { - mpdo.mpd.ExecX(ctx) + if err := mpdo.Exec(ctx); err != nil { + panic(err) + } } diff --git a/ent/matchplayer_query.go b/ent/matchplayer_query.go index 4b1db27..0240425 100644 --- a/ent/matchplayer_query.go +++ b/ent/matchplayer_query.go @@ -24,11 +24,9 @@ import ( // MatchPlayerQuery is the builder for querying MatchPlayer entities. type MatchPlayerQuery struct { config - limit *int - offset *int - unique *bool + ctx *QueryContext order []OrderFunc - fields []string + inters []Interceptor predicates []predicate.MatchPlayer withMatches *MatchQuery withPlayers *PlayerQuery @@ -48,26 +46,26 @@ func (mpq *MatchPlayerQuery) Where(ps ...predicate.MatchPlayer) *MatchPlayerQuer return mpq } -// Limit adds a limit step to the query. +// Limit the number of records to be returned by this query. func (mpq *MatchPlayerQuery) Limit(limit int) *MatchPlayerQuery { - mpq.limit = &limit + mpq.ctx.Limit = &limit return mpq } -// Offset adds an offset step to the query. +// Offset to start from. func (mpq *MatchPlayerQuery) Offset(offset int) *MatchPlayerQuery { - mpq.offset = &offset + mpq.ctx.Offset = &offset return mpq } // 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.unique = &unique + mpq.ctx.Unique = &unique return mpq } -// Order adds an order step to the query. +// Order specifies how the records should be ordered. func (mpq *MatchPlayerQuery) Order(o ...OrderFunc) *MatchPlayerQuery { mpq.order = append(mpq.order, o...) return mpq @@ -75,7 +73,7 @@ func (mpq *MatchPlayerQuery) Order(o ...OrderFunc) *MatchPlayerQuery { // QueryMatches chains the current query on the "matches" edge. func (mpq *MatchPlayerQuery) QueryMatches() *MatchQuery { - query := &MatchQuery{config: mpq.config} + query := (&MatchClient{config: mpq.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := mpq.prepareQuery(ctx); err != nil { return nil, err @@ -97,7 +95,7 @@ func (mpq *MatchPlayerQuery) QueryMatches() *MatchQuery { // QueryPlayers chains the current query on the "players" edge. func (mpq *MatchPlayerQuery) QueryPlayers() *PlayerQuery { - query := &PlayerQuery{config: mpq.config} + query := (&PlayerClient{config: mpq.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := mpq.prepareQuery(ctx); err != nil { return nil, err @@ -119,7 +117,7 @@ func (mpq *MatchPlayerQuery) QueryPlayers() *PlayerQuery { // QueryWeaponStats chains the current query on the "weapon_stats" edge. func (mpq *MatchPlayerQuery) QueryWeaponStats() *WeaponQuery { - query := &WeaponQuery{config: mpq.config} + query := (&WeaponClient{config: mpq.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := mpq.prepareQuery(ctx); err != nil { return nil, err @@ -141,7 +139,7 @@ func (mpq *MatchPlayerQuery) QueryWeaponStats() *WeaponQuery { // QueryRoundStats chains the current query on the "round_stats" edge. func (mpq *MatchPlayerQuery) QueryRoundStats() *RoundStatsQuery { - query := &RoundStatsQuery{config: mpq.config} + query := (&RoundStatsClient{config: mpq.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := mpq.prepareQuery(ctx); err != nil { return nil, err @@ -163,7 +161,7 @@ func (mpq *MatchPlayerQuery) QueryRoundStats() *RoundStatsQuery { // QuerySpray chains the current query on the "spray" edge. func (mpq *MatchPlayerQuery) QuerySpray() *SprayQuery { - query := &SprayQuery{config: mpq.config} + query := (&SprayClient{config: mpq.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := mpq.prepareQuery(ctx); err != nil { return nil, err @@ -185,7 +183,7 @@ func (mpq *MatchPlayerQuery) QuerySpray() *SprayQuery { // QueryMessages chains the current query on the "messages" edge. func (mpq *MatchPlayerQuery) QueryMessages() *MessagesQuery { - query := &MessagesQuery{config: mpq.config} + query := (&MessagesClient{config: mpq.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := mpq.prepareQuery(ctx); err != nil { return nil, err @@ -208,7 +206,7 @@ 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(ctx) + nodes, err := mpq.Limit(1).All(setContextOp(ctx, mpq.ctx, "First")) if err != nil { return nil, err } @@ -231,7 +229,7 @@ func (mpq *MatchPlayerQuery) FirstX(ctx context.Context) *MatchPlayer { // Returns a *NotFoundError when no MatchPlayer ID was found. func (mpq *MatchPlayerQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = mpq.Limit(1).IDs(ctx); err != nil { + if ids, err = mpq.Limit(1).IDs(setContextOp(ctx, mpq.ctx, "FirstID")); err != nil { return } if len(ids) == 0 { @@ -254,7 +252,7 @@ func (mpq *MatchPlayerQuery) FirstIDX(ctx context.Context) int { // 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(ctx) + nodes, err := mpq.Limit(2).All(setContextOp(ctx, mpq.ctx, "Only")) if err != nil { return nil, err } @@ -282,7 +280,7 @@ func (mpq *MatchPlayerQuery) OnlyX(ctx context.Context) *MatchPlayer { // Returns a *NotFoundError when no entities are found. func (mpq *MatchPlayerQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = mpq.Limit(2).IDs(ctx); err != nil { + if ids, err = mpq.Limit(2).IDs(setContextOp(ctx, mpq.ctx, "OnlyID")); err != nil { return } switch len(ids) { @@ -307,10 +305,12 @@ 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 { return nil, err } - return mpq.sqlAll(ctx) + qr := querierAll[[]*MatchPlayer, *MatchPlayerQuery]() + return withInterceptors[[]*MatchPlayer](ctx, mpq, qr, mpq.inters) } // AllX is like All, but panics if an error occurs. @@ -323,9 +323,12 @@ 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) ([]int, error) { - var ids []int - if err := mpq.Select(matchplayer.FieldID).Scan(ctx, &ids); err != nil { +func (mpq *MatchPlayerQuery) IDs(ctx context.Context) (ids []int, err error) { + if mpq.ctx.Unique == nil && mpq.path != nil { + mpq.Unique(true) + } + ctx = setContextOp(ctx, mpq.ctx, "IDs") + if err = mpq.Select(matchplayer.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil @@ -342,10 +345,11 @@ 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 { return 0, err } - return mpq.sqlCount(ctx) + return withInterceptors[int](ctx, mpq, querierCount[*MatchPlayerQuery](), mpq.inters) } // CountX is like Count, but panics if an error occurs. @@ -359,10 +363,15 @@ 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) { - if err := mpq.prepareQuery(ctx); err != nil { - return false, err + ctx = setContextOp(ctx, mpq.ctx, "Exist") + switch _, err := mpq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil } - return mpq.sqlExist(ctx) } // ExistX is like Exist, but panics if an error occurs. @@ -382,9 +391,9 @@ func (mpq *MatchPlayerQuery) Clone() *MatchPlayerQuery { } return &MatchPlayerQuery{ config: mpq.config, - limit: mpq.limit, - offset: mpq.offset, + ctx: mpq.ctx.Clone(), order: append([]OrderFunc{}, mpq.order...), + inters: append([]Interceptor{}, mpq.inters...), predicates: append([]predicate.MatchPlayer{}, mpq.predicates...), withMatches: mpq.withMatches.Clone(), withPlayers: mpq.withPlayers.Clone(), @@ -393,16 +402,15 @@ func (mpq *MatchPlayerQuery) Clone() *MatchPlayerQuery { withSpray: mpq.withSpray.Clone(), withMessages: mpq.withMessages.Clone(), // clone intermediate query. - sql: mpq.sql.Clone(), - path: mpq.path, - unique: mpq.unique, + sql: mpq.sql.Clone(), + path: mpq.path, } } // 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 := &MatchQuery{config: mpq.config} + query := (&MatchClient{config: mpq.config}).Query() for _, opt := range opts { opt(query) } @@ -413,7 +421,7 @@ func (mpq *MatchPlayerQuery) WithMatches(opts ...func(*MatchQuery)) *MatchPlayer // 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 := &PlayerQuery{config: mpq.config} + query := (&PlayerClient{config: mpq.config}).Query() for _, opt := range opts { opt(query) } @@ -424,7 +432,7 @@ func (mpq *MatchPlayerQuery) WithPlayers(opts ...func(*PlayerQuery)) *MatchPlaye // 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 := &WeaponQuery{config: mpq.config} + query := (&WeaponClient{config: mpq.config}).Query() for _, opt := range opts { opt(query) } @@ -435,7 +443,7 @@ func (mpq *MatchPlayerQuery) WithWeaponStats(opts ...func(*WeaponQuery)) *MatchP // 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 := &RoundStatsQuery{config: mpq.config} + query := (&RoundStatsClient{config: mpq.config}).Query() for _, opt := range opts { opt(query) } @@ -446,7 +454,7 @@ func (mpq *MatchPlayerQuery) WithRoundStats(opts ...func(*RoundStatsQuery)) *Mat // 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 := &SprayQuery{config: mpq.config} + query := (&SprayClient{config: mpq.config}).Query() for _, opt := range opts { opt(query) } @@ -457,7 +465,7 @@ func (mpq *MatchPlayerQuery) WithSpray(opts ...func(*SprayQuery)) *MatchPlayerQu // 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 := &MessagesQuery{config: mpq.config} + query := (&MessagesClient{config: mpq.config}).Query() for _, opt := range opts { opt(query) } @@ -480,16 +488,11 @@ func (mpq *MatchPlayerQuery) WithMessages(opts ...func(*MessagesQuery)) *MatchPl // Aggregate(ent.Count()). // Scan(ctx, &v) func (mpq *MatchPlayerQuery) GroupBy(field string, fields ...string) *MatchPlayerGroupBy { - grbuild := &MatchPlayerGroupBy{config: mpq.config} - grbuild.fields = append([]string{field}, fields...) - grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { - if err := mpq.prepareQuery(ctx); err != nil { - return nil, err - } - return mpq.sqlQuery(ctx), nil - } + mpq.ctx.Fields = append([]string{field}, fields...) + grbuild := &MatchPlayerGroupBy{build: mpq} + grbuild.flds = &mpq.ctx.Fields grbuild.label = matchplayer.Label - grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan + grbuild.scan = grbuild.Scan return grbuild } @@ -506,11 +509,11 @@ func (mpq *MatchPlayerQuery) GroupBy(field string, fields ...string) *MatchPlaye // Select(matchplayer.FieldTeamID). // Scan(ctx, &v) func (mpq *MatchPlayerQuery) Select(fields ...string) *MatchPlayerSelect { - mpq.fields = append(mpq.fields, fields...) - selbuild := &MatchPlayerSelect{MatchPlayerQuery: mpq} - selbuild.label = matchplayer.Label - selbuild.flds, selbuild.scan = &mpq.fields, selbuild.Scan - return selbuild + mpq.ctx.Fields = append(mpq.ctx.Fields, fields...) + sbuild := &MatchPlayerSelect{MatchPlayerQuery: mpq} + sbuild.label = matchplayer.Label + sbuild.flds, sbuild.scan = &mpq.ctx.Fields, sbuild.Scan + return sbuild } // Aggregate returns a MatchPlayerSelect configured with the given aggregations. @@ -519,7 +522,17 @@ func (mpq *MatchPlayerQuery) Aggregate(fns ...AggregateFunc) *MatchPlayerSelect } func (mpq *MatchPlayerQuery) prepareQuery(ctx context.Context) error { - for _, f := range mpq.fields { + for _, inter := range mpq.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 { + return err + } + } + } + for _, f := range mpq.ctx.Fields { if !matchplayer.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } @@ -621,6 +634,9 @@ func (mpq *MatchPlayerQuery) loadMatches(ctx context.Context, query *MatchQuery, } nodeids[fk] = append(nodeids[fk], nodes[i]) } + if len(ids) == 0 { + return nil + } query.Where(match.IDIn(ids...)) neighbors, err := query.All(ctx) if err != nil { @@ -647,6 +663,9 @@ func (mpq *MatchPlayerQuery) loadPlayers(ctx context.Context, query *PlayerQuery } nodeids[fk] = append(nodeids[fk], nodes[i]) } + if len(ids) == 0 { + return nil + } query.Where(player.IDIn(ids...)) neighbors, err := query.All(ctx) if err != nil { @@ -793,41 +812,22 @@ func (mpq *MatchPlayerQuery) sqlCount(ctx context.Context) (int, error) { if len(mpq.modifiers) > 0 { _spec.Modifiers = mpq.modifiers } - _spec.Node.Columns = mpq.fields - if len(mpq.fields) > 0 { - _spec.Unique = mpq.unique != nil && *mpq.unique + _spec.Node.Columns = mpq.ctx.Fields + if len(mpq.ctx.Fields) > 0 { + _spec.Unique = mpq.ctx.Unique != nil && *mpq.ctx.Unique } return sqlgraph.CountNodes(ctx, mpq.driver, _spec) } -func (mpq *MatchPlayerQuery) sqlExist(ctx context.Context) (bool, error) { - switch _, err := mpq.FirstID(ctx); { - case IsNotFound(err): - return false, nil - case err != nil: - return false, fmt.Errorf("ent: check existence: %w", err) - default: - return true, nil - } -} - func (mpq *MatchPlayerQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: matchplayer.Table, - Columns: matchplayer.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: matchplayer.FieldID, - }, - }, - From: mpq.sql, - Unique: true, - } - if unique := mpq.unique; unique != nil { + _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.Unique = *unique + } else if mpq.path != nil { + _spec.Unique = true } - if fields := mpq.fields; len(fields) > 0 { + if fields := mpq.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 { @@ -843,10 +843,10 @@ func (mpq *MatchPlayerQuery) querySpec() *sqlgraph.QuerySpec { } } } - if limit := mpq.limit; limit != nil { + if limit := mpq.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := mpq.offset; offset != nil { + if offset := mpq.ctx.Offset; offset != nil { _spec.Offset = *offset } if ps := mpq.order; len(ps) > 0 { @@ -862,7 +862,7 @@ func (mpq *MatchPlayerQuery) querySpec() *sqlgraph.QuerySpec { func (mpq *MatchPlayerQuery) sqlQuery(ctx context.Context) *sql.Selector { builder := sql.Dialect(mpq.driver.Dialect()) t1 := builder.Table(matchplayer.Table) - columns := mpq.fields + columns := mpq.ctx.Fields if len(columns) == 0 { columns = matchplayer.Columns } @@ -871,7 +871,7 @@ func (mpq *MatchPlayerQuery) sqlQuery(ctx context.Context) *sql.Selector { selector = mpq.sql selector.Select(selector.Columns(columns...)...) } - if mpq.unique != nil && *mpq.unique { + if mpq.ctx.Unique != nil && *mpq.ctx.Unique { selector.Distinct() } for _, m := range mpq.modifiers { @@ -883,12 +883,12 @@ func (mpq *MatchPlayerQuery) sqlQuery(ctx context.Context) *sql.Selector { for _, p := range mpq.order { p(selector) } - if offset := mpq.offset; offset != nil { + if offset := mpq.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.limit; limit != nil { + if limit := mpq.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector @@ -902,13 +902,8 @@ func (mpq *MatchPlayerQuery) Modify(modifiers ...func(s *sql.Selector)) *MatchPl // MatchPlayerGroupBy is the group-by builder for MatchPlayer entities. type MatchPlayerGroupBy struct { - config selector - fields []string - fns []AggregateFunc - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) + build *MatchPlayerQuery } // Aggregate adds the given aggregation functions to the group-by query. @@ -917,58 +912,46 @@ func (mpgb *MatchPlayerGroupBy) Aggregate(fns ...AggregateFunc) *MatchPlayerGrou return mpgb } -// Scan applies the group-by query and scans the result into the given value. +// Scan applies the selector query and scans the result into the given value. func (mpgb *MatchPlayerGroupBy) Scan(ctx context.Context, v any) error { - query, err := mpgb.path(ctx) - if err != nil { + ctx = setContextOp(ctx, mpgb.build.ctx, "GroupBy") + if err := mpgb.build.prepareQuery(ctx); err != nil { return err } - mpgb.sql = query - return mpgb.sqlScan(ctx, v) + return scanWithInterceptors[*MatchPlayerQuery, *MatchPlayerGroupBy](ctx, mpgb.build, mpgb, mpgb.build.inters, v) } -func (mpgb *MatchPlayerGroupBy) sqlScan(ctx context.Context, v any) error { - for _, f := range mpgb.fields { - if !matchplayer.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} - } +func (mpgb *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 = append(aggregation, fn(selector)) } - selector := mpgb.sqlQuery() + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*mpgb.flds)+len(mpgb.fns)) + for _, f := range *mpgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*mpgb.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := mpgb.driver.Query(ctx, query, args, rows); err != nil { + if err := mpgb.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() return sql.ScanSlice(rows, v) } -func (mpgb *MatchPlayerGroupBy) sqlQuery() *sql.Selector { - selector := mpgb.sql.Select() - aggregation := make([]string, 0, len(mpgb.fns)) - for _, fn := range mpgb.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(mpgb.fields)+len(mpgb.fns)) - for _, f := range mpgb.fields { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - return selector.GroupBy(selector.Columns(mpgb.fields...)...) -} - // MatchPlayerSelect is the builder for selecting fields of MatchPlayer entities. type MatchPlayerSelect struct { *MatchPlayerQuery selector - // intermediate query (i.e. traversal path). - sql *sql.Selector } // Aggregate adds the given aggregation functions to the selector query. @@ -979,26 +962,27 @@ func (mps *MatchPlayerSelect) Aggregate(fns ...AggregateFunc) *MatchPlayerSelect // 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 { return err } - mps.sql = mps.MatchPlayerQuery.sqlQuery(ctx) - return mps.sqlScan(ctx, v) + return scanWithInterceptors[*MatchPlayerQuery, *MatchPlayerSelect](ctx, mps.MatchPlayerQuery, mps, mps.inters, v) } -func (mps *MatchPlayerSelect) sqlScan(ctx context.Context, v any) error { +func (mps *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 = append(aggregation, fn(mps.sql)) + aggregation = append(aggregation, fn(selector)) } switch n := len(*mps.selector.flds); { case n == 0 && len(aggregation) > 0: - mps.sql.Select(aggregation...) + selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: - mps.sql.AppendSelect(aggregation...) + selector.AppendSelect(aggregation...) } rows := &sql.Rows{} - query, args := mps.sql.Query() + query, args := selector.Query() if err := mps.driver.Query(ctx, query, args, rows); err != nil { return err } diff --git a/ent/matchplayer_update.go b/ent/matchplayer_update.go index 6800e28..a5b2e48 100644 --- a/ent/matchplayer_update.go +++ b/ent/matchplayer_update.go @@ -1000,40 +1000,7 @@ func (mpu *MatchPlayerUpdate) RemoveMessages(m ...*Messages) *MatchPlayerUpdate // Save executes the query and returns the number of nodes affected by the update operation. func (mpu *MatchPlayerUpdate) Save(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(mpu.hooks) == 0 { - if err = mpu.check(); err != nil { - return 0, err - } - affected, err = mpu.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*MatchPlayerMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err = mpu.check(); err != nil { - return 0, err - } - mpu.mutation = mutation - affected, err = mpu.sqlSave(ctx) - mutation.done = true - return affected, err - }) - for i := len(mpu.hooks) - 1; i >= 0; i-- { - if mpu.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = mpu.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, mpu.mutation); err != nil { - return 0, err - } - } - return affected, err + return withHooks[int, MatchPlayerMutation](ctx, mpu.sqlSave, mpu.mutation, mpu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -1075,16 +1042,10 @@ func (mpu *MatchPlayerUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *M } func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: matchplayer.Table, - Columns: matchplayer.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: matchplayer.FieldID, - }, - }, + if err := mpu.check(); err != nil { + return n, err } + _spec := sqlgraph.NewUpdateSpec(matchplayer.Table, matchplayer.Columns, sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt)) if ps := mpu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -1639,6 +1600,7 @@ func (mpu *MatchPlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } return 0, err } + mpu.mutation.done = true return n, nil } @@ -2615,6 +2577,12 @@ func (mpuo *MatchPlayerUpdateOne) RemoveMessages(m ...*Messages) *MatchPlayerUpd return mpuo.RemoveMessageIDs(ids...) } +// Where appends a list predicates to the MatchPlayerUpdate builder. +func (mpuo *MatchPlayerUpdateOne) Where(ps ...predicate.MatchPlayer) *MatchPlayerUpdateOne { + mpuo.mutation.Where(ps...) + return mpuo +} + // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. func (mpuo *MatchPlayerUpdateOne) Select(field string, fields ...string) *MatchPlayerUpdateOne { @@ -2624,46 +2592,7 @@ func (mpuo *MatchPlayerUpdateOne) Select(field string, fields ...string) *MatchP // Save executes the query and returns the updated MatchPlayer entity. func (mpuo *MatchPlayerUpdateOne) Save(ctx context.Context) (*MatchPlayer, error) { - var ( - err error - node *MatchPlayer - ) - if len(mpuo.hooks) == 0 { - if err = mpuo.check(); err != nil { - return nil, err - } - node, err = mpuo.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*MatchPlayerMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err = mpuo.check(); err != nil { - return nil, err - } - mpuo.mutation = mutation - node, err = mpuo.sqlSave(ctx) - mutation.done = true - return node, err - }) - for i := len(mpuo.hooks) - 1; i >= 0; i-- { - if mpuo.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = mpuo.hooks[i](mut) - } - v, err := mut.Mutate(ctx, mpuo.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*MatchPlayer) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from MatchPlayerMutation", v) - } - node = nv - } - return node, err + return withHooks[*MatchPlayer, MatchPlayerMutation](ctx, mpuo.sqlSave, mpuo.mutation, mpuo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -2705,16 +2634,10 @@ func (mpuo *MatchPlayerUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder) } func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlayer, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: matchplayer.Table, - Columns: matchplayer.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: matchplayer.FieldID, - }, - }, + if err := mpuo.check(); err != nil { + return _node, err } + _spec := sqlgraph.NewUpdateSpec(matchplayer.Table, matchplayer.Columns, sqlgraph.NewFieldSpec(matchplayer.FieldID, field.TypeInt)) id, ok := mpuo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "MatchPlayer.id" for update`)} @@ -3289,5 +3212,6 @@ func (mpuo *MatchPlayerUpdateOne) sqlSave(ctx context.Context) (_node *MatchPlay } return nil, err } + mpuo.mutation.done = true return _node, nil } diff --git a/ent/messages.go b/ent/messages.go index 51e7047..ca8e231 100644 --- a/ent/messages.go +++ b/ent/messages.go @@ -116,14 +116,14 @@ func (m *Messages) assignValues(columns []string, values []any) error { // QueryMatchPlayer queries the "match_player" edge of the Messages entity. func (m *Messages) QueryMatchPlayer() *MatchPlayerQuery { - return (&MessagesClient{config: m.config}).QueryMatchPlayer(m) + 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 (&MessagesClient{config: m.config}).UpdateOne(m) + return NewMessagesClient(m.config).UpdateOne(m) } // Unwrap unwraps the Messages entity that was returned from a transaction after it was closed, @@ -156,9 +156,3 @@ func (m *Messages) String() string { // MessagesSlice is a parsable slice of Messages. type MessagesSlice []*Messages - -func (m MessagesSlice) config(cfg config) { - for _i := range m { - m[_i].config = cfg - } -} diff --git a/ent/messages/where.go b/ent/messages/where.go index edbcca5..200f693 100644 --- a/ent/messages/where.go +++ b/ent/messages/where.go @@ -10,271 +10,177 @@ import ( // ID filters vertices based on their ID field. func ID(id int) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) + return predicate.Messages(sql.FieldEQ(FieldID, id)) } // IDEQ applies the EQ predicate on the ID field. func IDEQ(id int) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) + return predicate.Messages(sql.FieldEQ(FieldID, id)) } // IDNEQ applies the NEQ predicate on the ID field. func IDNEQ(id int) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldID), id)) - }) + return predicate.Messages(sql.FieldNEQ(FieldID, id)) } // IDIn applies the In predicate on the ID field. func IDIn(ids ...int) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - v := make([]any, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.In(s.C(FieldID), v...)) - }) + return predicate.Messages(sql.FieldIn(FieldID, ids...)) } // IDNotIn applies the NotIn predicate on the ID field. func IDNotIn(ids ...int) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - v := make([]any, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.NotIn(s.C(FieldID), v...)) - }) + return predicate.Messages(sql.FieldNotIn(FieldID, ids...)) } // IDGT applies the GT predicate on the ID field. func IDGT(id int) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldID), id)) - }) + return predicate.Messages(sql.FieldGT(FieldID, id)) } // IDGTE applies the GTE predicate on the ID field. func IDGTE(id int) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldID), id)) - }) + return predicate.Messages(sql.FieldGTE(FieldID, id)) } // IDLT applies the LT predicate on the ID field. func IDLT(id int) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldID), id)) - }) + return predicate.Messages(sql.FieldLT(FieldID, id)) } // IDLTE applies the LTE predicate on the ID field. func IDLTE(id int) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldID), id)) - }) + return predicate.Messages(sql.FieldLTE(FieldID, id)) } // Message applies equality check predicate on the "message" field. It's identical to MessageEQ. func Message(v string) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldMessage), v)) - }) + return predicate.Messages(sql.FieldEQ(FieldMessage, v)) } // AllChat applies equality check predicate on the "all_chat" field. It's identical to AllChatEQ. func AllChat(v bool) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldAllChat), v)) - }) + return predicate.Messages(sql.FieldEQ(FieldAllChat, v)) } // Tick applies equality check predicate on the "tick" field. It's identical to TickEQ. func Tick(v int) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldTick), v)) - }) + return predicate.Messages(sql.FieldEQ(FieldTick, v)) } // MessageEQ applies the EQ predicate on the "message" field. func MessageEQ(v string) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldMessage), v)) - }) + return predicate.Messages(sql.FieldEQ(FieldMessage, v)) } // MessageNEQ applies the NEQ predicate on the "message" field. func MessageNEQ(v string) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldMessage), v)) - }) + return predicate.Messages(sql.FieldNEQ(FieldMessage, v)) } // MessageIn applies the In predicate on the "message" field. func MessageIn(vs ...string) predicate.Messages { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldMessage), v...)) - }) + return predicate.Messages(sql.FieldIn(FieldMessage, vs...)) } // MessageNotIn applies the NotIn predicate on the "message" field. func MessageNotIn(vs ...string) predicate.Messages { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldMessage), v...)) - }) + return predicate.Messages(sql.FieldNotIn(FieldMessage, vs...)) } // MessageGT applies the GT predicate on the "message" field. func MessageGT(v string) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldMessage), v)) - }) + return predicate.Messages(sql.FieldGT(FieldMessage, v)) } // MessageGTE applies the GTE predicate on the "message" field. func MessageGTE(v string) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldMessage), v)) - }) + return predicate.Messages(sql.FieldGTE(FieldMessage, v)) } // MessageLT applies the LT predicate on the "message" field. func MessageLT(v string) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldMessage), v)) - }) + return predicate.Messages(sql.FieldLT(FieldMessage, v)) } // MessageLTE applies the LTE predicate on the "message" field. func MessageLTE(v string) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldMessage), v)) - }) + return predicate.Messages(sql.FieldLTE(FieldMessage, v)) } // MessageContains applies the Contains predicate on the "message" field. func MessageContains(v string) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldMessage), v)) - }) + return predicate.Messages(sql.FieldContains(FieldMessage, v)) } // MessageHasPrefix applies the HasPrefix predicate on the "message" field. func MessageHasPrefix(v string) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldMessage), v)) - }) + return predicate.Messages(sql.FieldHasPrefix(FieldMessage, v)) } // MessageHasSuffix applies the HasSuffix predicate on the "message" field. func MessageHasSuffix(v string) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldMessage), v)) - }) + return predicate.Messages(sql.FieldHasSuffix(FieldMessage, v)) } // MessageEqualFold applies the EqualFold predicate on the "message" field. func MessageEqualFold(v string) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldMessage), v)) - }) + return predicate.Messages(sql.FieldEqualFold(FieldMessage, v)) } // MessageContainsFold applies the ContainsFold predicate on the "message" field. func MessageContainsFold(v string) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldMessage), v)) - }) + return predicate.Messages(sql.FieldContainsFold(FieldMessage, v)) } // AllChatEQ applies the EQ predicate on the "all_chat" field. func AllChatEQ(v bool) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldAllChat), v)) - }) + return predicate.Messages(sql.FieldEQ(FieldAllChat, v)) } // AllChatNEQ applies the NEQ predicate on the "all_chat" field. func AllChatNEQ(v bool) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldAllChat), v)) - }) + return predicate.Messages(sql.FieldNEQ(FieldAllChat, v)) } // TickEQ applies the EQ predicate on the "tick" field. func TickEQ(v int) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldTick), v)) - }) + return predicate.Messages(sql.FieldEQ(FieldTick, v)) } // TickNEQ applies the NEQ predicate on the "tick" field. func TickNEQ(v int) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldTick), v)) - }) + return predicate.Messages(sql.FieldNEQ(FieldTick, v)) } // TickIn applies the In predicate on the "tick" field. func TickIn(vs ...int) predicate.Messages { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldTick), v...)) - }) + return predicate.Messages(sql.FieldIn(FieldTick, vs...)) } // TickNotIn applies the NotIn predicate on the "tick" field. func TickNotIn(vs ...int) predicate.Messages { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldTick), v...)) - }) + return predicate.Messages(sql.FieldNotIn(FieldTick, vs...)) } // TickGT applies the GT predicate on the "tick" field. func TickGT(v int) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldTick), v)) - }) + return predicate.Messages(sql.FieldGT(FieldTick, v)) } // TickGTE applies the GTE predicate on the "tick" field. func TickGTE(v int) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldTick), v)) - }) + return predicate.Messages(sql.FieldGTE(FieldTick, v)) } // TickLT applies the LT predicate on the "tick" field. func TickLT(v int) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldTick), v)) - }) + return predicate.Messages(sql.FieldLT(FieldTick, v)) } // TickLTE applies the LTE predicate on the "tick" field. func TickLTE(v int) predicate.Messages { - return predicate.Messages(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldTick), v)) - }) + return predicate.Messages(sql.FieldLTE(FieldTick, v)) } // HasMatchPlayer applies the HasEdge predicate on the "match_player" edge. @@ -282,7 +188,6 @@ func HasMatchPlayer() predicate.Messages { return predicate.Messages(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(MatchPlayerTable, FieldID), sqlgraph.Edge(sqlgraph.M2O, true, MatchPlayerTable, MatchPlayerColumn), ) sqlgraph.HasNeighbors(s, step) diff --git a/ent/messages_create.go b/ent/messages_create.go index 660b94d..998cd69 100644 --- a/ent/messages_create.go +++ b/ent/messages_create.go @@ -64,49 +64,7 @@ func (mc *MessagesCreate) Mutation() *MessagesMutation { // Save creates the Messages in the database. func (mc *MessagesCreate) Save(ctx context.Context) (*Messages, error) { - var ( - err error - node *Messages - ) - if len(mc.hooks) == 0 { - if err = mc.check(); err != nil { - return nil, err - } - node, err = mc.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*MessagesMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err = mc.check(); err != nil { - return nil, err - } - mc.mutation = mutation - if node, err = mc.sqlSave(ctx); err != nil { - return nil, err - } - mutation.id = &node.ID - mutation.done = true - return node, err - }) - for i := len(mc.hooks) - 1; i >= 0; i-- { - if mc.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = mc.hooks[i](mut) - } - v, err := mut.Mutate(ctx, mc.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*Messages) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from MessagesMutation", v) - } - node = nv - } - return node, err + return withHooks[*Messages, MessagesMutation](ctx, mc.sqlSave, mc.mutation, mc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -146,6 +104,9 @@ func (mc *MessagesCreate) check() error { } func (mc *MessagesCreate) sqlSave(ctx context.Context) (*Messages, error) { + if err := mc.check(); err != nil { + return nil, err + } _node, _spec := mc.createSpec() if err := sqlgraph.CreateNode(ctx, mc.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { @@ -155,19 +116,15 @@ 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 return _node, nil } func (mc *MessagesCreate) createSpec() (*Messages, *sqlgraph.CreateSpec) { var ( _node = &Messages{config: mc.config} - _spec = &sqlgraph.CreateSpec{ - Table: messages.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: messages.FieldID, - }, - } + _spec = sqlgraph.NewCreateSpec(messages.Table, sqlgraph.NewFieldSpec(messages.FieldID, field.TypeInt)) ) if value, ok := mc.mutation.Message(); ok { _spec.SetField(messages.FieldMessage, field.TypeString, value) diff --git a/ent/messages_delete.go b/ent/messages_delete.go index bfcf44d..ea2f447 100644 --- a/ent/messages_delete.go +++ b/ent/messages_delete.go @@ -4,7 +4,6 @@ package ent import ( "context" - "fmt" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -28,34 +27,7 @@ func (md *MessagesDelete) Where(ps ...predicate.Messages) *MessagesDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (md *MessagesDelete) Exec(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(md.hooks) == 0 { - affected, err = md.sqlExec(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*MessagesMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - md.mutation = mutation - affected, err = md.sqlExec(ctx) - mutation.done = true - return affected, err - }) - for i := len(md.hooks) - 1; i >= 0; i-- { - if md.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = md.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, md.mutation); err != nil { - return 0, err - } - } - return affected, err + return withHooks[int, MessagesMutation](ctx, md.sqlExec, md.mutation, md.hooks) } // ExecX is like Exec, but panics if an error occurs. @@ -68,15 +40,7 @@ func (md *MessagesDelete) ExecX(ctx context.Context) int { } func (md *MessagesDelete) sqlExec(ctx context.Context) (int, error) { - _spec := &sqlgraph.DeleteSpec{ - Node: &sqlgraph.NodeSpec{ - Table: messages.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: messages.FieldID, - }, - }, - } + _spec := sqlgraph.NewDeleteSpec(messages.Table, sqlgraph.NewFieldSpec(messages.FieldID, field.TypeInt)) if ps := md.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -88,6 +52,7 @@ func (md *MessagesDelete) sqlExec(ctx context.Context) (int, error) { if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } + md.mutation.done = true return affected, err } @@ -96,6 +61,12 @@ type MessagesDeleteOne struct { md *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 +} + // Exec executes the deletion query. func (mdo *MessagesDeleteOne) Exec(ctx context.Context) error { n, err := mdo.md.Exec(ctx) @@ -111,5 +82,7 @@ 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) { - mdo.md.ExecX(ctx) + if err := mdo.Exec(ctx); err != nil { + panic(err) + } } diff --git a/ent/messages_query.go b/ent/messages_query.go index 9519f68..1021c34 100644 --- a/ent/messages_query.go +++ b/ent/messages_query.go @@ -18,11 +18,9 @@ import ( // MessagesQuery is the builder for querying Messages entities. type MessagesQuery struct { config - limit *int - offset *int - unique *bool + ctx *QueryContext order []OrderFunc - fields []string + inters []Interceptor predicates []predicate.Messages withMatchPlayer *MatchPlayerQuery withFKs bool @@ -38,26 +36,26 @@ func (mq *MessagesQuery) Where(ps ...predicate.Messages) *MessagesQuery { return mq } -// Limit adds a limit step to the query. +// Limit the number of records to be returned by this query. func (mq *MessagesQuery) Limit(limit int) *MessagesQuery { - mq.limit = &limit + mq.ctx.Limit = &limit return mq } -// Offset adds an offset step to the query. +// Offset to start from. func (mq *MessagesQuery) Offset(offset int) *MessagesQuery { - mq.offset = &offset + mq.ctx.Offset = &offset return mq } // 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.unique = &unique + mq.ctx.Unique = &unique return mq } -// Order adds an order step to the query. +// Order specifies how the records should be ordered. func (mq *MessagesQuery) Order(o ...OrderFunc) *MessagesQuery { mq.order = append(mq.order, o...) return mq @@ -65,7 +63,7 @@ func (mq *MessagesQuery) Order(o ...OrderFunc) *MessagesQuery { // QueryMatchPlayer chains the current query on the "match_player" edge. func (mq *MessagesQuery) QueryMatchPlayer() *MatchPlayerQuery { - query := &MatchPlayerQuery{config: mq.config} + query := (&MatchPlayerClient{config: mq.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := mq.prepareQuery(ctx); err != nil { return nil, err @@ -88,7 +86,7 @@ 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(ctx) + nodes, err := mq.Limit(1).All(setContextOp(ctx, mq.ctx, "First")) if err != nil { return nil, err } @@ -111,7 +109,7 @@ func (mq *MessagesQuery) FirstX(ctx context.Context) *Messages { // Returns a *NotFoundError when no Messages ID was found. func (mq *MessagesQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = mq.Limit(1).IDs(ctx); err != nil { + if ids, err = mq.Limit(1).IDs(setContextOp(ctx, mq.ctx, "FirstID")); err != nil { return } if len(ids) == 0 { @@ -134,7 +132,7 @@ func (mq *MessagesQuery) FirstIDX(ctx context.Context) int { // 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(ctx) + nodes, err := mq.Limit(2).All(setContextOp(ctx, mq.ctx, "Only")) if err != nil { return nil, err } @@ -162,7 +160,7 @@ func (mq *MessagesQuery) OnlyX(ctx context.Context) *Messages { // Returns a *NotFoundError when no entities are found. func (mq *MessagesQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = mq.Limit(2).IDs(ctx); err != nil { + if ids, err = mq.Limit(2).IDs(setContextOp(ctx, mq.ctx, "OnlyID")); err != nil { return } switch len(ids) { @@ -187,10 +185,12 @@ 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 { return nil, err } - return mq.sqlAll(ctx) + qr := querierAll[[]*Messages, *MessagesQuery]() + return withInterceptors[[]*Messages](ctx, mq, qr, mq.inters) } // AllX is like All, but panics if an error occurs. @@ -203,9 +203,12 @@ 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) ([]int, error) { - var ids []int - if err := mq.Select(messages.FieldID).Scan(ctx, &ids); err != nil { +func (mq *MessagesQuery) IDs(ctx context.Context) (ids []int, err error) { + if mq.ctx.Unique == nil && mq.path != nil { + mq.Unique(true) + } + ctx = setContextOp(ctx, mq.ctx, "IDs") + if err = mq.Select(messages.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil @@ -222,10 +225,11 @@ 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 { return 0, err } - return mq.sqlCount(ctx) + return withInterceptors[int](ctx, mq, querierCount[*MessagesQuery](), mq.inters) } // CountX is like Count, but panics if an error occurs. @@ -239,10 +243,15 @@ 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) { - if err := mq.prepareQuery(ctx); err != nil { - return false, err + ctx = setContextOp(ctx, mq.ctx, "Exist") + switch _, err := mq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil } - return mq.sqlExist(ctx) } // ExistX is like Exist, but panics if an error occurs. @@ -262,22 +271,21 @@ func (mq *MessagesQuery) Clone() *MessagesQuery { } return &MessagesQuery{ config: mq.config, - limit: mq.limit, - offset: mq.offset, + ctx: mq.ctx.Clone(), order: append([]OrderFunc{}, mq.order...), + inters: append([]Interceptor{}, mq.inters...), predicates: append([]predicate.Messages{}, mq.predicates...), withMatchPlayer: mq.withMatchPlayer.Clone(), // clone intermediate query. - sql: mq.sql.Clone(), - path: mq.path, - unique: mq.unique, + sql: mq.sql.Clone(), + path: mq.path, } } // 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 := &MatchPlayerQuery{config: mq.config} + query := (&MatchPlayerClient{config: mq.config}).Query() for _, opt := range opts { opt(query) } @@ -300,16 +308,11 @@ func (mq *MessagesQuery) WithMatchPlayer(opts ...func(*MatchPlayerQuery)) *Messa // Aggregate(ent.Count()). // Scan(ctx, &v) func (mq *MessagesQuery) GroupBy(field string, fields ...string) *MessagesGroupBy { - grbuild := &MessagesGroupBy{config: mq.config} - grbuild.fields = append([]string{field}, fields...) - grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { - if err := mq.prepareQuery(ctx); err != nil { - return nil, err - } - return mq.sqlQuery(ctx), nil - } + mq.ctx.Fields = append([]string{field}, fields...) + grbuild := &MessagesGroupBy{build: mq} + grbuild.flds = &mq.ctx.Fields grbuild.label = messages.Label - grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan + grbuild.scan = grbuild.Scan return grbuild } @@ -326,11 +329,11 @@ func (mq *MessagesQuery) GroupBy(field string, fields ...string) *MessagesGroupB // Select(messages.FieldMessage). // Scan(ctx, &v) func (mq *MessagesQuery) Select(fields ...string) *MessagesSelect { - mq.fields = append(mq.fields, fields...) - selbuild := &MessagesSelect{MessagesQuery: mq} - selbuild.label = messages.Label - selbuild.flds, selbuild.scan = &mq.fields, selbuild.Scan - return selbuild + mq.ctx.Fields = append(mq.ctx.Fields, fields...) + sbuild := &MessagesSelect{MessagesQuery: mq} + sbuild.label = messages.Label + sbuild.flds, sbuild.scan = &mq.ctx.Fields, sbuild.Scan + return sbuild } // Aggregate returns a MessagesSelect configured with the given aggregations. @@ -339,7 +342,17 @@ func (mq *MessagesQuery) Aggregate(fns ...AggregateFunc) *MessagesSelect { } func (mq *MessagesQuery) prepareQuery(ctx context.Context) error { - for _, f := range mq.fields { + for _, inter := range mq.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 { + return err + } + } + } + for _, f := range mq.ctx.Fields { if !messages.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } @@ -412,6 +425,9 @@ func (mq *MessagesQuery) loadMatchPlayer(ctx context.Context, query *MatchPlayer } nodeids[fk] = append(nodeids[fk], nodes[i]) } + if len(ids) == 0 { + return nil + } query.Where(matchplayer.IDIn(ids...)) neighbors, err := query.All(ctx) if err != nil { @@ -434,41 +450,22 @@ func (mq *MessagesQuery) sqlCount(ctx context.Context) (int, error) { if len(mq.modifiers) > 0 { _spec.Modifiers = mq.modifiers } - _spec.Node.Columns = mq.fields - if len(mq.fields) > 0 { - _spec.Unique = mq.unique != nil && *mq.unique + _spec.Node.Columns = mq.ctx.Fields + if len(mq.ctx.Fields) > 0 { + _spec.Unique = mq.ctx.Unique != nil && *mq.ctx.Unique } return sqlgraph.CountNodes(ctx, mq.driver, _spec) } -func (mq *MessagesQuery) sqlExist(ctx context.Context) (bool, error) { - switch _, err := mq.FirstID(ctx); { - case IsNotFound(err): - return false, nil - case err != nil: - return false, fmt.Errorf("ent: check existence: %w", err) - default: - return true, nil - } -} - func (mq *MessagesQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: messages.Table, - Columns: messages.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: messages.FieldID, - }, - }, - From: mq.sql, - Unique: true, - } - if unique := mq.unique; unique != nil { + _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.Unique = *unique + } else if mq.path != nil { + _spec.Unique = true } - if fields := mq.fields; len(fields) > 0 { + if fields := mq.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 { @@ -484,10 +481,10 @@ func (mq *MessagesQuery) querySpec() *sqlgraph.QuerySpec { } } } - if limit := mq.limit; limit != nil { + if limit := mq.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := mq.offset; offset != nil { + if offset := mq.ctx.Offset; offset != nil { _spec.Offset = *offset } if ps := mq.order; len(ps) > 0 { @@ -503,7 +500,7 @@ func (mq *MessagesQuery) querySpec() *sqlgraph.QuerySpec { func (mq *MessagesQuery) sqlQuery(ctx context.Context) *sql.Selector { builder := sql.Dialect(mq.driver.Dialect()) t1 := builder.Table(messages.Table) - columns := mq.fields + columns := mq.ctx.Fields if len(columns) == 0 { columns = messages.Columns } @@ -512,7 +509,7 @@ func (mq *MessagesQuery) sqlQuery(ctx context.Context) *sql.Selector { selector = mq.sql selector.Select(selector.Columns(columns...)...) } - if mq.unique != nil && *mq.unique { + if mq.ctx.Unique != nil && *mq.ctx.Unique { selector.Distinct() } for _, m := range mq.modifiers { @@ -524,12 +521,12 @@ func (mq *MessagesQuery) sqlQuery(ctx context.Context) *sql.Selector { for _, p := range mq.order { p(selector) } - if offset := mq.offset; offset != nil { + if offset := mq.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.limit; limit != nil { + if limit := mq.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector @@ -543,13 +540,8 @@ func (mq *MessagesQuery) Modify(modifiers ...func(s *sql.Selector)) *MessagesSel // MessagesGroupBy is the group-by builder for Messages entities. type MessagesGroupBy struct { - config selector - fields []string - fns []AggregateFunc - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) + build *MessagesQuery } // Aggregate adds the given aggregation functions to the group-by query. @@ -558,58 +550,46 @@ func (mgb *MessagesGroupBy) Aggregate(fns ...AggregateFunc) *MessagesGroupBy { return mgb } -// Scan applies the group-by query and scans the result into the given value. +// Scan applies the selector query and scans the result into the given value. func (mgb *MessagesGroupBy) Scan(ctx context.Context, v any) error { - query, err := mgb.path(ctx) - if err != nil { + ctx = setContextOp(ctx, mgb.build.ctx, "GroupBy") + if err := mgb.build.prepareQuery(ctx); err != nil { return err } - mgb.sql = query - return mgb.sqlScan(ctx, v) + return scanWithInterceptors[*MessagesQuery, *MessagesGroupBy](ctx, mgb.build, mgb, mgb.build.inters, v) } -func (mgb *MessagesGroupBy) sqlScan(ctx context.Context, v any) error { - for _, f := range mgb.fields { - if !messages.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} - } +func (mgb *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 = append(aggregation, fn(selector)) } - selector := mgb.sqlQuery() + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*mgb.flds)+len(mgb.fns)) + for _, f := range *mgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*mgb.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := mgb.driver.Query(ctx, query, args, rows); err != nil { + if err := mgb.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() return sql.ScanSlice(rows, v) } -func (mgb *MessagesGroupBy) sqlQuery() *sql.Selector { - selector := mgb.sql.Select() - aggregation := make([]string, 0, len(mgb.fns)) - for _, fn := range mgb.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(mgb.fields)+len(mgb.fns)) - for _, f := range mgb.fields { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - return selector.GroupBy(selector.Columns(mgb.fields...)...) -} - // MessagesSelect is the builder for selecting fields of Messages entities. type MessagesSelect struct { *MessagesQuery selector - // intermediate query (i.e. traversal path). - sql *sql.Selector } // Aggregate adds the given aggregation functions to the selector query. @@ -620,26 +600,27 @@ func (ms *MessagesSelect) Aggregate(fns ...AggregateFunc) *MessagesSelect { // 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 { return err } - ms.sql = ms.MessagesQuery.sqlQuery(ctx) - return ms.sqlScan(ctx, v) + return scanWithInterceptors[*MessagesQuery, *MessagesSelect](ctx, ms.MessagesQuery, ms, ms.inters, v) } -func (ms *MessagesSelect) sqlScan(ctx context.Context, v any) error { +func (ms *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 = append(aggregation, fn(ms.sql)) + aggregation = append(aggregation, fn(selector)) } switch n := len(*ms.selector.flds); { case n == 0 && len(aggregation) > 0: - ms.sql.Select(aggregation...) + selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: - ms.sql.AppendSelect(aggregation...) + selector.AppendSelect(aggregation...) } rows := &sql.Rows{} - query, args := ms.sql.Query() + query, args := selector.Query() if err := ms.driver.Query(ctx, query, args, rows); err != nil { return err } diff --git a/ent/messages_update.go b/ent/messages_update.go index 5db5891..72956e1 100644 --- a/ent/messages_update.go +++ b/ent/messages_update.go @@ -86,34 +86,7 @@ func (mu *MessagesUpdate) ClearMatchPlayer() *MessagesUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (mu *MessagesUpdate) Save(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(mu.hooks) == 0 { - affected, err = mu.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*MessagesMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - mu.mutation = mutation - affected, err = mu.sqlSave(ctx) - mutation.done = true - return affected, err - }) - for i := len(mu.hooks) - 1; i >= 0; i-- { - if mu.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = mu.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, mu.mutation); err != nil { - return 0, err - } - } - return affected, err + return withHooks[int, MessagesMutation](ctx, mu.sqlSave, mu.mutation, mu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -145,16 +118,7 @@ func (mu *MessagesUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *Messa } func (mu *MessagesUpdate) sqlSave(ctx context.Context) (n int, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: messages.Table, - Columns: messages.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: messages.FieldID, - }, - }, - } + _spec := sqlgraph.NewUpdateSpec(messages.Table, messages.Columns, sqlgraph.NewFieldSpec(messages.FieldID, field.TypeInt)) if ps := mu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -218,6 +182,7 @@ func (mu *MessagesUpdate) sqlSave(ctx context.Context) (n int, err error) { } return 0, err } + mu.mutation.done = true return n, nil } @@ -285,6 +250,12 @@ func (muo *MessagesUpdateOne) ClearMatchPlayer() *MessagesUpdateOne { return muo } +// Where appends a list predicates to the MessagesUpdate builder. +func (muo *MessagesUpdateOne) Where(ps ...predicate.Messages) *MessagesUpdateOne { + muo.mutation.Where(ps...) + return muo +} + // 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 { @@ -294,40 +265,7 @@ func (muo *MessagesUpdateOne) Select(field string, fields ...string) *MessagesUp // Save executes the query and returns the updated Messages entity. func (muo *MessagesUpdateOne) Save(ctx context.Context) (*Messages, error) { - var ( - err error - node *Messages - ) - if len(muo.hooks) == 0 { - node, err = muo.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*MessagesMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - muo.mutation = mutation - node, err = muo.sqlSave(ctx) - mutation.done = true - return node, err - }) - for i := len(muo.hooks) - 1; i >= 0; i-- { - if muo.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = muo.hooks[i](mut) - } - v, err := mut.Mutate(ctx, muo.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*Messages) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from MessagesMutation", v) - } - node = nv - } - return node, err + return withHooks[*Messages, MessagesMutation](ctx, muo.sqlSave, muo.mutation, muo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -359,16 +297,7 @@ func (muo *MessagesUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *M } func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: messages.Table, - Columns: messages.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: messages.FieldID, - }, - }, - } + _spec := sqlgraph.NewUpdateSpec(messages.Table, messages.Columns, sqlgraph.NewFieldSpec(messages.FieldID, field.TypeInt)) id, ok := muo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Messages.id" for update`)} @@ -452,5 +381,6 @@ func (muo *MessagesUpdateOne) sqlSave(ctx context.Context) (_node *Messages, err } return nil, err } + muo.mutation.done = true return _node, nil } diff --git a/ent/mutation.go b/ent/mutation.go index a10bbb6..fd69fa2 100644 --- a/ent/mutation.go +++ b/ent/mutation.go @@ -9,6 +9,8 @@ import ( "sync" "time" + "entgo.io/ent" + "entgo.io/ent/dialect/sql" "git.harting.dev/csgowtf/csgowtfd/ent/match" "git.harting.dev/csgowtf/csgowtfd/ent/matchplayer" "git.harting.dev/csgowtf/csgowtfd/ent/messages" @@ -17,8 +19,6 @@ import ( "git.harting.dev/csgowtf/csgowtfd/ent/roundstats" "git.harting.dev/csgowtf/csgowtfd/ent/spray" "git.harting.dev/csgowtf/csgowtfd/ent/weapon" - - "entgo.io/ent" ) const ( @@ -971,11 +971,26 @@ func (m *MatchMutation) Where(ps ...predicate.Match) { m.predicates = append(m.predicates, ps...) } +// WhereP appends storage-level predicates to the MatchMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *MatchMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Match, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + // Op returns the operation name. func (m *MatchMutation) Op() Op { return m.op } +// SetOp allows setting the mutation operation. +func (m *MatchMutation) SetOp(op Op) { + m.op = op +} + // Type returns the node type of this mutation (Match). func (m *MatchMutation) Type() string { return m.typ @@ -4128,11 +4143,26 @@ func (m *MatchPlayerMutation) Where(ps ...predicate.MatchPlayer) { m.predicates = append(m.predicates, ps...) } +// WhereP appends storage-level predicates to the MatchPlayerMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *MatchPlayerMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.MatchPlayer, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + // Op returns the operation name. func (m *MatchPlayerMutation) Op() Op { return m.op } +// SetOp allows setting the mutation operation. +func (m *MatchPlayerMutation) SetOp(op Op) { + m.op = op +} + // Type returns the node type of this mutation (MatchPlayer). func (m *MatchPlayerMutation) Type() string { return m.typ @@ -5779,11 +5809,26 @@ func (m *MessagesMutation) Where(ps ...predicate.Messages) { m.predicates = append(m.predicates, ps...) } +// WhereP appends storage-level predicates to the MessagesMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *MessagesMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Messages, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + // Op returns the operation name. func (m *MessagesMutation) Op() Op { return m.op } +// SetOp allows setting the mutation operation. +func (m *MessagesMutation) SetOp(op Op) { + m.op = op +} + // Type returns the node type of this mutation (Messages). func (m *MessagesMutation) Type() string { return m.typ @@ -7145,11 +7190,26 @@ func (m *PlayerMutation) Where(ps ...predicate.Player) { m.predicates = append(m.predicates, ps...) } +// WhereP appends storage-level predicates to the PlayerMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *PlayerMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Player, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + // Op returns the operation name. func (m *PlayerMutation) Op() Op { return m.op } +// SetOp allows setting the mutation operation. +func (m *PlayerMutation) SetOp(op Op) { + m.op = op +} + // Type returns the node type of this mutation (Player). func (m *PlayerMutation) Type() string { return m.typ @@ -8165,11 +8225,26 @@ func (m *RoundStatsMutation) Where(ps ...predicate.RoundStats) { m.predicates = append(m.predicates, ps...) } +// WhereP appends storage-level predicates to the RoundStatsMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *RoundStatsMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.RoundStats, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + // Op returns the operation name. func (m *RoundStatsMutation) Op() Op { return m.op } +// SetOp allows setting the mutation operation. +func (m *RoundStatsMutation) SetOp(op Op) { + m.op = op +} + // Type returns the node type of this mutation (RoundStats). func (m *RoundStatsMutation) Type() string { return m.typ @@ -8703,11 +8778,26 @@ func (m *SprayMutation) Where(ps ...predicate.Spray) { m.predicates = append(m.predicates, ps...) } +// WhereP appends storage-level predicates to the SprayMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *SprayMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Spray, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + // Op returns the operation name. func (m *SprayMutation) Op() Op { return m.op } +// SetOp allows setting the mutation operation. +func (m *SprayMutation) SetOp(op Op) { + m.op = op +} + // Type returns the node type of this mutation (Spray). func (m *SprayMutation) Type() string { return m.typ @@ -9308,11 +9398,26 @@ func (m *WeaponMutation) Where(ps ...predicate.Weapon) { m.predicates = append(m.predicates, ps...) } +// WhereP appends storage-level predicates to the WeaponMutation builder. Using this method, +// users can use type-assertion to append predicates that do not depend on any generated package. +func (m *WeaponMutation) WhereP(ps ...func(*sql.Selector)) { + p := make([]predicate.Weapon, len(ps)) + for i := range ps { + p[i] = ps[i] + } + m.Where(p...) +} + // Op returns the operation name. func (m *WeaponMutation) Op() Op { return m.op } +// SetOp allows setting the mutation operation. +func (m *WeaponMutation) SetOp(op Op) { + m.op = op +} + // Type returns the node type of this mutation (Weapon). func (m *WeaponMutation) Type() string { return m.typ diff --git a/ent/player.go b/ent/player.go index e6dd164..a221028 100644 --- a/ent/player.go +++ b/ent/player.go @@ -217,19 +217,19 @@ func (pl *Player) assignValues(columns []string, values []any) error { // QueryStats queries the "stats" edge of the Player entity. func (pl *Player) QueryStats() *MatchPlayerQuery { - return (&PlayerClient{config: pl.config}).QueryStats(pl) + return NewPlayerClient(pl.config).QueryStats(pl) } // QueryMatches queries the "matches" edge of the Player entity. func (pl *Player) QueryMatches() *MatchQuery { - return (&PlayerClient{config: pl.config}).QueryMatches(pl) + return NewPlayerClient(pl.config).QueryMatches(pl) } // 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 (&PlayerClient{config: pl.config}).UpdateOne(pl) + return NewPlayerClient(pl.config).UpdateOne(pl) } // Unwrap unwraps the Player entity that was returned from a transaction after it was closed, @@ -300,9 +300,3 @@ func (pl *Player) String() string { // Players is a parsable slice of Player. type Players []*Player - -func (pl Players) config(cfg config) { - for _i := range pl { - pl[_i].config = cfg - } -} diff --git a/ent/player/where.go b/ent/player/where.go index 1063822..a33e2ae 100644 --- a/ent/player/where.go +++ b/ent/player/where.go @@ -12,1629 +12,1067 @@ import ( // ID filters vertices based on their ID field. func ID(id uint64) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) + return predicate.Player(sql.FieldEQ(FieldID, id)) } // IDEQ applies the EQ predicate on the ID field. func IDEQ(id uint64) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) + return predicate.Player(sql.FieldEQ(FieldID, id)) } // IDNEQ applies the NEQ predicate on the ID field. func IDNEQ(id uint64) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldID), id)) - }) + return predicate.Player(sql.FieldNEQ(FieldID, id)) } // IDIn applies the In predicate on the ID field. func IDIn(ids ...uint64) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - v := make([]any, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.In(s.C(FieldID), v...)) - }) + return predicate.Player(sql.FieldIn(FieldID, ids...)) } // IDNotIn applies the NotIn predicate on the ID field. func IDNotIn(ids ...uint64) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - v := make([]any, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.NotIn(s.C(FieldID), v...)) - }) + return predicate.Player(sql.FieldNotIn(FieldID, ids...)) } // IDGT applies the GT predicate on the ID field. func IDGT(id uint64) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldID), id)) - }) + return predicate.Player(sql.FieldGT(FieldID, id)) } // IDGTE applies the GTE predicate on the ID field. func IDGTE(id uint64) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldID), id)) - }) + return predicate.Player(sql.FieldGTE(FieldID, id)) } // IDLT applies the LT predicate on the ID field. func IDLT(id uint64) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldID), id)) - }) + return predicate.Player(sql.FieldLT(FieldID, id)) } // IDLTE applies the LTE predicate on the ID field. func IDLTE(id uint64) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldID), id)) - }) + return predicate.Player(sql.FieldLTE(FieldID, id)) } // Name applies equality check predicate on the "name" field. It's identical to NameEQ. func Name(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldName), v)) - }) + return predicate.Player(sql.FieldEQ(FieldName, v)) } // Avatar applies equality check predicate on the "avatar" field. It's identical to AvatarEQ. func Avatar(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldAvatar), v)) - }) + return predicate.Player(sql.FieldEQ(FieldAvatar, v)) } // VanityURL applies equality check predicate on the "vanity_url" field. It's identical to VanityURLEQ. func VanityURL(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldVanityURL), v)) - }) + return predicate.Player(sql.FieldEQ(FieldVanityURL, v)) } // VanityURLReal applies equality check predicate on the "vanity_url_real" field. It's identical to VanityURLRealEQ. func VanityURLReal(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldVanityURLReal), v)) - }) + return predicate.Player(sql.FieldEQ(FieldVanityURLReal, v)) } // VacDate applies equality check predicate on the "vac_date" field. It's identical to VacDateEQ. func VacDate(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldVacDate), v)) - }) + return predicate.Player(sql.FieldEQ(FieldVacDate, v)) } // VacCount applies equality check predicate on the "vac_count" field. It's identical to VacCountEQ. func VacCount(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldVacCount), v)) - }) + return predicate.Player(sql.FieldEQ(FieldVacCount, v)) } // GameBanDate applies equality check predicate on the "game_ban_date" field. It's identical to GameBanDateEQ. func GameBanDate(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldGameBanDate), v)) - }) + return predicate.Player(sql.FieldEQ(FieldGameBanDate, v)) } // GameBanCount applies equality check predicate on the "game_ban_count" field. It's identical to GameBanCountEQ. func GameBanCount(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldGameBanCount), v)) - }) + return predicate.Player(sql.FieldEQ(FieldGameBanCount, v)) } // SteamUpdated applies equality check predicate on the "steam_updated" field. It's identical to SteamUpdatedEQ. func SteamUpdated(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldSteamUpdated), v)) - }) + return predicate.Player(sql.FieldEQ(FieldSteamUpdated, v)) } // SharecodeUpdated applies equality check predicate on the "sharecode_updated" field. It's identical to SharecodeUpdatedEQ. func SharecodeUpdated(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldSharecodeUpdated), v)) - }) + return predicate.Player(sql.FieldEQ(FieldSharecodeUpdated, v)) } // AuthCode applies equality check predicate on the "auth_code" field. It's identical to AuthCodeEQ. func AuthCode(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldAuthCode), v)) - }) + return predicate.Player(sql.FieldEQ(FieldAuthCode, v)) } // ProfileCreated applies equality check predicate on the "profile_created" field. It's identical to ProfileCreatedEQ. func ProfileCreated(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldProfileCreated), v)) - }) + return predicate.Player(sql.FieldEQ(FieldProfileCreated, v)) } // OldestSharecodeSeen applies equality check predicate on the "oldest_sharecode_seen" field. It's identical to OldestSharecodeSeenEQ. func OldestSharecodeSeen(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldOldestSharecodeSeen), v)) - }) + return predicate.Player(sql.FieldEQ(FieldOldestSharecodeSeen, v)) } // Wins applies equality check predicate on the "wins" field. It's identical to WinsEQ. func Wins(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldWins), v)) - }) + return predicate.Player(sql.FieldEQ(FieldWins, v)) } // Looses applies equality check predicate on the "looses" field. It's identical to LoosesEQ. func Looses(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldLooses), v)) - }) + return predicate.Player(sql.FieldEQ(FieldLooses, v)) } // Ties applies equality check predicate on the "ties" field. It's identical to TiesEQ. func Ties(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldTies), v)) - }) + return predicate.Player(sql.FieldEQ(FieldTies, v)) } // NameEQ applies the EQ predicate on the "name" field. func NameEQ(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldName), v)) - }) + return predicate.Player(sql.FieldEQ(FieldName, v)) } // NameNEQ applies the NEQ predicate on the "name" field. func NameNEQ(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldName), v)) - }) + return predicate.Player(sql.FieldNEQ(FieldName, v)) } // NameIn applies the In predicate on the "name" field. func NameIn(vs ...string) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldName), v...)) - }) + return predicate.Player(sql.FieldIn(FieldName, vs...)) } // NameNotIn applies the NotIn predicate on the "name" field. func NameNotIn(vs ...string) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldName), v...)) - }) + return predicate.Player(sql.FieldNotIn(FieldName, vs...)) } // NameGT applies the GT predicate on the "name" field. func NameGT(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldName), v)) - }) + return predicate.Player(sql.FieldGT(FieldName, v)) } // NameGTE applies the GTE predicate on the "name" field. func NameGTE(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldName), v)) - }) + return predicate.Player(sql.FieldGTE(FieldName, v)) } // NameLT applies the LT predicate on the "name" field. func NameLT(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldName), v)) - }) + return predicate.Player(sql.FieldLT(FieldName, v)) } // NameLTE applies the LTE predicate on the "name" field. func NameLTE(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldName), v)) - }) + return predicate.Player(sql.FieldLTE(FieldName, v)) } // NameContains applies the Contains predicate on the "name" field. func NameContains(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldName), v)) - }) + return predicate.Player(sql.FieldContains(FieldName, v)) } // NameHasPrefix applies the HasPrefix predicate on the "name" field. func NameHasPrefix(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldName), v)) - }) + return predicate.Player(sql.FieldHasPrefix(FieldName, v)) } // NameHasSuffix applies the HasSuffix predicate on the "name" field. func NameHasSuffix(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldName), v)) - }) + return predicate.Player(sql.FieldHasSuffix(FieldName, v)) } // NameIsNil applies the IsNil predicate on the "name" field. func NameIsNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldName))) - }) + return predicate.Player(sql.FieldIsNull(FieldName)) } // NameNotNil applies the NotNil predicate on the "name" field. func NameNotNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldName))) - }) + return predicate.Player(sql.FieldNotNull(FieldName)) } // NameEqualFold applies the EqualFold predicate on the "name" field. func NameEqualFold(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldName), v)) - }) + return predicate.Player(sql.FieldEqualFold(FieldName, v)) } // NameContainsFold applies the ContainsFold predicate on the "name" field. func NameContainsFold(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldName), v)) - }) + return predicate.Player(sql.FieldContainsFold(FieldName, v)) } // AvatarEQ applies the EQ predicate on the "avatar" field. func AvatarEQ(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldAvatar), v)) - }) + return predicate.Player(sql.FieldEQ(FieldAvatar, v)) } // AvatarNEQ applies the NEQ predicate on the "avatar" field. func AvatarNEQ(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldAvatar), v)) - }) + return predicate.Player(sql.FieldNEQ(FieldAvatar, v)) } // AvatarIn applies the In predicate on the "avatar" field. func AvatarIn(vs ...string) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldAvatar), v...)) - }) + return predicate.Player(sql.FieldIn(FieldAvatar, vs...)) } // AvatarNotIn applies the NotIn predicate on the "avatar" field. func AvatarNotIn(vs ...string) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldAvatar), v...)) - }) + return predicate.Player(sql.FieldNotIn(FieldAvatar, vs...)) } // AvatarGT applies the GT predicate on the "avatar" field. func AvatarGT(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldAvatar), v)) - }) + return predicate.Player(sql.FieldGT(FieldAvatar, v)) } // AvatarGTE applies the GTE predicate on the "avatar" field. func AvatarGTE(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldAvatar), v)) - }) + return predicate.Player(sql.FieldGTE(FieldAvatar, v)) } // AvatarLT applies the LT predicate on the "avatar" field. func AvatarLT(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldAvatar), v)) - }) + return predicate.Player(sql.FieldLT(FieldAvatar, v)) } // AvatarLTE applies the LTE predicate on the "avatar" field. func AvatarLTE(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldAvatar), v)) - }) + return predicate.Player(sql.FieldLTE(FieldAvatar, v)) } // AvatarContains applies the Contains predicate on the "avatar" field. func AvatarContains(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldAvatar), v)) - }) + return predicate.Player(sql.FieldContains(FieldAvatar, v)) } // AvatarHasPrefix applies the HasPrefix predicate on the "avatar" field. func AvatarHasPrefix(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldAvatar), v)) - }) + return predicate.Player(sql.FieldHasPrefix(FieldAvatar, v)) } // AvatarHasSuffix applies the HasSuffix predicate on the "avatar" field. func AvatarHasSuffix(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldAvatar), v)) - }) + return predicate.Player(sql.FieldHasSuffix(FieldAvatar, v)) } // AvatarIsNil applies the IsNil predicate on the "avatar" field. func AvatarIsNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldAvatar))) - }) + return predicate.Player(sql.FieldIsNull(FieldAvatar)) } // AvatarNotNil applies the NotNil predicate on the "avatar" field. func AvatarNotNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldAvatar))) - }) + return predicate.Player(sql.FieldNotNull(FieldAvatar)) } // AvatarEqualFold applies the EqualFold predicate on the "avatar" field. func AvatarEqualFold(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldAvatar), v)) - }) + return predicate.Player(sql.FieldEqualFold(FieldAvatar, v)) } // AvatarContainsFold applies the ContainsFold predicate on the "avatar" field. func AvatarContainsFold(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldAvatar), v)) - }) + return predicate.Player(sql.FieldContainsFold(FieldAvatar, v)) } // VanityURLEQ applies the EQ predicate on the "vanity_url" field. func VanityURLEQ(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldVanityURL), v)) - }) + return predicate.Player(sql.FieldEQ(FieldVanityURL, v)) } // VanityURLNEQ applies the NEQ predicate on the "vanity_url" field. func VanityURLNEQ(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldVanityURL), v)) - }) + return predicate.Player(sql.FieldNEQ(FieldVanityURL, v)) } // VanityURLIn applies the In predicate on the "vanity_url" field. func VanityURLIn(vs ...string) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldVanityURL), v...)) - }) + return predicate.Player(sql.FieldIn(FieldVanityURL, vs...)) } // VanityURLNotIn applies the NotIn predicate on the "vanity_url" field. func VanityURLNotIn(vs ...string) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldVanityURL), v...)) - }) + return predicate.Player(sql.FieldNotIn(FieldVanityURL, vs...)) } // VanityURLGT applies the GT predicate on the "vanity_url" field. func VanityURLGT(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldVanityURL), v)) - }) + return predicate.Player(sql.FieldGT(FieldVanityURL, v)) } // VanityURLGTE applies the GTE predicate on the "vanity_url" field. func VanityURLGTE(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldVanityURL), v)) - }) + return predicate.Player(sql.FieldGTE(FieldVanityURL, v)) } // VanityURLLT applies the LT predicate on the "vanity_url" field. func VanityURLLT(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldVanityURL), v)) - }) + return predicate.Player(sql.FieldLT(FieldVanityURL, v)) } // VanityURLLTE applies the LTE predicate on the "vanity_url" field. func VanityURLLTE(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldVanityURL), v)) - }) + return predicate.Player(sql.FieldLTE(FieldVanityURL, v)) } // VanityURLContains applies the Contains predicate on the "vanity_url" field. func VanityURLContains(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldVanityURL), v)) - }) + return predicate.Player(sql.FieldContains(FieldVanityURL, v)) } // VanityURLHasPrefix applies the HasPrefix predicate on the "vanity_url" field. func VanityURLHasPrefix(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldVanityURL), v)) - }) + return predicate.Player(sql.FieldHasPrefix(FieldVanityURL, v)) } // VanityURLHasSuffix applies the HasSuffix predicate on the "vanity_url" field. func VanityURLHasSuffix(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldVanityURL), v)) - }) + return predicate.Player(sql.FieldHasSuffix(FieldVanityURL, v)) } // VanityURLIsNil applies the IsNil predicate on the "vanity_url" field. func VanityURLIsNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldVanityURL))) - }) + return predicate.Player(sql.FieldIsNull(FieldVanityURL)) } // VanityURLNotNil applies the NotNil predicate on the "vanity_url" field. func VanityURLNotNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldVanityURL))) - }) + return predicate.Player(sql.FieldNotNull(FieldVanityURL)) } // VanityURLEqualFold applies the EqualFold predicate on the "vanity_url" field. func VanityURLEqualFold(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldVanityURL), v)) - }) + return predicate.Player(sql.FieldEqualFold(FieldVanityURL, v)) } // VanityURLContainsFold applies the ContainsFold predicate on the "vanity_url" field. func VanityURLContainsFold(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldVanityURL), v)) - }) + return predicate.Player(sql.FieldContainsFold(FieldVanityURL, v)) } // VanityURLRealEQ applies the EQ predicate on the "vanity_url_real" field. func VanityURLRealEQ(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldVanityURLReal), v)) - }) + return predicate.Player(sql.FieldEQ(FieldVanityURLReal, v)) } // VanityURLRealNEQ applies the NEQ predicate on the "vanity_url_real" field. func VanityURLRealNEQ(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldVanityURLReal), v)) - }) + return predicate.Player(sql.FieldNEQ(FieldVanityURLReal, v)) } // VanityURLRealIn applies the In predicate on the "vanity_url_real" field. func VanityURLRealIn(vs ...string) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldVanityURLReal), v...)) - }) + return predicate.Player(sql.FieldIn(FieldVanityURLReal, vs...)) } // VanityURLRealNotIn applies the NotIn predicate on the "vanity_url_real" field. func VanityURLRealNotIn(vs ...string) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldVanityURLReal), v...)) - }) + return predicate.Player(sql.FieldNotIn(FieldVanityURLReal, vs...)) } // VanityURLRealGT applies the GT predicate on the "vanity_url_real" field. func VanityURLRealGT(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldVanityURLReal), v)) - }) + return predicate.Player(sql.FieldGT(FieldVanityURLReal, v)) } // VanityURLRealGTE applies the GTE predicate on the "vanity_url_real" field. func VanityURLRealGTE(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldVanityURLReal), v)) - }) + return predicate.Player(sql.FieldGTE(FieldVanityURLReal, v)) } // VanityURLRealLT applies the LT predicate on the "vanity_url_real" field. func VanityURLRealLT(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldVanityURLReal), v)) - }) + return predicate.Player(sql.FieldLT(FieldVanityURLReal, v)) } // VanityURLRealLTE applies the LTE predicate on the "vanity_url_real" field. func VanityURLRealLTE(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldVanityURLReal), v)) - }) + return predicate.Player(sql.FieldLTE(FieldVanityURLReal, v)) } // VanityURLRealContains applies the Contains predicate on the "vanity_url_real" field. func VanityURLRealContains(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldVanityURLReal), v)) - }) + return predicate.Player(sql.FieldContains(FieldVanityURLReal, v)) } // VanityURLRealHasPrefix applies the HasPrefix predicate on the "vanity_url_real" field. func VanityURLRealHasPrefix(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldVanityURLReal), v)) - }) + return predicate.Player(sql.FieldHasPrefix(FieldVanityURLReal, v)) } // VanityURLRealHasSuffix applies the HasSuffix predicate on the "vanity_url_real" field. func VanityURLRealHasSuffix(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldVanityURLReal), v)) - }) + return predicate.Player(sql.FieldHasSuffix(FieldVanityURLReal, v)) } // VanityURLRealIsNil applies the IsNil predicate on the "vanity_url_real" field. func VanityURLRealIsNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldVanityURLReal))) - }) + return predicate.Player(sql.FieldIsNull(FieldVanityURLReal)) } // VanityURLRealNotNil applies the NotNil predicate on the "vanity_url_real" field. func VanityURLRealNotNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldVanityURLReal))) - }) + return predicate.Player(sql.FieldNotNull(FieldVanityURLReal)) } // VanityURLRealEqualFold applies the EqualFold predicate on the "vanity_url_real" field. func VanityURLRealEqualFold(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldVanityURLReal), v)) - }) + return predicate.Player(sql.FieldEqualFold(FieldVanityURLReal, v)) } // VanityURLRealContainsFold applies the ContainsFold predicate on the "vanity_url_real" field. func VanityURLRealContainsFold(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldVanityURLReal), v)) - }) + return predicate.Player(sql.FieldContainsFold(FieldVanityURLReal, v)) } // VacDateEQ applies the EQ predicate on the "vac_date" field. func VacDateEQ(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldVacDate), v)) - }) + return predicate.Player(sql.FieldEQ(FieldVacDate, v)) } // VacDateNEQ applies the NEQ predicate on the "vac_date" field. func VacDateNEQ(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldVacDate), v)) - }) + return predicate.Player(sql.FieldNEQ(FieldVacDate, v)) } // VacDateIn applies the In predicate on the "vac_date" field. func VacDateIn(vs ...time.Time) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldVacDate), v...)) - }) + return predicate.Player(sql.FieldIn(FieldVacDate, vs...)) } // VacDateNotIn applies the NotIn predicate on the "vac_date" field. func VacDateNotIn(vs ...time.Time) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldVacDate), v...)) - }) + return predicate.Player(sql.FieldNotIn(FieldVacDate, vs...)) } // VacDateGT applies the GT predicate on the "vac_date" field. func VacDateGT(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldVacDate), v)) - }) + return predicate.Player(sql.FieldGT(FieldVacDate, v)) } // VacDateGTE applies the GTE predicate on the "vac_date" field. func VacDateGTE(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldVacDate), v)) - }) + return predicate.Player(sql.FieldGTE(FieldVacDate, v)) } // VacDateLT applies the LT predicate on the "vac_date" field. func VacDateLT(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldVacDate), v)) - }) + return predicate.Player(sql.FieldLT(FieldVacDate, v)) } // VacDateLTE applies the LTE predicate on the "vac_date" field. func VacDateLTE(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldVacDate), v)) - }) + return predicate.Player(sql.FieldLTE(FieldVacDate, v)) } // VacDateIsNil applies the IsNil predicate on the "vac_date" field. func VacDateIsNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldVacDate))) - }) + return predicate.Player(sql.FieldIsNull(FieldVacDate)) } // VacDateNotNil applies the NotNil predicate on the "vac_date" field. func VacDateNotNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldVacDate))) - }) + return predicate.Player(sql.FieldNotNull(FieldVacDate)) } // VacCountEQ applies the EQ predicate on the "vac_count" field. func VacCountEQ(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldVacCount), v)) - }) + return predicate.Player(sql.FieldEQ(FieldVacCount, v)) } // VacCountNEQ applies the NEQ predicate on the "vac_count" field. func VacCountNEQ(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldVacCount), v)) - }) + return predicate.Player(sql.FieldNEQ(FieldVacCount, v)) } // VacCountIn applies the In predicate on the "vac_count" field. func VacCountIn(vs ...int) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldVacCount), v...)) - }) + return predicate.Player(sql.FieldIn(FieldVacCount, vs...)) } // VacCountNotIn applies the NotIn predicate on the "vac_count" field. func VacCountNotIn(vs ...int) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldVacCount), v...)) - }) + return predicate.Player(sql.FieldNotIn(FieldVacCount, vs...)) } // VacCountGT applies the GT predicate on the "vac_count" field. func VacCountGT(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldVacCount), v)) - }) + return predicate.Player(sql.FieldGT(FieldVacCount, v)) } // VacCountGTE applies the GTE predicate on the "vac_count" field. func VacCountGTE(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldVacCount), v)) - }) + return predicate.Player(sql.FieldGTE(FieldVacCount, v)) } // VacCountLT applies the LT predicate on the "vac_count" field. func VacCountLT(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldVacCount), v)) - }) + return predicate.Player(sql.FieldLT(FieldVacCount, v)) } // VacCountLTE applies the LTE predicate on the "vac_count" field. func VacCountLTE(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldVacCount), v)) - }) + return predicate.Player(sql.FieldLTE(FieldVacCount, v)) } // VacCountIsNil applies the IsNil predicate on the "vac_count" field. func VacCountIsNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldVacCount))) - }) + return predicate.Player(sql.FieldIsNull(FieldVacCount)) } // VacCountNotNil applies the NotNil predicate on the "vac_count" field. func VacCountNotNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldVacCount))) - }) + return predicate.Player(sql.FieldNotNull(FieldVacCount)) } // GameBanDateEQ applies the EQ predicate on the "game_ban_date" field. func GameBanDateEQ(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldGameBanDate), v)) - }) + return predicate.Player(sql.FieldEQ(FieldGameBanDate, v)) } // GameBanDateNEQ applies the NEQ predicate on the "game_ban_date" field. func GameBanDateNEQ(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldGameBanDate), v)) - }) + return predicate.Player(sql.FieldNEQ(FieldGameBanDate, v)) } // GameBanDateIn applies the In predicate on the "game_ban_date" field. func GameBanDateIn(vs ...time.Time) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldGameBanDate), v...)) - }) + return predicate.Player(sql.FieldIn(FieldGameBanDate, vs...)) } // GameBanDateNotIn applies the NotIn predicate on the "game_ban_date" field. func GameBanDateNotIn(vs ...time.Time) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldGameBanDate), v...)) - }) + return predicate.Player(sql.FieldNotIn(FieldGameBanDate, vs...)) } // GameBanDateGT applies the GT predicate on the "game_ban_date" field. func GameBanDateGT(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldGameBanDate), v)) - }) + return predicate.Player(sql.FieldGT(FieldGameBanDate, v)) } // GameBanDateGTE applies the GTE predicate on the "game_ban_date" field. func GameBanDateGTE(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldGameBanDate), v)) - }) + return predicate.Player(sql.FieldGTE(FieldGameBanDate, v)) } // GameBanDateLT applies the LT predicate on the "game_ban_date" field. func GameBanDateLT(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldGameBanDate), v)) - }) + return predicate.Player(sql.FieldLT(FieldGameBanDate, v)) } // GameBanDateLTE applies the LTE predicate on the "game_ban_date" field. func GameBanDateLTE(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldGameBanDate), v)) - }) + return predicate.Player(sql.FieldLTE(FieldGameBanDate, v)) } // GameBanDateIsNil applies the IsNil predicate on the "game_ban_date" field. func GameBanDateIsNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldGameBanDate))) - }) + return predicate.Player(sql.FieldIsNull(FieldGameBanDate)) } // GameBanDateNotNil applies the NotNil predicate on the "game_ban_date" field. func GameBanDateNotNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldGameBanDate))) - }) + return predicate.Player(sql.FieldNotNull(FieldGameBanDate)) } // GameBanCountEQ applies the EQ predicate on the "game_ban_count" field. func GameBanCountEQ(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldGameBanCount), v)) - }) + return predicate.Player(sql.FieldEQ(FieldGameBanCount, v)) } // GameBanCountNEQ applies the NEQ predicate on the "game_ban_count" field. func GameBanCountNEQ(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldGameBanCount), v)) - }) + return predicate.Player(sql.FieldNEQ(FieldGameBanCount, v)) } // GameBanCountIn applies the In predicate on the "game_ban_count" field. func GameBanCountIn(vs ...int) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldGameBanCount), v...)) - }) + return predicate.Player(sql.FieldIn(FieldGameBanCount, vs...)) } // GameBanCountNotIn applies the NotIn predicate on the "game_ban_count" field. func GameBanCountNotIn(vs ...int) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldGameBanCount), v...)) - }) + return predicate.Player(sql.FieldNotIn(FieldGameBanCount, vs...)) } // GameBanCountGT applies the GT predicate on the "game_ban_count" field. func GameBanCountGT(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldGameBanCount), v)) - }) + return predicate.Player(sql.FieldGT(FieldGameBanCount, v)) } // GameBanCountGTE applies the GTE predicate on the "game_ban_count" field. func GameBanCountGTE(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldGameBanCount), v)) - }) + return predicate.Player(sql.FieldGTE(FieldGameBanCount, v)) } // GameBanCountLT applies the LT predicate on the "game_ban_count" field. func GameBanCountLT(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldGameBanCount), v)) - }) + return predicate.Player(sql.FieldLT(FieldGameBanCount, v)) } // GameBanCountLTE applies the LTE predicate on the "game_ban_count" field. func GameBanCountLTE(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldGameBanCount), v)) - }) + return predicate.Player(sql.FieldLTE(FieldGameBanCount, v)) } // GameBanCountIsNil applies the IsNil predicate on the "game_ban_count" field. func GameBanCountIsNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldGameBanCount))) - }) + return predicate.Player(sql.FieldIsNull(FieldGameBanCount)) } // GameBanCountNotNil applies the NotNil predicate on the "game_ban_count" field. func GameBanCountNotNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldGameBanCount))) - }) + return predicate.Player(sql.FieldNotNull(FieldGameBanCount)) } // SteamUpdatedEQ applies the EQ predicate on the "steam_updated" field. func SteamUpdatedEQ(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldSteamUpdated), v)) - }) + return predicate.Player(sql.FieldEQ(FieldSteamUpdated, v)) } // SteamUpdatedNEQ applies the NEQ predicate on the "steam_updated" field. func SteamUpdatedNEQ(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldSteamUpdated), v)) - }) + return predicate.Player(sql.FieldNEQ(FieldSteamUpdated, v)) } // SteamUpdatedIn applies the In predicate on the "steam_updated" field. func SteamUpdatedIn(vs ...time.Time) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldSteamUpdated), v...)) - }) + return predicate.Player(sql.FieldIn(FieldSteamUpdated, vs...)) } // SteamUpdatedNotIn applies the NotIn predicate on the "steam_updated" field. func SteamUpdatedNotIn(vs ...time.Time) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldSteamUpdated), v...)) - }) + return predicate.Player(sql.FieldNotIn(FieldSteamUpdated, vs...)) } // SteamUpdatedGT applies the GT predicate on the "steam_updated" field. func SteamUpdatedGT(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldSteamUpdated), v)) - }) + return predicate.Player(sql.FieldGT(FieldSteamUpdated, v)) } // SteamUpdatedGTE applies the GTE predicate on the "steam_updated" field. func SteamUpdatedGTE(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldSteamUpdated), v)) - }) + return predicate.Player(sql.FieldGTE(FieldSteamUpdated, v)) } // SteamUpdatedLT applies the LT predicate on the "steam_updated" field. func SteamUpdatedLT(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldSteamUpdated), v)) - }) + return predicate.Player(sql.FieldLT(FieldSteamUpdated, v)) } // SteamUpdatedLTE applies the LTE predicate on the "steam_updated" field. func SteamUpdatedLTE(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldSteamUpdated), v)) - }) + return predicate.Player(sql.FieldLTE(FieldSteamUpdated, v)) } // SharecodeUpdatedEQ applies the EQ predicate on the "sharecode_updated" field. func SharecodeUpdatedEQ(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldSharecodeUpdated), v)) - }) + return predicate.Player(sql.FieldEQ(FieldSharecodeUpdated, v)) } // SharecodeUpdatedNEQ applies the NEQ predicate on the "sharecode_updated" field. func SharecodeUpdatedNEQ(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldSharecodeUpdated), v)) - }) + return predicate.Player(sql.FieldNEQ(FieldSharecodeUpdated, v)) } // SharecodeUpdatedIn applies the In predicate on the "sharecode_updated" field. func SharecodeUpdatedIn(vs ...time.Time) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldSharecodeUpdated), v...)) - }) + return predicate.Player(sql.FieldIn(FieldSharecodeUpdated, vs...)) } // SharecodeUpdatedNotIn applies the NotIn predicate on the "sharecode_updated" field. func SharecodeUpdatedNotIn(vs ...time.Time) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldSharecodeUpdated), v...)) - }) + return predicate.Player(sql.FieldNotIn(FieldSharecodeUpdated, vs...)) } // SharecodeUpdatedGT applies the GT predicate on the "sharecode_updated" field. func SharecodeUpdatedGT(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldSharecodeUpdated), v)) - }) + return predicate.Player(sql.FieldGT(FieldSharecodeUpdated, v)) } // SharecodeUpdatedGTE applies the GTE predicate on the "sharecode_updated" field. func SharecodeUpdatedGTE(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldSharecodeUpdated), v)) - }) + return predicate.Player(sql.FieldGTE(FieldSharecodeUpdated, v)) } // SharecodeUpdatedLT applies the LT predicate on the "sharecode_updated" field. func SharecodeUpdatedLT(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldSharecodeUpdated), v)) - }) + return predicate.Player(sql.FieldLT(FieldSharecodeUpdated, v)) } // SharecodeUpdatedLTE applies the LTE predicate on the "sharecode_updated" field. func SharecodeUpdatedLTE(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldSharecodeUpdated), v)) - }) + return predicate.Player(sql.FieldLTE(FieldSharecodeUpdated, v)) } // SharecodeUpdatedIsNil applies the IsNil predicate on the "sharecode_updated" field. func SharecodeUpdatedIsNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldSharecodeUpdated))) - }) + return predicate.Player(sql.FieldIsNull(FieldSharecodeUpdated)) } // SharecodeUpdatedNotNil applies the NotNil predicate on the "sharecode_updated" field. func SharecodeUpdatedNotNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldSharecodeUpdated))) - }) + return predicate.Player(sql.FieldNotNull(FieldSharecodeUpdated)) } // AuthCodeEQ applies the EQ predicate on the "auth_code" field. func AuthCodeEQ(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldAuthCode), v)) - }) + return predicate.Player(sql.FieldEQ(FieldAuthCode, v)) } // AuthCodeNEQ applies the NEQ predicate on the "auth_code" field. func AuthCodeNEQ(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldAuthCode), v)) - }) + return predicate.Player(sql.FieldNEQ(FieldAuthCode, v)) } // AuthCodeIn applies the In predicate on the "auth_code" field. func AuthCodeIn(vs ...string) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldAuthCode), v...)) - }) + return predicate.Player(sql.FieldIn(FieldAuthCode, vs...)) } // AuthCodeNotIn applies the NotIn predicate on the "auth_code" field. func AuthCodeNotIn(vs ...string) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldAuthCode), v...)) - }) + return predicate.Player(sql.FieldNotIn(FieldAuthCode, vs...)) } // AuthCodeGT applies the GT predicate on the "auth_code" field. func AuthCodeGT(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldAuthCode), v)) - }) + return predicate.Player(sql.FieldGT(FieldAuthCode, v)) } // AuthCodeGTE applies the GTE predicate on the "auth_code" field. func AuthCodeGTE(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldAuthCode), v)) - }) + return predicate.Player(sql.FieldGTE(FieldAuthCode, v)) } // AuthCodeLT applies the LT predicate on the "auth_code" field. func AuthCodeLT(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldAuthCode), v)) - }) + return predicate.Player(sql.FieldLT(FieldAuthCode, v)) } // AuthCodeLTE applies the LTE predicate on the "auth_code" field. func AuthCodeLTE(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldAuthCode), v)) - }) + return predicate.Player(sql.FieldLTE(FieldAuthCode, v)) } // AuthCodeContains applies the Contains predicate on the "auth_code" field. func AuthCodeContains(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldAuthCode), v)) - }) + return predicate.Player(sql.FieldContains(FieldAuthCode, v)) } // AuthCodeHasPrefix applies the HasPrefix predicate on the "auth_code" field. func AuthCodeHasPrefix(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldAuthCode), v)) - }) + return predicate.Player(sql.FieldHasPrefix(FieldAuthCode, v)) } // AuthCodeHasSuffix applies the HasSuffix predicate on the "auth_code" field. func AuthCodeHasSuffix(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldAuthCode), v)) - }) + return predicate.Player(sql.FieldHasSuffix(FieldAuthCode, v)) } // AuthCodeIsNil applies the IsNil predicate on the "auth_code" field. func AuthCodeIsNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldAuthCode))) - }) + return predicate.Player(sql.FieldIsNull(FieldAuthCode)) } // AuthCodeNotNil applies the NotNil predicate on the "auth_code" field. func AuthCodeNotNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldAuthCode))) - }) + return predicate.Player(sql.FieldNotNull(FieldAuthCode)) } // AuthCodeEqualFold applies the EqualFold predicate on the "auth_code" field. func AuthCodeEqualFold(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldAuthCode), v)) - }) + return predicate.Player(sql.FieldEqualFold(FieldAuthCode, v)) } // AuthCodeContainsFold applies the ContainsFold predicate on the "auth_code" field. func AuthCodeContainsFold(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldAuthCode), v)) - }) + return predicate.Player(sql.FieldContainsFold(FieldAuthCode, v)) } // ProfileCreatedEQ applies the EQ predicate on the "profile_created" field. func ProfileCreatedEQ(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldProfileCreated), v)) - }) + return predicate.Player(sql.FieldEQ(FieldProfileCreated, v)) } // ProfileCreatedNEQ applies the NEQ predicate on the "profile_created" field. func ProfileCreatedNEQ(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldProfileCreated), v)) - }) + return predicate.Player(sql.FieldNEQ(FieldProfileCreated, v)) } // ProfileCreatedIn applies the In predicate on the "profile_created" field. func ProfileCreatedIn(vs ...time.Time) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldProfileCreated), v...)) - }) + return predicate.Player(sql.FieldIn(FieldProfileCreated, vs...)) } // ProfileCreatedNotIn applies the NotIn predicate on the "profile_created" field. func ProfileCreatedNotIn(vs ...time.Time) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldProfileCreated), v...)) - }) + return predicate.Player(sql.FieldNotIn(FieldProfileCreated, vs...)) } // ProfileCreatedGT applies the GT predicate on the "profile_created" field. func ProfileCreatedGT(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldProfileCreated), v)) - }) + return predicate.Player(sql.FieldGT(FieldProfileCreated, v)) } // ProfileCreatedGTE applies the GTE predicate on the "profile_created" field. func ProfileCreatedGTE(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldProfileCreated), v)) - }) + return predicate.Player(sql.FieldGTE(FieldProfileCreated, v)) } // ProfileCreatedLT applies the LT predicate on the "profile_created" field. func ProfileCreatedLT(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldProfileCreated), v)) - }) + return predicate.Player(sql.FieldLT(FieldProfileCreated, v)) } // ProfileCreatedLTE applies the LTE predicate on the "profile_created" field. func ProfileCreatedLTE(v time.Time) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldProfileCreated), v)) - }) + return predicate.Player(sql.FieldLTE(FieldProfileCreated, v)) } // ProfileCreatedIsNil applies the IsNil predicate on the "profile_created" field. func ProfileCreatedIsNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldProfileCreated))) - }) + return predicate.Player(sql.FieldIsNull(FieldProfileCreated)) } // ProfileCreatedNotNil applies the NotNil predicate on the "profile_created" field. func ProfileCreatedNotNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldProfileCreated))) - }) + return predicate.Player(sql.FieldNotNull(FieldProfileCreated)) } // OldestSharecodeSeenEQ applies the EQ predicate on the "oldest_sharecode_seen" field. func OldestSharecodeSeenEQ(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldOldestSharecodeSeen), v)) - }) + return predicate.Player(sql.FieldEQ(FieldOldestSharecodeSeen, v)) } // OldestSharecodeSeenNEQ applies the NEQ predicate on the "oldest_sharecode_seen" field. func OldestSharecodeSeenNEQ(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldOldestSharecodeSeen), v)) - }) + return predicate.Player(sql.FieldNEQ(FieldOldestSharecodeSeen, v)) } // OldestSharecodeSeenIn applies the In predicate on the "oldest_sharecode_seen" field. func OldestSharecodeSeenIn(vs ...string) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldOldestSharecodeSeen), v...)) - }) + return predicate.Player(sql.FieldIn(FieldOldestSharecodeSeen, vs...)) } // OldestSharecodeSeenNotIn applies the NotIn predicate on the "oldest_sharecode_seen" field. func OldestSharecodeSeenNotIn(vs ...string) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldOldestSharecodeSeen), v...)) - }) + return predicate.Player(sql.FieldNotIn(FieldOldestSharecodeSeen, vs...)) } // OldestSharecodeSeenGT applies the GT predicate on the "oldest_sharecode_seen" field. func OldestSharecodeSeenGT(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldOldestSharecodeSeen), v)) - }) + return predicate.Player(sql.FieldGT(FieldOldestSharecodeSeen, v)) } // OldestSharecodeSeenGTE applies the GTE predicate on the "oldest_sharecode_seen" field. func OldestSharecodeSeenGTE(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldOldestSharecodeSeen), v)) - }) + return predicate.Player(sql.FieldGTE(FieldOldestSharecodeSeen, v)) } // OldestSharecodeSeenLT applies the LT predicate on the "oldest_sharecode_seen" field. func OldestSharecodeSeenLT(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldOldestSharecodeSeen), v)) - }) + return predicate.Player(sql.FieldLT(FieldOldestSharecodeSeen, v)) } // OldestSharecodeSeenLTE applies the LTE predicate on the "oldest_sharecode_seen" field. func OldestSharecodeSeenLTE(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldOldestSharecodeSeen), v)) - }) + return predicate.Player(sql.FieldLTE(FieldOldestSharecodeSeen, v)) } // OldestSharecodeSeenContains applies the Contains predicate on the "oldest_sharecode_seen" field. func OldestSharecodeSeenContains(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.Contains(s.C(FieldOldestSharecodeSeen), v)) - }) + return predicate.Player(sql.FieldContains(FieldOldestSharecodeSeen, v)) } // OldestSharecodeSeenHasPrefix applies the HasPrefix predicate on the "oldest_sharecode_seen" field. func OldestSharecodeSeenHasPrefix(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.HasPrefix(s.C(FieldOldestSharecodeSeen), v)) - }) + return predicate.Player(sql.FieldHasPrefix(FieldOldestSharecodeSeen, v)) } // OldestSharecodeSeenHasSuffix applies the HasSuffix predicate on the "oldest_sharecode_seen" field. func OldestSharecodeSeenHasSuffix(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.HasSuffix(s.C(FieldOldestSharecodeSeen), v)) - }) + return predicate.Player(sql.FieldHasSuffix(FieldOldestSharecodeSeen, v)) } // OldestSharecodeSeenIsNil applies the IsNil predicate on the "oldest_sharecode_seen" field. func OldestSharecodeSeenIsNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldOldestSharecodeSeen))) - }) + return predicate.Player(sql.FieldIsNull(FieldOldestSharecodeSeen)) } // OldestSharecodeSeenNotNil applies the NotNil predicate on the "oldest_sharecode_seen" field. func OldestSharecodeSeenNotNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldOldestSharecodeSeen))) - }) + return predicate.Player(sql.FieldNotNull(FieldOldestSharecodeSeen)) } // OldestSharecodeSeenEqualFold applies the EqualFold predicate on the "oldest_sharecode_seen" field. func OldestSharecodeSeenEqualFold(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EqualFold(s.C(FieldOldestSharecodeSeen), v)) - }) + return predicate.Player(sql.FieldEqualFold(FieldOldestSharecodeSeen, v)) } // OldestSharecodeSeenContainsFold applies the ContainsFold predicate on the "oldest_sharecode_seen" field. func OldestSharecodeSeenContainsFold(v string) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.ContainsFold(s.C(FieldOldestSharecodeSeen), v)) - }) + return predicate.Player(sql.FieldContainsFold(FieldOldestSharecodeSeen, v)) } // WinsEQ applies the EQ predicate on the "wins" field. func WinsEQ(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldWins), v)) - }) + return predicate.Player(sql.FieldEQ(FieldWins, v)) } // WinsNEQ applies the NEQ predicate on the "wins" field. func WinsNEQ(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldWins), v)) - }) + return predicate.Player(sql.FieldNEQ(FieldWins, v)) } // WinsIn applies the In predicate on the "wins" field. func WinsIn(vs ...int) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldWins), v...)) - }) + return predicate.Player(sql.FieldIn(FieldWins, vs...)) } // WinsNotIn applies the NotIn predicate on the "wins" field. func WinsNotIn(vs ...int) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldWins), v...)) - }) + return predicate.Player(sql.FieldNotIn(FieldWins, vs...)) } // WinsGT applies the GT predicate on the "wins" field. func WinsGT(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldWins), v)) - }) + return predicate.Player(sql.FieldGT(FieldWins, v)) } // WinsGTE applies the GTE predicate on the "wins" field. func WinsGTE(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldWins), v)) - }) + return predicate.Player(sql.FieldGTE(FieldWins, v)) } // WinsLT applies the LT predicate on the "wins" field. func WinsLT(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldWins), v)) - }) + return predicate.Player(sql.FieldLT(FieldWins, v)) } // WinsLTE applies the LTE predicate on the "wins" field. func WinsLTE(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldWins), v)) - }) + return predicate.Player(sql.FieldLTE(FieldWins, v)) } // WinsIsNil applies the IsNil predicate on the "wins" field. func WinsIsNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldWins))) - }) + return predicate.Player(sql.FieldIsNull(FieldWins)) } // WinsNotNil applies the NotNil predicate on the "wins" field. func WinsNotNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldWins))) - }) + return predicate.Player(sql.FieldNotNull(FieldWins)) } // LoosesEQ applies the EQ predicate on the "looses" field. func LoosesEQ(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldLooses), v)) - }) + return predicate.Player(sql.FieldEQ(FieldLooses, v)) } // LoosesNEQ applies the NEQ predicate on the "looses" field. func LoosesNEQ(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldLooses), v)) - }) + return predicate.Player(sql.FieldNEQ(FieldLooses, v)) } // LoosesIn applies the In predicate on the "looses" field. func LoosesIn(vs ...int) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldLooses), v...)) - }) + return predicate.Player(sql.FieldIn(FieldLooses, vs...)) } // LoosesNotIn applies the NotIn predicate on the "looses" field. func LoosesNotIn(vs ...int) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldLooses), v...)) - }) + return predicate.Player(sql.FieldNotIn(FieldLooses, vs...)) } // LoosesGT applies the GT predicate on the "looses" field. func LoosesGT(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldLooses), v)) - }) + return predicate.Player(sql.FieldGT(FieldLooses, v)) } // LoosesGTE applies the GTE predicate on the "looses" field. func LoosesGTE(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldLooses), v)) - }) + return predicate.Player(sql.FieldGTE(FieldLooses, v)) } // LoosesLT applies the LT predicate on the "looses" field. func LoosesLT(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldLooses), v)) - }) + return predicate.Player(sql.FieldLT(FieldLooses, v)) } // LoosesLTE applies the LTE predicate on the "looses" field. func LoosesLTE(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldLooses), v)) - }) + return predicate.Player(sql.FieldLTE(FieldLooses, v)) } // LoosesIsNil applies the IsNil predicate on the "looses" field. func LoosesIsNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldLooses))) - }) + return predicate.Player(sql.FieldIsNull(FieldLooses)) } // LoosesNotNil applies the NotNil predicate on the "looses" field. func LoosesNotNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldLooses))) - }) + return predicate.Player(sql.FieldNotNull(FieldLooses)) } // TiesEQ applies the EQ predicate on the "ties" field. func TiesEQ(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldTies), v)) - }) + return predicate.Player(sql.FieldEQ(FieldTies, v)) } // TiesNEQ applies the NEQ predicate on the "ties" field. func TiesNEQ(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldTies), v)) - }) + return predicate.Player(sql.FieldNEQ(FieldTies, v)) } // TiesIn applies the In predicate on the "ties" field. func TiesIn(vs ...int) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldTies), v...)) - }) + return predicate.Player(sql.FieldIn(FieldTies, vs...)) } // TiesNotIn applies the NotIn predicate on the "ties" field. func TiesNotIn(vs ...int) predicate.Player { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldTies), v...)) - }) + return predicate.Player(sql.FieldNotIn(FieldTies, vs...)) } // TiesGT applies the GT predicate on the "ties" field. func TiesGT(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldTies), v)) - }) + return predicate.Player(sql.FieldGT(FieldTies, v)) } // TiesGTE applies the GTE predicate on the "ties" field. func TiesGTE(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldTies), v)) - }) + return predicate.Player(sql.FieldGTE(FieldTies, v)) } // TiesLT applies the LT predicate on the "ties" field. func TiesLT(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldTies), v)) - }) + return predicate.Player(sql.FieldLT(FieldTies, v)) } // TiesLTE applies the LTE predicate on the "ties" field. func TiesLTE(v int) predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldTies), v)) - }) + return predicate.Player(sql.FieldLTE(FieldTies, v)) } // TiesIsNil applies the IsNil predicate on the "ties" field. func TiesIsNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.IsNull(s.C(FieldTies))) - }) + return predicate.Player(sql.FieldIsNull(FieldTies)) } // TiesNotNil applies the NotNil predicate on the "ties" field. func TiesNotNil() predicate.Player { - return predicate.Player(func(s *sql.Selector) { - s.Where(sql.NotNull(s.C(FieldTies))) - }) + return predicate.Player(sql.FieldNotNull(FieldTies)) } // HasStats applies the HasEdge predicate on the "stats" edge. @@ -1642,7 +1080,6 @@ func HasStats() predicate.Player { return predicate.Player(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(StatsTable, FieldID), sqlgraph.Edge(sqlgraph.O2M, false, StatsTable, StatsColumn), ) sqlgraph.HasNeighbors(s, step) @@ -1670,7 +1107,6 @@ func HasMatches() predicate.Player { return predicate.Player(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(MatchesTable, FieldID), sqlgraph.Edge(sqlgraph.M2M, false, MatchesTable, MatchesPrimaryKey...), ) sqlgraph.HasNeighbors(s, step) diff --git a/ent/player_create.go b/ent/player_create.go index e6bf009..73a2da9 100644 --- a/ent/player_create.go +++ b/ent/player_create.go @@ -289,50 +289,8 @@ func (pc *PlayerCreate) Mutation() *PlayerMutation { // Save creates the Player in the database. func (pc *PlayerCreate) Save(ctx context.Context) (*Player, error) { - var ( - err error - node *Player - ) pc.defaults() - if len(pc.hooks) == 0 { - if err = pc.check(); err != nil { - return nil, err - } - node, err = pc.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*PlayerMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err = pc.check(); err != nil { - return nil, err - } - pc.mutation = mutation - if node, err = pc.sqlSave(ctx); err != nil { - return nil, err - } - mutation.id = &node.ID - mutation.done = true - return node, err - }) - for i := len(pc.hooks) - 1; i >= 0; i-- { - if pc.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = pc.hooks[i](mut) - } - v, err := mut.Mutate(ctx, pc.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*Player) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from PlayerMutation", v) - } - node = nv - } - return node, err + return withHooks[*Player, PlayerMutation](ctx, pc.sqlSave, pc.mutation, pc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -374,6 +332,9 @@ func (pc *PlayerCreate) check() error { } func (pc *PlayerCreate) sqlSave(ctx context.Context) (*Player, error) { + if err := pc.check(); err != nil { + return nil, err + } _node, _spec := pc.createSpec() if err := sqlgraph.CreateNode(ctx, pc.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { @@ -385,19 +346,15 @@ 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 return _node, nil } func (pc *PlayerCreate) createSpec() (*Player, *sqlgraph.CreateSpec) { var ( _node = &Player{config: pc.config} - _spec = &sqlgraph.CreateSpec{ - Table: player.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeUint64, - Column: player.FieldID, - }, - } + _spec = sqlgraph.NewCreateSpec(player.Table, sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64)) ) if id, ok := pc.mutation.ID(); ok { _node.ID = id diff --git a/ent/player_delete.go b/ent/player_delete.go index 0b371e6..b995e51 100644 --- a/ent/player_delete.go +++ b/ent/player_delete.go @@ -4,7 +4,6 @@ package ent import ( "context" - "fmt" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -28,34 +27,7 @@ func (pd *PlayerDelete) Where(ps ...predicate.Player) *PlayerDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (pd *PlayerDelete) Exec(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(pd.hooks) == 0 { - affected, err = pd.sqlExec(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*PlayerMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - pd.mutation = mutation - affected, err = pd.sqlExec(ctx) - mutation.done = true - return affected, err - }) - for i := len(pd.hooks) - 1; i >= 0; i-- { - if pd.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = pd.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, pd.mutation); err != nil { - return 0, err - } - } - return affected, err + return withHooks[int, PlayerMutation](ctx, pd.sqlExec, pd.mutation, pd.hooks) } // ExecX is like Exec, but panics if an error occurs. @@ -68,15 +40,7 @@ func (pd *PlayerDelete) ExecX(ctx context.Context) int { } func (pd *PlayerDelete) sqlExec(ctx context.Context) (int, error) { - _spec := &sqlgraph.DeleteSpec{ - Node: &sqlgraph.NodeSpec{ - Table: player.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeUint64, - Column: player.FieldID, - }, - }, - } + _spec := sqlgraph.NewDeleteSpec(player.Table, sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64)) if ps := pd.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -88,6 +52,7 @@ func (pd *PlayerDelete) sqlExec(ctx context.Context) (int, error) { if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } + pd.mutation.done = true return affected, err } @@ -96,6 +61,12 @@ type PlayerDeleteOne struct { pd *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 +} + // Exec executes the deletion query. func (pdo *PlayerDeleteOne) Exec(ctx context.Context) error { n, err := pdo.pd.Exec(ctx) @@ -111,5 +82,7 @@ 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) { - pdo.pd.ExecX(ctx) + if err := pdo.Exec(ctx); err != nil { + panic(err) + } } diff --git a/ent/player_query.go b/ent/player_query.go index 1b6fa09..a1bda9c 100644 --- a/ent/player_query.go +++ b/ent/player_query.go @@ -20,11 +20,9 @@ import ( // PlayerQuery is the builder for querying Player entities. type PlayerQuery struct { config - limit *int - offset *int - unique *bool + ctx *QueryContext order []OrderFunc - fields []string + inters []Interceptor predicates []predicate.Player withStats *MatchPlayerQuery withMatches *MatchQuery @@ -40,26 +38,26 @@ func (pq *PlayerQuery) Where(ps ...predicate.Player) *PlayerQuery { return pq } -// Limit adds a limit step to the query. +// Limit the number of records to be returned by this query. func (pq *PlayerQuery) Limit(limit int) *PlayerQuery { - pq.limit = &limit + pq.ctx.Limit = &limit return pq } -// Offset adds an offset step to the query. +// Offset to start from. func (pq *PlayerQuery) Offset(offset int) *PlayerQuery { - pq.offset = &offset + pq.ctx.Offset = &offset return pq } // 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.unique = &unique + pq.ctx.Unique = &unique return pq } -// Order adds an order step to the query. +// Order specifies how the records should be ordered. func (pq *PlayerQuery) Order(o ...OrderFunc) *PlayerQuery { pq.order = append(pq.order, o...) return pq @@ -67,7 +65,7 @@ func (pq *PlayerQuery) Order(o ...OrderFunc) *PlayerQuery { // QueryStats chains the current query on the "stats" edge. func (pq *PlayerQuery) QueryStats() *MatchPlayerQuery { - query := &MatchPlayerQuery{config: pq.config} + query := (&MatchPlayerClient{config: pq.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := pq.prepareQuery(ctx); err != nil { return nil, err @@ -89,7 +87,7 @@ func (pq *PlayerQuery) QueryStats() *MatchPlayerQuery { // QueryMatches chains the current query on the "matches" edge. func (pq *PlayerQuery) QueryMatches() *MatchQuery { - query := &MatchQuery{config: pq.config} + query := (&MatchClient{config: pq.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := pq.prepareQuery(ctx); err != nil { return nil, err @@ -112,7 +110,7 @@ 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(ctx) + nodes, err := pq.Limit(1).All(setContextOp(ctx, pq.ctx, "First")) if err != nil { return nil, err } @@ -135,7 +133,7 @@ func (pq *PlayerQuery) FirstX(ctx context.Context) *Player { // Returns a *NotFoundError when no Player ID was found. func (pq *PlayerQuery) FirstID(ctx context.Context) (id uint64, err error) { var ids []uint64 - if ids, err = pq.Limit(1).IDs(ctx); err != nil { + if ids, err = pq.Limit(1).IDs(setContextOp(ctx, pq.ctx, "FirstID")); err != nil { return } if len(ids) == 0 { @@ -158,7 +156,7 @@ func (pq *PlayerQuery) FirstIDX(ctx context.Context) uint64 { // 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(ctx) + nodes, err := pq.Limit(2).All(setContextOp(ctx, pq.ctx, "Only")) if err != nil { return nil, err } @@ -186,7 +184,7 @@ func (pq *PlayerQuery) OnlyX(ctx context.Context) *Player { // Returns a *NotFoundError when no entities are found. func (pq *PlayerQuery) OnlyID(ctx context.Context) (id uint64, err error) { var ids []uint64 - if ids, err = pq.Limit(2).IDs(ctx); err != nil { + if ids, err = pq.Limit(2).IDs(setContextOp(ctx, pq.ctx, "OnlyID")); err != nil { return } switch len(ids) { @@ -211,10 +209,12 @@ 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 { return nil, err } - return pq.sqlAll(ctx) + qr := querierAll[[]*Player, *PlayerQuery]() + return withInterceptors[[]*Player](ctx, pq, qr, pq.inters) } // AllX is like All, but panics if an error occurs. @@ -227,9 +227,12 @@ 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) ([]uint64, error) { - var ids []uint64 - if err := pq.Select(player.FieldID).Scan(ctx, &ids); err != nil { +func (pq *PlayerQuery) IDs(ctx context.Context) (ids []uint64, err error) { + if pq.ctx.Unique == nil && pq.path != nil { + pq.Unique(true) + } + ctx = setContextOp(ctx, pq.ctx, "IDs") + if err = pq.Select(player.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil @@ -246,10 +249,11 @@ 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 { return 0, err } - return pq.sqlCount(ctx) + return withInterceptors[int](ctx, pq, querierCount[*PlayerQuery](), pq.inters) } // CountX is like Count, but panics if an error occurs. @@ -263,10 +267,15 @@ 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) { - if err := pq.prepareQuery(ctx); err != nil { - return false, err + ctx = setContextOp(ctx, pq.ctx, "Exist") + switch _, err := pq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil } - return pq.sqlExist(ctx) } // ExistX is like Exist, but panics if an error occurs. @@ -286,23 +295,22 @@ func (pq *PlayerQuery) Clone() *PlayerQuery { } return &PlayerQuery{ config: pq.config, - limit: pq.limit, - offset: pq.offset, + ctx: pq.ctx.Clone(), order: append([]OrderFunc{}, pq.order...), + inters: append([]Interceptor{}, pq.inters...), predicates: append([]predicate.Player{}, pq.predicates...), withStats: pq.withStats.Clone(), withMatches: pq.withMatches.Clone(), // clone intermediate query. - sql: pq.sql.Clone(), - path: pq.path, - unique: pq.unique, + sql: pq.sql.Clone(), + path: pq.path, } } // 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 := &MatchPlayerQuery{config: pq.config} + query := (&MatchPlayerClient{config: pq.config}).Query() for _, opt := range opts { opt(query) } @@ -313,7 +321,7 @@ func (pq *PlayerQuery) WithStats(opts ...func(*MatchPlayerQuery)) *PlayerQuery { // 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 := &MatchQuery{config: pq.config} + query := (&MatchClient{config: pq.config}).Query() for _, opt := range opts { opt(query) } @@ -336,16 +344,11 @@ func (pq *PlayerQuery) WithMatches(opts ...func(*MatchQuery)) *PlayerQuery { // Aggregate(ent.Count()). // Scan(ctx, &v) func (pq *PlayerQuery) GroupBy(field string, fields ...string) *PlayerGroupBy { - grbuild := &PlayerGroupBy{config: pq.config} - grbuild.fields = append([]string{field}, fields...) - grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { - if err := pq.prepareQuery(ctx); err != nil { - return nil, err - } - return pq.sqlQuery(ctx), nil - } + pq.ctx.Fields = append([]string{field}, fields...) + grbuild := &PlayerGroupBy{build: pq} + grbuild.flds = &pq.ctx.Fields grbuild.label = player.Label - grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan + grbuild.scan = grbuild.Scan return grbuild } @@ -362,11 +365,11 @@ func (pq *PlayerQuery) GroupBy(field string, fields ...string) *PlayerGroupBy { // Select(player.FieldName). // Scan(ctx, &v) func (pq *PlayerQuery) Select(fields ...string) *PlayerSelect { - pq.fields = append(pq.fields, fields...) - selbuild := &PlayerSelect{PlayerQuery: pq} - selbuild.label = player.Label - selbuild.flds, selbuild.scan = &pq.fields, selbuild.Scan - return selbuild + pq.ctx.Fields = append(pq.ctx.Fields, fields...) + sbuild := &PlayerSelect{PlayerQuery: pq} + sbuild.label = player.Label + sbuild.flds, sbuild.scan = &pq.ctx.Fields, sbuild.Scan + return sbuild } // Aggregate returns a PlayerSelect configured with the given aggregations. @@ -375,7 +378,17 @@ func (pq *PlayerQuery) Aggregate(fns ...AggregateFunc) *PlayerSelect { } func (pq *PlayerQuery) prepareQuery(ctx context.Context) error { - for _, f := range pq.fields { + for _, inter := range pq.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 { + return err + } + } + } + for _, f := range pq.ctx.Fields { if !player.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } @@ -487,27 +500,30 @@ func (pq *PlayerQuery) loadMatches(ctx context.Context, query *MatchQuery, nodes if err := query.prepareQuery(ctx); err != nil { return err } - neighbors, err := query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { - assign := spec.Assign - values := spec.ScanValues - spec.ScanValues = func(columns []string) ([]any, error) { - values, err := values(columns[1:]) - if err != nil { - return nil, err + qr := QuerierFunc(func(ctx context.Context, q Query) (Value, error) { + return query.sqlAll(ctx, func(_ context.Context, spec *sqlgraph.QuerySpec) { + assign := spec.Assign + values := spec.ScanValues + spec.ScanValues = func(columns []string) ([]any, error) { + values, err := values(columns[1:]) + if err != nil { + return nil, err + } + return append([]any{new(sql.NullInt64)}, values...), nil } - return append([]any{new(sql.NullInt64)}, values...), nil - } - spec.Assign = func(columns []string, values []any) error { - outValue := uint64(values[0].(*sql.NullInt64).Int64) - inValue := uint64(values[1].(*sql.NullInt64).Int64) - if nids[inValue] == nil { - nids[inValue] = map[*Player]struct{}{byID[outValue]: {}} - return assign(columns[1:], values[1:]) + spec.Assign = func(columns []string, values []any) error { + outValue := uint64(values[0].(*sql.NullInt64).Int64) + inValue := uint64(values[1].(*sql.NullInt64).Int64) + if nids[inValue] == nil { + nids[inValue] = map[*Player]struct{}{byID[outValue]: {}} + return assign(columns[1:], values[1:]) + } + nids[inValue][byID[outValue]] = struct{}{} + return nil } - nids[inValue][byID[outValue]] = struct{}{} - return nil - } + }) }) + neighbors, err := withInterceptors[[]*Match](ctx, query, qr, query.inters) if err != nil { return err } @@ -528,41 +544,22 @@ func (pq *PlayerQuery) sqlCount(ctx context.Context) (int, error) { if len(pq.modifiers) > 0 { _spec.Modifiers = pq.modifiers } - _spec.Node.Columns = pq.fields - if len(pq.fields) > 0 { - _spec.Unique = pq.unique != nil && *pq.unique + _spec.Node.Columns = pq.ctx.Fields + if len(pq.ctx.Fields) > 0 { + _spec.Unique = pq.ctx.Unique != nil && *pq.ctx.Unique } return sqlgraph.CountNodes(ctx, pq.driver, _spec) } -func (pq *PlayerQuery) sqlExist(ctx context.Context) (bool, error) { - switch _, err := pq.FirstID(ctx); { - case IsNotFound(err): - return false, nil - case err != nil: - return false, fmt.Errorf("ent: check existence: %w", err) - default: - return true, nil - } -} - func (pq *PlayerQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: player.Table, - Columns: player.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeUint64, - Column: player.FieldID, - }, - }, - From: pq.sql, - Unique: true, - } - if unique := pq.unique; unique != nil { + _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.Unique = *unique + } else if pq.path != nil { + _spec.Unique = true } - if fields := pq.fields; len(fields) > 0 { + if fields := pq.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 { @@ -578,10 +575,10 @@ func (pq *PlayerQuery) querySpec() *sqlgraph.QuerySpec { } } } - if limit := pq.limit; limit != nil { + if limit := pq.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := pq.offset; offset != nil { + if offset := pq.ctx.Offset; offset != nil { _spec.Offset = *offset } if ps := pq.order; len(ps) > 0 { @@ -597,7 +594,7 @@ func (pq *PlayerQuery) querySpec() *sqlgraph.QuerySpec { func (pq *PlayerQuery) sqlQuery(ctx context.Context) *sql.Selector { builder := sql.Dialect(pq.driver.Dialect()) t1 := builder.Table(player.Table) - columns := pq.fields + columns := pq.ctx.Fields if len(columns) == 0 { columns = player.Columns } @@ -606,7 +603,7 @@ func (pq *PlayerQuery) sqlQuery(ctx context.Context) *sql.Selector { selector = pq.sql selector.Select(selector.Columns(columns...)...) } - if pq.unique != nil && *pq.unique { + if pq.ctx.Unique != nil && *pq.ctx.Unique { selector.Distinct() } for _, m := range pq.modifiers { @@ -618,12 +615,12 @@ func (pq *PlayerQuery) sqlQuery(ctx context.Context) *sql.Selector { for _, p := range pq.order { p(selector) } - if offset := pq.offset; offset != nil { + if offset := pq.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.limit; limit != nil { + if limit := pq.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector @@ -637,13 +634,8 @@ func (pq *PlayerQuery) Modify(modifiers ...func(s *sql.Selector)) *PlayerSelect // PlayerGroupBy is the group-by builder for Player entities. type PlayerGroupBy struct { - config selector - fields []string - fns []AggregateFunc - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) + build *PlayerQuery } // Aggregate adds the given aggregation functions to the group-by query. @@ -652,58 +644,46 @@ func (pgb *PlayerGroupBy) Aggregate(fns ...AggregateFunc) *PlayerGroupBy { return pgb } -// Scan applies the group-by query and scans the result into the given value. +// Scan applies the selector query and scans the result into the given value. func (pgb *PlayerGroupBy) Scan(ctx context.Context, v any) error { - query, err := pgb.path(ctx) - if err != nil { + ctx = setContextOp(ctx, pgb.build.ctx, "GroupBy") + if err := pgb.build.prepareQuery(ctx); err != nil { return err } - pgb.sql = query - return pgb.sqlScan(ctx, v) + return scanWithInterceptors[*PlayerQuery, *PlayerGroupBy](ctx, pgb.build, pgb, pgb.build.inters, v) } -func (pgb *PlayerGroupBy) sqlScan(ctx context.Context, v any) error { - for _, f := range pgb.fields { - if !player.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} - } +func (pgb *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 = append(aggregation, fn(selector)) } - selector := pgb.sqlQuery() + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*pgb.flds)+len(pgb.fns)) + for _, f := range *pgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*pgb.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := pgb.driver.Query(ctx, query, args, rows); err != nil { + if err := pgb.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() return sql.ScanSlice(rows, v) } -func (pgb *PlayerGroupBy) sqlQuery() *sql.Selector { - selector := pgb.sql.Select() - aggregation := make([]string, 0, len(pgb.fns)) - for _, fn := range pgb.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(pgb.fields)+len(pgb.fns)) - for _, f := range pgb.fields { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - return selector.GroupBy(selector.Columns(pgb.fields...)...) -} - // PlayerSelect is the builder for selecting fields of Player entities. type PlayerSelect struct { *PlayerQuery selector - // intermediate query (i.e. traversal path). - sql *sql.Selector } // Aggregate adds the given aggregation functions to the selector query. @@ -714,26 +694,27 @@ func (ps *PlayerSelect) Aggregate(fns ...AggregateFunc) *PlayerSelect { // 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 { return err } - ps.sql = ps.PlayerQuery.sqlQuery(ctx) - return ps.sqlScan(ctx, v) + return scanWithInterceptors[*PlayerQuery, *PlayerSelect](ctx, ps.PlayerQuery, ps, ps.inters, v) } -func (ps *PlayerSelect) sqlScan(ctx context.Context, v any) error { +func (ps *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 = append(aggregation, fn(ps.sql)) + aggregation = append(aggregation, fn(selector)) } switch n := len(*ps.selector.flds); { case n == 0 && len(aggregation) > 0: - ps.sql.Select(aggregation...) + selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: - ps.sql.AppendSelect(aggregation...) + selector.AppendSelect(aggregation...) } rows := &sql.Rows{} - query, args := ps.sql.Query() + query, args := selector.Query() if err := ps.driver.Query(ctx, query, args, rows); err != nil { return err } diff --git a/ent/player_update.go b/ent/player_update.go index e1d9a77..2e38d56 100644 --- a/ent/player_update.go +++ b/ent/player_update.go @@ -459,34 +459,7 @@ func (pu *PlayerUpdate) RemoveMatches(m ...*Match) *PlayerUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (pu *PlayerUpdate) Save(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(pu.hooks) == 0 { - affected, err = pu.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*PlayerMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - pu.mutation = mutation - affected, err = pu.sqlSave(ctx) - mutation.done = true - return affected, err - }) - for i := len(pu.hooks) - 1; i >= 0; i-- { - if pu.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = pu.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, pu.mutation); err != nil { - return 0, err - } - } - return affected, err + return withHooks[int, PlayerMutation](ctx, pu.sqlSave, pu.mutation, pu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -518,16 +491,7 @@ func (pu *PlayerUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *PlayerU } func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: player.Table, - Columns: player.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeUint64, - Column: player.FieldID, - }, - }, - } + _spec := sqlgraph.NewUpdateSpec(player.Table, player.Columns, sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64)) if ps := pu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -760,6 +724,7 @@ func (pu *PlayerUpdate) sqlSave(ctx context.Context) (n int, err error) { } return 0, err } + pu.mutation.done = true return n, nil } @@ -1198,6 +1163,12 @@ func (puo *PlayerUpdateOne) RemoveMatches(m ...*Match) *PlayerUpdateOne { return puo.RemoveMatchIDs(ids...) } +// Where appends a list predicates to the PlayerUpdate builder. +func (puo *PlayerUpdateOne) Where(ps ...predicate.Player) *PlayerUpdateOne { + puo.mutation.Where(ps...) + return puo +} + // Select allows selecting one or more fields (columns) of the returned entity. // The default is selecting all fields defined in the entity schema. func (puo *PlayerUpdateOne) Select(field string, fields ...string) *PlayerUpdateOne { @@ -1207,40 +1178,7 @@ func (puo *PlayerUpdateOne) Select(field string, fields ...string) *PlayerUpdate // Save executes the query and returns the updated Player entity. func (puo *PlayerUpdateOne) Save(ctx context.Context) (*Player, error) { - var ( - err error - node *Player - ) - if len(puo.hooks) == 0 { - node, err = puo.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*PlayerMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - puo.mutation = mutation - node, err = puo.sqlSave(ctx) - mutation.done = true - return node, err - }) - for i := len(puo.hooks) - 1; i >= 0; i-- { - if puo.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = puo.hooks[i](mut) - } - v, err := mut.Mutate(ctx, puo.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*Player) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from PlayerMutation", v) - } - node = nv - } - return node, err + return withHooks[*Player, PlayerMutation](ctx, puo.sqlSave, puo.mutation, puo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -1272,16 +1210,7 @@ func (puo *PlayerUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *Pla } func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: player.Table, - Columns: player.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeUint64, - Column: player.FieldID, - }, - }, - } + _spec := sqlgraph.NewUpdateSpec(player.Table, player.Columns, sqlgraph.NewFieldSpec(player.FieldID, field.TypeUint64)) id, ok := puo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Player.id" for update`)} @@ -1534,5 +1463,6 @@ func (puo *PlayerUpdateOne) sqlSave(ctx context.Context) (_node *Player, err err } return nil, err } + puo.mutation.done = true return _node, nil } diff --git a/ent/roundstats.go b/ent/roundstats.go index 7113d89..1f716f2 100644 --- a/ent/roundstats.go +++ b/ent/roundstats.go @@ -120,14 +120,14 @@ func (rs *RoundStats) assignValues(columns []string, values []any) error { // QueryMatchPlayer queries the "match_player" edge of the RoundStats entity. func (rs *RoundStats) QueryMatchPlayer() *MatchPlayerQuery { - return (&RoundStatsClient{config: rs.config}).QueryMatchPlayer(rs) + return NewRoundStatsClient(rs.config).QueryMatchPlayer(rs) } // 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 (&RoundStatsClient{config: rs.config}).UpdateOne(rs) + return NewRoundStatsClient(rs.config).UpdateOne(rs) } // Unwrap unwraps the RoundStats entity that was returned from a transaction after it was closed, @@ -163,9 +163,3 @@ func (rs *RoundStats) String() string { // RoundStatsSlice is a parsable slice of RoundStats. type RoundStatsSlice []*RoundStats - -func (rs RoundStatsSlice) config(cfg config) { - for _i := range rs { - rs[_i].config = cfg - } -} diff --git a/ent/roundstats/where.go b/ent/roundstats/where.go index c06434e..c97fccc 100644 --- a/ent/roundstats/where.go +++ b/ent/roundstats/where.go @@ -10,357 +10,227 @@ import ( // ID filters vertices based on their ID field. func ID(id int) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) + return predicate.RoundStats(sql.FieldEQ(FieldID, id)) } // IDEQ applies the EQ predicate on the ID field. func IDEQ(id int) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) + return predicate.RoundStats(sql.FieldEQ(FieldID, id)) } // IDNEQ applies the NEQ predicate on the ID field. func IDNEQ(id int) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldID), id)) - }) + return predicate.RoundStats(sql.FieldNEQ(FieldID, id)) } // IDIn applies the In predicate on the ID field. func IDIn(ids ...int) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - v := make([]any, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.In(s.C(FieldID), v...)) - }) + return predicate.RoundStats(sql.FieldIn(FieldID, ids...)) } // IDNotIn applies the NotIn predicate on the ID field. func IDNotIn(ids ...int) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - v := make([]any, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.NotIn(s.C(FieldID), v...)) - }) + return predicate.RoundStats(sql.FieldNotIn(FieldID, ids...)) } // IDGT applies the GT predicate on the ID field. func IDGT(id int) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldID), id)) - }) + return predicate.RoundStats(sql.FieldGT(FieldID, id)) } // IDGTE applies the GTE predicate on the ID field. func IDGTE(id int) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldID), id)) - }) + return predicate.RoundStats(sql.FieldGTE(FieldID, id)) } // IDLT applies the LT predicate on the ID field. func IDLT(id int) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldID), id)) - }) + return predicate.RoundStats(sql.FieldLT(FieldID, id)) } // IDLTE applies the LTE predicate on the ID field. func IDLTE(id int) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldID), id)) - }) + return predicate.RoundStats(sql.FieldLTE(FieldID, id)) } // Round applies equality check predicate on the "round" field. It's identical to RoundEQ. func Round(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldRound), v)) - }) + return predicate.RoundStats(sql.FieldEQ(FieldRound, v)) } // Bank applies equality check predicate on the "bank" field. It's identical to BankEQ. func Bank(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldBank), v)) - }) + return predicate.RoundStats(sql.FieldEQ(FieldBank, v)) } // Equipment applies equality check predicate on the "equipment" field. It's identical to EquipmentEQ. func Equipment(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldEquipment), v)) - }) + return predicate.RoundStats(sql.FieldEQ(FieldEquipment, v)) } // Spent applies equality check predicate on the "spent" field. It's identical to SpentEQ. func Spent(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldSpent), v)) - }) + return predicate.RoundStats(sql.FieldEQ(FieldSpent, v)) } // RoundEQ applies the EQ predicate on the "round" field. func RoundEQ(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldRound), v)) - }) + return predicate.RoundStats(sql.FieldEQ(FieldRound, v)) } // RoundNEQ applies the NEQ predicate on the "round" field. func RoundNEQ(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldRound), v)) - }) + return predicate.RoundStats(sql.FieldNEQ(FieldRound, v)) } // RoundIn applies the In predicate on the "round" field. func RoundIn(vs ...uint) predicate.RoundStats { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldRound), v...)) - }) + return predicate.RoundStats(sql.FieldIn(FieldRound, vs...)) } // RoundNotIn applies the NotIn predicate on the "round" field. func RoundNotIn(vs ...uint) predicate.RoundStats { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldRound), v...)) - }) + return predicate.RoundStats(sql.FieldNotIn(FieldRound, vs...)) } // RoundGT applies the GT predicate on the "round" field. func RoundGT(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldRound), v)) - }) + return predicate.RoundStats(sql.FieldGT(FieldRound, v)) } // RoundGTE applies the GTE predicate on the "round" field. func RoundGTE(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldRound), v)) - }) + return predicate.RoundStats(sql.FieldGTE(FieldRound, v)) } // RoundLT applies the LT predicate on the "round" field. func RoundLT(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldRound), v)) - }) + return predicate.RoundStats(sql.FieldLT(FieldRound, v)) } // RoundLTE applies the LTE predicate on the "round" field. func RoundLTE(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldRound), v)) - }) + return predicate.RoundStats(sql.FieldLTE(FieldRound, v)) } // BankEQ applies the EQ predicate on the "bank" field. func BankEQ(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldBank), v)) - }) + return predicate.RoundStats(sql.FieldEQ(FieldBank, v)) } // BankNEQ applies the NEQ predicate on the "bank" field. func BankNEQ(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldBank), v)) - }) + return predicate.RoundStats(sql.FieldNEQ(FieldBank, v)) } // BankIn applies the In predicate on the "bank" field. func BankIn(vs ...uint) predicate.RoundStats { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldBank), v...)) - }) + return predicate.RoundStats(sql.FieldIn(FieldBank, vs...)) } // BankNotIn applies the NotIn predicate on the "bank" field. func BankNotIn(vs ...uint) predicate.RoundStats { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldBank), v...)) - }) + return predicate.RoundStats(sql.FieldNotIn(FieldBank, vs...)) } // BankGT applies the GT predicate on the "bank" field. func BankGT(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldBank), v)) - }) + return predicate.RoundStats(sql.FieldGT(FieldBank, v)) } // BankGTE applies the GTE predicate on the "bank" field. func BankGTE(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldBank), v)) - }) + return predicate.RoundStats(sql.FieldGTE(FieldBank, v)) } // BankLT applies the LT predicate on the "bank" field. func BankLT(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldBank), v)) - }) + return predicate.RoundStats(sql.FieldLT(FieldBank, v)) } // BankLTE applies the LTE predicate on the "bank" field. func BankLTE(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldBank), v)) - }) + return predicate.RoundStats(sql.FieldLTE(FieldBank, v)) } // EquipmentEQ applies the EQ predicate on the "equipment" field. func EquipmentEQ(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldEquipment), v)) - }) + return predicate.RoundStats(sql.FieldEQ(FieldEquipment, v)) } // EquipmentNEQ applies the NEQ predicate on the "equipment" field. func EquipmentNEQ(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldEquipment), v)) - }) + return predicate.RoundStats(sql.FieldNEQ(FieldEquipment, v)) } // EquipmentIn applies the In predicate on the "equipment" field. func EquipmentIn(vs ...uint) predicate.RoundStats { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldEquipment), v...)) - }) + return predicate.RoundStats(sql.FieldIn(FieldEquipment, vs...)) } // EquipmentNotIn applies the NotIn predicate on the "equipment" field. func EquipmentNotIn(vs ...uint) predicate.RoundStats { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldEquipment), v...)) - }) + return predicate.RoundStats(sql.FieldNotIn(FieldEquipment, vs...)) } // EquipmentGT applies the GT predicate on the "equipment" field. func EquipmentGT(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldEquipment), v)) - }) + return predicate.RoundStats(sql.FieldGT(FieldEquipment, v)) } // EquipmentGTE applies the GTE predicate on the "equipment" field. func EquipmentGTE(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldEquipment), v)) - }) + return predicate.RoundStats(sql.FieldGTE(FieldEquipment, v)) } // EquipmentLT applies the LT predicate on the "equipment" field. func EquipmentLT(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldEquipment), v)) - }) + return predicate.RoundStats(sql.FieldLT(FieldEquipment, v)) } // EquipmentLTE applies the LTE predicate on the "equipment" field. func EquipmentLTE(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldEquipment), v)) - }) + return predicate.RoundStats(sql.FieldLTE(FieldEquipment, v)) } // SpentEQ applies the EQ predicate on the "spent" field. func SpentEQ(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldSpent), v)) - }) + return predicate.RoundStats(sql.FieldEQ(FieldSpent, v)) } // SpentNEQ applies the NEQ predicate on the "spent" field. func SpentNEQ(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldSpent), v)) - }) + return predicate.RoundStats(sql.FieldNEQ(FieldSpent, v)) } // SpentIn applies the In predicate on the "spent" field. func SpentIn(vs ...uint) predicate.RoundStats { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldSpent), v...)) - }) + return predicate.RoundStats(sql.FieldIn(FieldSpent, vs...)) } // SpentNotIn applies the NotIn predicate on the "spent" field. func SpentNotIn(vs ...uint) predicate.RoundStats { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldSpent), v...)) - }) + return predicate.RoundStats(sql.FieldNotIn(FieldSpent, vs...)) } // SpentGT applies the GT predicate on the "spent" field. func SpentGT(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldSpent), v)) - }) + return predicate.RoundStats(sql.FieldGT(FieldSpent, v)) } // SpentGTE applies the GTE predicate on the "spent" field. func SpentGTE(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldSpent), v)) - }) + return predicate.RoundStats(sql.FieldGTE(FieldSpent, v)) } // SpentLT applies the LT predicate on the "spent" field. func SpentLT(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldSpent), v)) - }) + return predicate.RoundStats(sql.FieldLT(FieldSpent, v)) } // SpentLTE applies the LTE predicate on the "spent" field. func SpentLTE(v uint) predicate.RoundStats { - return predicate.RoundStats(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldSpent), v)) - }) + return predicate.RoundStats(sql.FieldLTE(FieldSpent, v)) } // HasMatchPlayer applies the HasEdge predicate on the "match_player" edge. @@ -368,7 +238,6 @@ func HasMatchPlayer() predicate.RoundStats { return predicate.RoundStats(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(MatchPlayerTable, FieldID), sqlgraph.Edge(sqlgraph.M2O, true, MatchPlayerTable, MatchPlayerColumn), ) sqlgraph.HasNeighbors(s, step) diff --git a/ent/roundstats_create.go b/ent/roundstats_create.go index f2aec6d..edd6ca3 100644 --- a/ent/roundstats_create.go +++ b/ent/roundstats_create.go @@ -70,49 +70,7 @@ func (rsc *RoundStatsCreate) Mutation() *RoundStatsMutation { // Save creates the RoundStats in the database. func (rsc *RoundStatsCreate) Save(ctx context.Context) (*RoundStats, error) { - var ( - err error - node *RoundStats - ) - if len(rsc.hooks) == 0 { - if err = rsc.check(); err != nil { - return nil, err - } - node, err = rsc.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*RoundStatsMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err = rsc.check(); err != nil { - return nil, err - } - rsc.mutation = mutation - if node, err = rsc.sqlSave(ctx); err != nil { - return nil, err - } - mutation.id = &node.ID - mutation.done = true - return node, err - }) - for i := len(rsc.hooks) - 1; i >= 0; i-- { - if rsc.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = rsc.hooks[i](mut) - } - v, err := mut.Mutate(ctx, rsc.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*RoundStats) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from RoundStatsMutation", v) - } - node = nv - } - return node, err + return withHooks[*RoundStats, RoundStatsMutation](ctx, rsc.sqlSave, rsc.mutation, rsc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -155,6 +113,9 @@ func (rsc *RoundStatsCreate) check() error { } func (rsc *RoundStatsCreate) sqlSave(ctx context.Context) (*RoundStats, error) { + if err := rsc.check(); err != nil { + return nil, err + } _node, _spec := rsc.createSpec() if err := sqlgraph.CreateNode(ctx, rsc.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { @@ -164,19 +125,15 @@ 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 return _node, nil } func (rsc *RoundStatsCreate) createSpec() (*RoundStats, *sqlgraph.CreateSpec) { var ( _node = &RoundStats{config: rsc.config} - _spec = &sqlgraph.CreateSpec{ - Table: roundstats.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: roundstats.FieldID, - }, - } + _spec = sqlgraph.NewCreateSpec(roundstats.Table, sqlgraph.NewFieldSpec(roundstats.FieldID, field.TypeInt)) ) if value, ok := rsc.mutation.Round(); ok { _spec.SetField(roundstats.FieldRound, field.TypeUint, value) diff --git a/ent/roundstats_delete.go b/ent/roundstats_delete.go index 4094fa6..8edaa27 100644 --- a/ent/roundstats_delete.go +++ b/ent/roundstats_delete.go @@ -4,7 +4,6 @@ package ent import ( "context" - "fmt" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -28,34 +27,7 @@ func (rsd *RoundStatsDelete) Where(ps ...predicate.RoundStats) *RoundStatsDelete // Exec executes the deletion query and returns how many vertices were deleted. func (rsd *RoundStatsDelete) Exec(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(rsd.hooks) == 0 { - affected, err = rsd.sqlExec(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*RoundStatsMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - rsd.mutation = mutation - affected, err = rsd.sqlExec(ctx) - mutation.done = true - return affected, err - }) - for i := len(rsd.hooks) - 1; i >= 0; i-- { - if rsd.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = rsd.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, rsd.mutation); err != nil { - return 0, err - } - } - return affected, err + return withHooks[int, RoundStatsMutation](ctx, rsd.sqlExec, rsd.mutation, rsd.hooks) } // ExecX is like Exec, but panics if an error occurs. @@ -68,15 +40,7 @@ func (rsd *RoundStatsDelete) ExecX(ctx context.Context) int { } func (rsd *RoundStatsDelete) sqlExec(ctx context.Context) (int, error) { - _spec := &sqlgraph.DeleteSpec{ - Node: &sqlgraph.NodeSpec{ - Table: roundstats.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: roundstats.FieldID, - }, - }, - } + _spec := sqlgraph.NewDeleteSpec(roundstats.Table, sqlgraph.NewFieldSpec(roundstats.FieldID, field.TypeInt)) if ps := rsd.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -88,6 +52,7 @@ func (rsd *RoundStatsDelete) sqlExec(ctx context.Context) (int, error) { if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } + rsd.mutation.done = true return affected, err } @@ -96,6 +61,12 @@ type RoundStatsDeleteOne struct { rsd *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 +} + // Exec executes the deletion query. func (rsdo *RoundStatsDeleteOne) Exec(ctx context.Context) error { n, err := rsdo.rsd.Exec(ctx) @@ -111,5 +82,7 @@ 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) { - rsdo.rsd.ExecX(ctx) + if err := rsdo.Exec(ctx); err != nil { + panic(err) + } } diff --git a/ent/roundstats_query.go b/ent/roundstats_query.go index 4fd3c54..7e3fa9d 100644 --- a/ent/roundstats_query.go +++ b/ent/roundstats_query.go @@ -18,11 +18,9 @@ import ( // RoundStatsQuery is the builder for querying RoundStats entities. type RoundStatsQuery struct { config - limit *int - offset *int - unique *bool + ctx *QueryContext order []OrderFunc - fields []string + inters []Interceptor predicates []predicate.RoundStats withMatchPlayer *MatchPlayerQuery withFKs bool @@ -38,26 +36,26 @@ func (rsq *RoundStatsQuery) Where(ps ...predicate.RoundStats) *RoundStatsQuery { return rsq } -// Limit adds a limit step to the query. +// Limit the number of records to be returned by this query. func (rsq *RoundStatsQuery) Limit(limit int) *RoundStatsQuery { - rsq.limit = &limit + rsq.ctx.Limit = &limit return rsq } -// Offset adds an offset step to the query. +// Offset to start from. func (rsq *RoundStatsQuery) Offset(offset int) *RoundStatsQuery { - rsq.offset = &offset + rsq.ctx.Offset = &offset return rsq } // 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.unique = &unique + rsq.ctx.Unique = &unique return rsq } -// Order adds an order step to the query. +// Order specifies how the records should be ordered. func (rsq *RoundStatsQuery) Order(o ...OrderFunc) *RoundStatsQuery { rsq.order = append(rsq.order, o...) return rsq @@ -65,7 +63,7 @@ func (rsq *RoundStatsQuery) Order(o ...OrderFunc) *RoundStatsQuery { // QueryMatchPlayer chains the current query on the "match_player" edge. func (rsq *RoundStatsQuery) QueryMatchPlayer() *MatchPlayerQuery { - query := &MatchPlayerQuery{config: rsq.config} + query := (&MatchPlayerClient{config: rsq.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := rsq.prepareQuery(ctx); err != nil { return nil, err @@ -88,7 +86,7 @@ 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(ctx) + nodes, err := rsq.Limit(1).All(setContextOp(ctx, rsq.ctx, "First")) if err != nil { return nil, err } @@ -111,7 +109,7 @@ func (rsq *RoundStatsQuery) FirstX(ctx context.Context) *RoundStats { // Returns a *NotFoundError when no RoundStats ID was found. func (rsq *RoundStatsQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = rsq.Limit(1).IDs(ctx); err != nil { + if ids, err = rsq.Limit(1).IDs(setContextOp(ctx, rsq.ctx, "FirstID")); err != nil { return } if len(ids) == 0 { @@ -134,7 +132,7 @@ func (rsq *RoundStatsQuery) FirstIDX(ctx context.Context) int { // 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(ctx) + nodes, err := rsq.Limit(2).All(setContextOp(ctx, rsq.ctx, "Only")) if err != nil { return nil, err } @@ -162,7 +160,7 @@ func (rsq *RoundStatsQuery) OnlyX(ctx context.Context) *RoundStats { // Returns a *NotFoundError when no entities are found. func (rsq *RoundStatsQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = rsq.Limit(2).IDs(ctx); err != nil { + if ids, err = rsq.Limit(2).IDs(setContextOp(ctx, rsq.ctx, "OnlyID")); err != nil { return } switch len(ids) { @@ -187,10 +185,12 @@ 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 { return nil, err } - return rsq.sqlAll(ctx) + qr := querierAll[[]*RoundStats, *RoundStatsQuery]() + return withInterceptors[[]*RoundStats](ctx, rsq, qr, rsq.inters) } // AllX is like All, but panics if an error occurs. @@ -203,9 +203,12 @@ 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) ([]int, error) { - var ids []int - if err := rsq.Select(roundstats.FieldID).Scan(ctx, &ids); err != nil { +func (rsq *RoundStatsQuery) IDs(ctx context.Context) (ids []int, err error) { + if rsq.ctx.Unique == nil && rsq.path != nil { + rsq.Unique(true) + } + ctx = setContextOp(ctx, rsq.ctx, "IDs") + if err = rsq.Select(roundstats.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil @@ -222,10 +225,11 @@ 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 { return 0, err } - return rsq.sqlCount(ctx) + return withInterceptors[int](ctx, rsq, querierCount[*RoundStatsQuery](), rsq.inters) } // CountX is like Count, but panics if an error occurs. @@ -239,10 +243,15 @@ 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) { - if err := rsq.prepareQuery(ctx); err != nil { - return false, err + ctx = setContextOp(ctx, rsq.ctx, "Exist") + switch _, err := rsq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil } - return rsq.sqlExist(ctx) } // ExistX is like Exist, but panics if an error occurs. @@ -262,22 +271,21 @@ func (rsq *RoundStatsQuery) Clone() *RoundStatsQuery { } return &RoundStatsQuery{ config: rsq.config, - limit: rsq.limit, - offset: rsq.offset, + ctx: rsq.ctx.Clone(), order: append([]OrderFunc{}, rsq.order...), + inters: append([]Interceptor{}, rsq.inters...), predicates: append([]predicate.RoundStats{}, rsq.predicates...), withMatchPlayer: rsq.withMatchPlayer.Clone(), // clone intermediate query. - sql: rsq.sql.Clone(), - path: rsq.path, - unique: rsq.unique, + sql: rsq.sql.Clone(), + path: rsq.path, } } // 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 := &MatchPlayerQuery{config: rsq.config} + query := (&MatchPlayerClient{config: rsq.config}).Query() for _, opt := range opts { opt(query) } @@ -300,16 +308,11 @@ func (rsq *RoundStatsQuery) WithMatchPlayer(opts ...func(*MatchPlayerQuery)) *Ro // Aggregate(ent.Count()). // Scan(ctx, &v) func (rsq *RoundStatsQuery) GroupBy(field string, fields ...string) *RoundStatsGroupBy { - grbuild := &RoundStatsGroupBy{config: rsq.config} - grbuild.fields = append([]string{field}, fields...) - grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { - if err := rsq.prepareQuery(ctx); err != nil { - return nil, err - } - return rsq.sqlQuery(ctx), nil - } + rsq.ctx.Fields = append([]string{field}, fields...) + grbuild := &RoundStatsGroupBy{build: rsq} + grbuild.flds = &rsq.ctx.Fields grbuild.label = roundstats.Label - grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan + grbuild.scan = grbuild.Scan return grbuild } @@ -326,11 +329,11 @@ func (rsq *RoundStatsQuery) GroupBy(field string, fields ...string) *RoundStatsG // Select(roundstats.FieldRound). // Scan(ctx, &v) func (rsq *RoundStatsQuery) Select(fields ...string) *RoundStatsSelect { - rsq.fields = append(rsq.fields, fields...) - selbuild := &RoundStatsSelect{RoundStatsQuery: rsq} - selbuild.label = roundstats.Label - selbuild.flds, selbuild.scan = &rsq.fields, selbuild.Scan - return selbuild + rsq.ctx.Fields = append(rsq.ctx.Fields, fields...) + sbuild := &RoundStatsSelect{RoundStatsQuery: rsq} + sbuild.label = roundstats.Label + sbuild.flds, sbuild.scan = &rsq.ctx.Fields, sbuild.Scan + return sbuild } // Aggregate returns a RoundStatsSelect configured with the given aggregations. @@ -339,7 +342,17 @@ func (rsq *RoundStatsQuery) Aggregate(fns ...AggregateFunc) *RoundStatsSelect { } func (rsq *RoundStatsQuery) prepareQuery(ctx context.Context) error { - for _, f := range rsq.fields { + for _, inter := range rsq.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 { + return err + } + } + } + for _, f := range rsq.ctx.Fields { if !roundstats.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } @@ -412,6 +425,9 @@ func (rsq *RoundStatsQuery) loadMatchPlayer(ctx context.Context, query *MatchPla } nodeids[fk] = append(nodeids[fk], nodes[i]) } + if len(ids) == 0 { + return nil + } query.Where(matchplayer.IDIn(ids...)) neighbors, err := query.All(ctx) if err != nil { @@ -434,41 +450,22 @@ func (rsq *RoundStatsQuery) sqlCount(ctx context.Context) (int, error) { if len(rsq.modifiers) > 0 { _spec.Modifiers = rsq.modifiers } - _spec.Node.Columns = rsq.fields - if len(rsq.fields) > 0 { - _spec.Unique = rsq.unique != nil && *rsq.unique + _spec.Node.Columns = rsq.ctx.Fields + if len(rsq.ctx.Fields) > 0 { + _spec.Unique = rsq.ctx.Unique != nil && *rsq.ctx.Unique } return sqlgraph.CountNodes(ctx, rsq.driver, _spec) } -func (rsq *RoundStatsQuery) sqlExist(ctx context.Context) (bool, error) { - switch _, err := rsq.FirstID(ctx); { - case IsNotFound(err): - return false, nil - case err != nil: - return false, fmt.Errorf("ent: check existence: %w", err) - default: - return true, nil - } -} - func (rsq *RoundStatsQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: roundstats.Table, - Columns: roundstats.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: roundstats.FieldID, - }, - }, - From: rsq.sql, - Unique: true, - } - if unique := rsq.unique; unique != nil { + _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.Unique = *unique + } else if rsq.path != nil { + _spec.Unique = true } - if fields := rsq.fields; len(fields) > 0 { + if fields := rsq.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 { @@ -484,10 +481,10 @@ func (rsq *RoundStatsQuery) querySpec() *sqlgraph.QuerySpec { } } } - if limit := rsq.limit; limit != nil { + if limit := rsq.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := rsq.offset; offset != nil { + if offset := rsq.ctx.Offset; offset != nil { _spec.Offset = *offset } if ps := rsq.order; len(ps) > 0 { @@ -503,7 +500,7 @@ func (rsq *RoundStatsQuery) querySpec() *sqlgraph.QuerySpec { func (rsq *RoundStatsQuery) sqlQuery(ctx context.Context) *sql.Selector { builder := sql.Dialect(rsq.driver.Dialect()) t1 := builder.Table(roundstats.Table) - columns := rsq.fields + columns := rsq.ctx.Fields if len(columns) == 0 { columns = roundstats.Columns } @@ -512,7 +509,7 @@ func (rsq *RoundStatsQuery) sqlQuery(ctx context.Context) *sql.Selector { selector = rsq.sql selector.Select(selector.Columns(columns...)...) } - if rsq.unique != nil && *rsq.unique { + if rsq.ctx.Unique != nil && *rsq.ctx.Unique { selector.Distinct() } for _, m := range rsq.modifiers { @@ -524,12 +521,12 @@ func (rsq *RoundStatsQuery) sqlQuery(ctx context.Context) *sql.Selector { for _, p := range rsq.order { p(selector) } - if offset := rsq.offset; offset != nil { + if offset := rsq.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.limit; limit != nil { + if limit := rsq.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector @@ -543,13 +540,8 @@ func (rsq *RoundStatsQuery) Modify(modifiers ...func(s *sql.Selector)) *RoundSta // RoundStatsGroupBy is the group-by builder for RoundStats entities. type RoundStatsGroupBy struct { - config selector - fields []string - fns []AggregateFunc - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) + build *RoundStatsQuery } // Aggregate adds the given aggregation functions to the group-by query. @@ -558,58 +550,46 @@ func (rsgb *RoundStatsGroupBy) Aggregate(fns ...AggregateFunc) *RoundStatsGroupB return rsgb } -// Scan applies the group-by query and scans the result into the given value. +// Scan applies the selector query and scans the result into the given value. func (rsgb *RoundStatsGroupBy) Scan(ctx context.Context, v any) error { - query, err := rsgb.path(ctx) - if err != nil { + ctx = setContextOp(ctx, rsgb.build.ctx, "GroupBy") + if err := rsgb.build.prepareQuery(ctx); err != nil { return err } - rsgb.sql = query - return rsgb.sqlScan(ctx, v) + return scanWithInterceptors[*RoundStatsQuery, *RoundStatsGroupBy](ctx, rsgb.build, rsgb, rsgb.build.inters, v) } -func (rsgb *RoundStatsGroupBy) sqlScan(ctx context.Context, v any) error { - for _, f := range rsgb.fields { - if !roundstats.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} - } +func (rsgb *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 = append(aggregation, fn(selector)) } - selector := rsgb.sqlQuery() + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*rsgb.flds)+len(rsgb.fns)) + for _, f := range *rsgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*rsgb.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := rsgb.driver.Query(ctx, query, args, rows); err != nil { + if err := rsgb.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() return sql.ScanSlice(rows, v) } -func (rsgb *RoundStatsGroupBy) sqlQuery() *sql.Selector { - selector := rsgb.sql.Select() - aggregation := make([]string, 0, len(rsgb.fns)) - for _, fn := range rsgb.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(rsgb.fields)+len(rsgb.fns)) - for _, f := range rsgb.fields { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - return selector.GroupBy(selector.Columns(rsgb.fields...)...) -} - // RoundStatsSelect is the builder for selecting fields of RoundStats entities. type RoundStatsSelect struct { *RoundStatsQuery selector - // intermediate query (i.e. traversal path). - sql *sql.Selector } // Aggregate adds the given aggregation functions to the selector query. @@ -620,26 +600,27 @@ func (rss *RoundStatsSelect) Aggregate(fns ...AggregateFunc) *RoundStatsSelect { // 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 { return err } - rss.sql = rss.RoundStatsQuery.sqlQuery(ctx) - return rss.sqlScan(ctx, v) + return scanWithInterceptors[*RoundStatsQuery, *RoundStatsSelect](ctx, rss.RoundStatsQuery, rss, rss.inters, v) } -func (rss *RoundStatsSelect) sqlScan(ctx context.Context, v any) error { +func (rss *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 = append(aggregation, fn(rss.sql)) + aggregation = append(aggregation, fn(selector)) } switch n := len(*rss.selector.flds); { case n == 0 && len(aggregation) > 0: - rss.sql.Select(aggregation...) + selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: - rss.sql.AppendSelect(aggregation...) + selector.AppendSelect(aggregation...) } rows := &sql.Rows{} - query, args := rss.sql.Query() + query, args := selector.Query() if err := rss.driver.Query(ctx, query, args, rows); err != nil { return err } diff --git a/ent/roundstats_update.go b/ent/roundstats_update.go index 0bec751..5085870 100644 --- a/ent/roundstats_update.go +++ b/ent/roundstats_update.go @@ -113,34 +113,7 @@ func (rsu *RoundStatsUpdate) ClearMatchPlayer() *RoundStatsUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (rsu *RoundStatsUpdate) Save(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(rsu.hooks) == 0 { - affected, err = rsu.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*RoundStatsMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - rsu.mutation = mutation - affected, err = rsu.sqlSave(ctx) - mutation.done = true - return affected, err - }) - for i := len(rsu.hooks) - 1; i >= 0; i-- { - if rsu.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = rsu.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, rsu.mutation); err != nil { - return 0, err - } - } - return affected, err + return withHooks[int, RoundStatsMutation](ctx, rsu.sqlSave, rsu.mutation, rsu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -172,16 +145,7 @@ func (rsu *RoundStatsUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *Ro } func (rsu *RoundStatsUpdate) sqlSave(ctx context.Context) (n int, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: roundstats.Table, - Columns: roundstats.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: roundstats.FieldID, - }, - }, - } + _spec := sqlgraph.NewUpdateSpec(roundstats.Table, roundstats.Columns, sqlgraph.NewFieldSpec(roundstats.FieldID, field.TypeInt)) if ps := rsu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -257,6 +221,7 @@ func (rsu *RoundStatsUpdate) sqlSave(ctx context.Context) (n int, err error) { } return 0, err } + rsu.mutation.done = true return n, nil } @@ -351,6 +316,12 @@ func (rsuo *RoundStatsUpdateOne) ClearMatchPlayer() *RoundStatsUpdateOne { return rsuo } +// Where appends a list predicates to the RoundStatsUpdate builder. +func (rsuo *RoundStatsUpdateOne) Where(ps ...predicate.RoundStats) *RoundStatsUpdateOne { + rsuo.mutation.Where(ps...) + return rsuo +} + // 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 { @@ -360,40 +331,7 @@ func (rsuo *RoundStatsUpdateOne) Select(field string, fields ...string) *RoundSt // Save executes the query and returns the updated RoundStats entity. func (rsuo *RoundStatsUpdateOne) Save(ctx context.Context) (*RoundStats, error) { - var ( - err error - node *RoundStats - ) - if len(rsuo.hooks) == 0 { - node, err = rsuo.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*RoundStatsMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - rsuo.mutation = mutation - node, err = rsuo.sqlSave(ctx) - mutation.done = true - return node, err - }) - for i := len(rsuo.hooks) - 1; i >= 0; i-- { - if rsuo.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = rsuo.hooks[i](mut) - } - v, err := mut.Mutate(ctx, rsuo.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*RoundStats) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from RoundStatsMutation", v) - } - node = nv - } - return node, err + return withHooks[*RoundStats, RoundStatsMutation](ctx, rsuo.sqlSave, rsuo.mutation, rsuo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -425,16 +363,7 @@ func (rsuo *RoundStatsUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) } func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: roundstats.Table, - Columns: roundstats.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: roundstats.FieldID, - }, - }, - } + _spec := sqlgraph.NewUpdateSpec(roundstats.Table, roundstats.Columns, sqlgraph.NewFieldSpec(roundstats.FieldID, field.TypeInt)) id, ok := rsuo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "RoundStats.id" for update`)} @@ -530,5 +459,6 @@ func (rsuo *RoundStatsUpdateOne) sqlSave(ctx context.Context) (_node *RoundStats } return nil, err } + rsuo.mutation.done = true return _node, nil } diff --git a/ent/runtime/runtime.go b/ent/runtime/runtime.go index 3a30276..515265b 100644 --- a/ent/runtime/runtime.go +++ b/ent/runtime/runtime.go @@ -5,6 +5,6 @@ package runtime // The schema-stitching logic is generated in git.harting.dev/csgowtf/csgowtfd/ent/runtime.go const ( - Version = "v0.11.4" // Version of ent codegen. - Sum = "h1:grwVY0fp31BZ6oEo3YrXenAuv8VJmEw7F/Bi6WqeH3Q=" // Sum of ent codegen. + Version = "v0.11.9" // Version of ent codegen. + Sum = "h1:dbbCkAiPVTRBIJwoZctiSYjB7zxQIBOzVSU5H9VYIQI=" // Sum of ent codegen. ) diff --git a/ent/spray.go b/ent/spray.go index 56a334b..7ac1ba6 100644 --- a/ent/spray.go +++ b/ent/spray.go @@ -106,14 +106,14 @@ func (s *Spray) assignValues(columns []string, values []any) error { // QueryMatchPlayers queries the "match_players" edge of the Spray entity. func (s *Spray) QueryMatchPlayers() *MatchPlayerQuery { - return (&SprayClient{config: s.config}).QueryMatchPlayers(s) + return NewSprayClient(s.config).QueryMatchPlayers(s) } // 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 (&SprayClient{config: s.config}).UpdateOne(s) + return NewSprayClient(s.config).UpdateOne(s) } // Unwrap unwraps the Spray entity that was returned from a transaction after it was closed, @@ -143,9 +143,3 @@ func (s *Spray) String() string { // Sprays is a parsable slice of Spray. type Sprays []*Spray - -func (s Sprays) config(cfg config) { - for _i := range s { - s[_i].config = cfg - } -} diff --git a/ent/spray/where.go b/ent/spray/where.go index 5b526af..8862f52 100644 --- a/ent/spray/where.go +++ b/ent/spray/where.go @@ -10,215 +10,137 @@ import ( // ID filters vertices based on their ID field. func ID(id int) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) + return predicate.Spray(sql.FieldEQ(FieldID, id)) } // IDEQ applies the EQ predicate on the ID field. func IDEQ(id int) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) + return predicate.Spray(sql.FieldEQ(FieldID, id)) } // IDNEQ applies the NEQ predicate on the ID field. func IDNEQ(id int) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldID), id)) - }) + return predicate.Spray(sql.FieldNEQ(FieldID, id)) } // IDIn applies the In predicate on the ID field. func IDIn(ids ...int) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - v := make([]any, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.In(s.C(FieldID), v...)) - }) + return predicate.Spray(sql.FieldIn(FieldID, ids...)) } // IDNotIn applies the NotIn predicate on the ID field. func IDNotIn(ids ...int) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - v := make([]any, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.NotIn(s.C(FieldID), v...)) - }) + return predicate.Spray(sql.FieldNotIn(FieldID, ids...)) } // IDGT applies the GT predicate on the ID field. func IDGT(id int) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldID), id)) - }) + return predicate.Spray(sql.FieldGT(FieldID, id)) } // IDGTE applies the GTE predicate on the ID field. func IDGTE(id int) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldID), id)) - }) + return predicate.Spray(sql.FieldGTE(FieldID, id)) } // IDLT applies the LT predicate on the ID field. func IDLT(id int) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldID), id)) - }) + return predicate.Spray(sql.FieldLT(FieldID, id)) } // IDLTE applies the LTE predicate on the ID field. func IDLTE(id int) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldID), id)) - }) + return predicate.Spray(sql.FieldLTE(FieldID, id)) } // Weapon applies equality check predicate on the "weapon" field. It's identical to WeaponEQ. func Weapon(v int) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldWeapon), v)) - }) + return predicate.Spray(sql.FieldEQ(FieldWeapon, v)) } // Spray applies equality check predicate on the "spray" field. It's identical to SprayEQ. func Spray(v []byte) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldSpray), v)) - }) + return predicate.Spray(sql.FieldEQ(FieldSpray, v)) } // WeaponEQ applies the EQ predicate on the "weapon" field. func WeaponEQ(v int) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldWeapon), v)) - }) + return predicate.Spray(sql.FieldEQ(FieldWeapon, v)) } // WeaponNEQ applies the NEQ predicate on the "weapon" field. func WeaponNEQ(v int) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldWeapon), v)) - }) + return predicate.Spray(sql.FieldNEQ(FieldWeapon, v)) } // WeaponIn applies the In predicate on the "weapon" field. func WeaponIn(vs ...int) predicate.Spray { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldWeapon), v...)) - }) + return predicate.Spray(sql.FieldIn(FieldWeapon, vs...)) } // WeaponNotIn applies the NotIn predicate on the "weapon" field. func WeaponNotIn(vs ...int) predicate.Spray { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldWeapon), v...)) - }) + return predicate.Spray(sql.FieldNotIn(FieldWeapon, vs...)) } // WeaponGT applies the GT predicate on the "weapon" field. func WeaponGT(v int) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldWeapon), v)) - }) + return predicate.Spray(sql.FieldGT(FieldWeapon, v)) } // WeaponGTE applies the GTE predicate on the "weapon" field. func WeaponGTE(v int) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldWeapon), v)) - }) + return predicate.Spray(sql.FieldGTE(FieldWeapon, v)) } // WeaponLT applies the LT predicate on the "weapon" field. func WeaponLT(v int) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldWeapon), v)) - }) + return predicate.Spray(sql.FieldLT(FieldWeapon, v)) } // WeaponLTE applies the LTE predicate on the "weapon" field. func WeaponLTE(v int) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldWeapon), v)) - }) + return predicate.Spray(sql.FieldLTE(FieldWeapon, v)) } // SprayEQ applies the EQ predicate on the "spray" field. func SprayEQ(v []byte) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldSpray), v)) - }) + return predicate.Spray(sql.FieldEQ(FieldSpray, v)) } // SprayNEQ applies the NEQ predicate on the "spray" field. func SprayNEQ(v []byte) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldSpray), v)) - }) + return predicate.Spray(sql.FieldNEQ(FieldSpray, v)) } // SprayIn applies the In predicate on the "spray" field. func SprayIn(vs ...[]byte) predicate.Spray { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldSpray), v...)) - }) + return predicate.Spray(sql.FieldIn(FieldSpray, vs...)) } // SprayNotIn applies the NotIn predicate on the "spray" field. func SprayNotIn(vs ...[]byte) predicate.Spray { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldSpray), v...)) - }) + return predicate.Spray(sql.FieldNotIn(FieldSpray, vs...)) } // SprayGT applies the GT predicate on the "spray" field. func SprayGT(v []byte) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldSpray), v)) - }) + return predicate.Spray(sql.FieldGT(FieldSpray, v)) } // SprayGTE applies the GTE predicate on the "spray" field. func SprayGTE(v []byte) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldSpray), v)) - }) + return predicate.Spray(sql.FieldGTE(FieldSpray, v)) } // SprayLT applies the LT predicate on the "spray" field. func SprayLT(v []byte) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldSpray), v)) - }) + return predicate.Spray(sql.FieldLT(FieldSpray, v)) } // SprayLTE applies the LTE predicate on the "spray" field. func SprayLTE(v []byte) predicate.Spray { - return predicate.Spray(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldSpray), v)) - }) + return predicate.Spray(sql.FieldLTE(FieldSpray, v)) } // HasMatchPlayers applies the HasEdge predicate on the "match_players" edge. @@ -226,7 +148,6 @@ func HasMatchPlayers() predicate.Spray { return predicate.Spray(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(MatchPlayersTable, FieldID), sqlgraph.Edge(sqlgraph.M2O, true, MatchPlayersTable, MatchPlayersColumn), ) sqlgraph.HasNeighbors(s, step) diff --git a/ent/spray_create.go b/ent/spray_create.go index 1d0bca1..51bf99e 100644 --- a/ent/spray_create.go +++ b/ent/spray_create.go @@ -58,49 +58,7 @@ func (sc *SprayCreate) Mutation() *SprayMutation { // Save creates the Spray in the database. func (sc *SprayCreate) Save(ctx context.Context) (*Spray, error) { - var ( - err error - node *Spray - ) - if len(sc.hooks) == 0 { - if err = sc.check(); err != nil { - return nil, err - } - node, err = sc.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*SprayMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err = sc.check(); err != nil { - return nil, err - } - sc.mutation = mutation - if node, err = sc.sqlSave(ctx); err != nil { - return nil, err - } - mutation.id = &node.ID - mutation.done = true - return node, err - }) - for i := len(sc.hooks) - 1; i >= 0; i-- { - if sc.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = sc.hooks[i](mut) - } - v, err := mut.Mutate(ctx, sc.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*Spray) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from SprayMutation", v) - } - node = nv - } - return node, err + return withHooks[*Spray, SprayMutation](ctx, sc.sqlSave, sc.mutation, sc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -137,6 +95,9 @@ func (sc *SprayCreate) check() error { } func (sc *SprayCreate) sqlSave(ctx context.Context) (*Spray, error) { + if err := sc.check(); err != nil { + return nil, err + } _node, _spec := sc.createSpec() if err := sqlgraph.CreateNode(ctx, sc.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { @@ -146,19 +107,15 @@ 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 return _node, nil } func (sc *SprayCreate) createSpec() (*Spray, *sqlgraph.CreateSpec) { var ( _node = &Spray{config: sc.config} - _spec = &sqlgraph.CreateSpec{ - Table: spray.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: spray.FieldID, - }, - } + _spec = sqlgraph.NewCreateSpec(spray.Table, sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt)) ) if value, ok := sc.mutation.Weapon(); ok { _spec.SetField(spray.FieldWeapon, field.TypeInt, value) diff --git a/ent/spray_delete.go b/ent/spray_delete.go index 08ddf87..37b13c9 100644 --- a/ent/spray_delete.go +++ b/ent/spray_delete.go @@ -4,7 +4,6 @@ package ent import ( "context" - "fmt" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -28,34 +27,7 @@ func (sd *SprayDelete) Where(ps ...predicate.Spray) *SprayDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (sd *SprayDelete) Exec(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(sd.hooks) == 0 { - affected, err = sd.sqlExec(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*SprayMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - sd.mutation = mutation - affected, err = sd.sqlExec(ctx) - mutation.done = true - return affected, err - }) - for i := len(sd.hooks) - 1; i >= 0; i-- { - if sd.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = sd.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, sd.mutation); err != nil { - return 0, err - } - } - return affected, err + return withHooks[int, SprayMutation](ctx, sd.sqlExec, sd.mutation, sd.hooks) } // ExecX is like Exec, but panics if an error occurs. @@ -68,15 +40,7 @@ func (sd *SprayDelete) ExecX(ctx context.Context) int { } func (sd *SprayDelete) sqlExec(ctx context.Context) (int, error) { - _spec := &sqlgraph.DeleteSpec{ - Node: &sqlgraph.NodeSpec{ - Table: spray.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: spray.FieldID, - }, - }, - } + _spec := sqlgraph.NewDeleteSpec(spray.Table, sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt)) if ps := sd.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -88,6 +52,7 @@ func (sd *SprayDelete) sqlExec(ctx context.Context) (int, error) { if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } + sd.mutation.done = true return affected, err } @@ -96,6 +61,12 @@ type SprayDeleteOne struct { sd *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 +} + // Exec executes the deletion query. func (sdo *SprayDeleteOne) Exec(ctx context.Context) error { n, err := sdo.sd.Exec(ctx) @@ -111,5 +82,7 @@ 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) { - sdo.sd.ExecX(ctx) + if err := sdo.Exec(ctx); err != nil { + panic(err) + } } diff --git a/ent/spray_query.go b/ent/spray_query.go index 1a5a995..da732ea 100644 --- a/ent/spray_query.go +++ b/ent/spray_query.go @@ -18,11 +18,9 @@ import ( // SprayQuery is the builder for querying Spray entities. type SprayQuery struct { config - limit *int - offset *int - unique *bool + ctx *QueryContext order []OrderFunc - fields []string + inters []Interceptor predicates []predicate.Spray withMatchPlayers *MatchPlayerQuery withFKs bool @@ -38,26 +36,26 @@ func (sq *SprayQuery) Where(ps ...predicate.Spray) *SprayQuery { return sq } -// Limit adds a limit step to the query. +// Limit the number of records to be returned by this query. func (sq *SprayQuery) Limit(limit int) *SprayQuery { - sq.limit = &limit + sq.ctx.Limit = &limit return sq } -// Offset adds an offset step to the query. +// Offset to start from. func (sq *SprayQuery) Offset(offset int) *SprayQuery { - sq.offset = &offset + sq.ctx.Offset = &offset return sq } // 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.unique = &unique + sq.ctx.Unique = &unique return sq } -// Order adds an order step to the query. +// Order specifies how the records should be ordered. func (sq *SprayQuery) Order(o ...OrderFunc) *SprayQuery { sq.order = append(sq.order, o...) return sq @@ -65,7 +63,7 @@ func (sq *SprayQuery) Order(o ...OrderFunc) *SprayQuery { // QueryMatchPlayers chains the current query on the "match_players" edge. func (sq *SprayQuery) QueryMatchPlayers() *MatchPlayerQuery { - query := &MatchPlayerQuery{config: sq.config} + query := (&MatchPlayerClient{config: sq.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := sq.prepareQuery(ctx); err != nil { return nil, err @@ -88,7 +86,7 @@ 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(ctx) + nodes, err := sq.Limit(1).All(setContextOp(ctx, sq.ctx, "First")) if err != nil { return nil, err } @@ -111,7 +109,7 @@ func (sq *SprayQuery) FirstX(ctx context.Context) *Spray { // Returns a *NotFoundError when no Spray ID was found. func (sq *SprayQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = sq.Limit(1).IDs(ctx); err != nil { + if ids, err = sq.Limit(1).IDs(setContextOp(ctx, sq.ctx, "FirstID")); err != nil { return } if len(ids) == 0 { @@ -134,7 +132,7 @@ func (sq *SprayQuery) FirstIDX(ctx context.Context) int { // 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(ctx) + nodes, err := sq.Limit(2).All(setContextOp(ctx, sq.ctx, "Only")) if err != nil { return nil, err } @@ -162,7 +160,7 @@ func (sq *SprayQuery) OnlyX(ctx context.Context) *Spray { // Returns a *NotFoundError when no entities are found. func (sq *SprayQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = sq.Limit(2).IDs(ctx); err != nil { + if ids, err = sq.Limit(2).IDs(setContextOp(ctx, sq.ctx, "OnlyID")); err != nil { return } switch len(ids) { @@ -187,10 +185,12 @@ 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 { return nil, err } - return sq.sqlAll(ctx) + qr := querierAll[[]*Spray, *SprayQuery]() + return withInterceptors[[]*Spray](ctx, sq, qr, sq.inters) } // AllX is like All, but panics if an error occurs. @@ -203,9 +203,12 @@ 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) ([]int, error) { - var ids []int - if err := sq.Select(spray.FieldID).Scan(ctx, &ids); err != nil { +func (sq *SprayQuery) IDs(ctx context.Context) (ids []int, err error) { + if sq.ctx.Unique == nil && sq.path != nil { + sq.Unique(true) + } + ctx = setContextOp(ctx, sq.ctx, "IDs") + if err = sq.Select(spray.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil @@ -222,10 +225,11 @@ 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 { return 0, err } - return sq.sqlCount(ctx) + return withInterceptors[int](ctx, sq, querierCount[*SprayQuery](), sq.inters) } // CountX is like Count, but panics if an error occurs. @@ -239,10 +243,15 @@ 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) { - if err := sq.prepareQuery(ctx); err != nil { - return false, err + ctx = setContextOp(ctx, sq.ctx, "Exist") + switch _, err := sq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil } - return sq.sqlExist(ctx) } // ExistX is like Exist, but panics if an error occurs. @@ -262,22 +271,21 @@ func (sq *SprayQuery) Clone() *SprayQuery { } return &SprayQuery{ config: sq.config, - limit: sq.limit, - offset: sq.offset, + ctx: sq.ctx.Clone(), order: append([]OrderFunc{}, sq.order...), + inters: append([]Interceptor{}, sq.inters...), predicates: append([]predicate.Spray{}, sq.predicates...), withMatchPlayers: sq.withMatchPlayers.Clone(), // clone intermediate query. - sql: sq.sql.Clone(), - path: sq.path, - unique: sq.unique, + sql: sq.sql.Clone(), + path: sq.path, } } // 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 := &MatchPlayerQuery{config: sq.config} + query := (&MatchPlayerClient{config: sq.config}).Query() for _, opt := range opts { opt(query) } @@ -300,16 +308,11 @@ func (sq *SprayQuery) WithMatchPlayers(opts ...func(*MatchPlayerQuery)) *SprayQu // Aggregate(ent.Count()). // Scan(ctx, &v) func (sq *SprayQuery) GroupBy(field string, fields ...string) *SprayGroupBy { - grbuild := &SprayGroupBy{config: sq.config} - grbuild.fields = append([]string{field}, fields...) - grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { - if err := sq.prepareQuery(ctx); err != nil { - return nil, err - } - return sq.sqlQuery(ctx), nil - } + sq.ctx.Fields = append([]string{field}, fields...) + grbuild := &SprayGroupBy{build: sq} + grbuild.flds = &sq.ctx.Fields grbuild.label = spray.Label - grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan + grbuild.scan = grbuild.Scan return grbuild } @@ -326,11 +329,11 @@ func (sq *SprayQuery) GroupBy(field string, fields ...string) *SprayGroupBy { // Select(spray.FieldWeapon). // Scan(ctx, &v) func (sq *SprayQuery) Select(fields ...string) *SpraySelect { - sq.fields = append(sq.fields, fields...) - selbuild := &SpraySelect{SprayQuery: sq} - selbuild.label = spray.Label - selbuild.flds, selbuild.scan = &sq.fields, selbuild.Scan - return selbuild + sq.ctx.Fields = append(sq.ctx.Fields, fields...) + sbuild := &SpraySelect{SprayQuery: sq} + sbuild.label = spray.Label + sbuild.flds, sbuild.scan = &sq.ctx.Fields, sbuild.Scan + return sbuild } // Aggregate returns a SpraySelect configured with the given aggregations. @@ -339,7 +342,17 @@ func (sq *SprayQuery) Aggregate(fns ...AggregateFunc) *SpraySelect { } func (sq *SprayQuery) prepareQuery(ctx context.Context) error { - for _, f := range sq.fields { + for _, inter := range sq.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 { + return err + } + } + } + for _, f := range sq.ctx.Fields { if !spray.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } @@ -412,6 +425,9 @@ func (sq *SprayQuery) loadMatchPlayers(ctx context.Context, query *MatchPlayerQu } nodeids[fk] = append(nodeids[fk], nodes[i]) } + if len(ids) == 0 { + return nil + } query.Where(matchplayer.IDIn(ids...)) neighbors, err := query.All(ctx) if err != nil { @@ -434,41 +450,22 @@ func (sq *SprayQuery) sqlCount(ctx context.Context) (int, error) { if len(sq.modifiers) > 0 { _spec.Modifiers = sq.modifiers } - _spec.Node.Columns = sq.fields - if len(sq.fields) > 0 { - _spec.Unique = sq.unique != nil && *sq.unique + _spec.Node.Columns = sq.ctx.Fields + if len(sq.ctx.Fields) > 0 { + _spec.Unique = sq.ctx.Unique != nil && *sq.ctx.Unique } return sqlgraph.CountNodes(ctx, sq.driver, _spec) } -func (sq *SprayQuery) sqlExist(ctx context.Context) (bool, error) { - switch _, err := sq.FirstID(ctx); { - case IsNotFound(err): - return false, nil - case err != nil: - return false, fmt.Errorf("ent: check existence: %w", err) - default: - return true, nil - } -} - func (sq *SprayQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: spray.Table, - Columns: spray.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: spray.FieldID, - }, - }, - From: sq.sql, - Unique: true, - } - if unique := sq.unique; unique != nil { + _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.Unique = *unique + } else if sq.path != nil { + _spec.Unique = true } - if fields := sq.fields; len(fields) > 0 { + if fields := sq.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 { @@ -484,10 +481,10 @@ func (sq *SprayQuery) querySpec() *sqlgraph.QuerySpec { } } } - if limit := sq.limit; limit != nil { + if limit := sq.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := sq.offset; offset != nil { + if offset := sq.ctx.Offset; offset != nil { _spec.Offset = *offset } if ps := sq.order; len(ps) > 0 { @@ -503,7 +500,7 @@ func (sq *SprayQuery) querySpec() *sqlgraph.QuerySpec { func (sq *SprayQuery) sqlQuery(ctx context.Context) *sql.Selector { builder := sql.Dialect(sq.driver.Dialect()) t1 := builder.Table(spray.Table) - columns := sq.fields + columns := sq.ctx.Fields if len(columns) == 0 { columns = spray.Columns } @@ -512,7 +509,7 @@ func (sq *SprayQuery) sqlQuery(ctx context.Context) *sql.Selector { selector = sq.sql selector.Select(selector.Columns(columns...)...) } - if sq.unique != nil && *sq.unique { + if sq.ctx.Unique != nil && *sq.ctx.Unique { selector.Distinct() } for _, m := range sq.modifiers { @@ -524,12 +521,12 @@ func (sq *SprayQuery) sqlQuery(ctx context.Context) *sql.Selector { for _, p := range sq.order { p(selector) } - if offset := sq.offset; offset != nil { + if offset := sq.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.limit; limit != nil { + if limit := sq.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector @@ -543,13 +540,8 @@ func (sq *SprayQuery) Modify(modifiers ...func(s *sql.Selector)) *SpraySelect { // SprayGroupBy is the group-by builder for Spray entities. type SprayGroupBy struct { - config selector - fields []string - fns []AggregateFunc - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) + build *SprayQuery } // Aggregate adds the given aggregation functions to the group-by query. @@ -558,58 +550,46 @@ func (sgb *SprayGroupBy) Aggregate(fns ...AggregateFunc) *SprayGroupBy { return sgb } -// Scan applies the group-by query and scans the result into the given value. +// Scan applies the selector query and scans the result into the given value. func (sgb *SprayGroupBy) Scan(ctx context.Context, v any) error { - query, err := sgb.path(ctx) - if err != nil { + ctx = setContextOp(ctx, sgb.build.ctx, "GroupBy") + if err := sgb.build.prepareQuery(ctx); err != nil { return err } - sgb.sql = query - return sgb.sqlScan(ctx, v) + return scanWithInterceptors[*SprayQuery, *SprayGroupBy](ctx, sgb.build, sgb, sgb.build.inters, v) } -func (sgb *SprayGroupBy) sqlScan(ctx context.Context, v any) error { - for _, f := range sgb.fields { - if !spray.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} - } +func (sgb *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 = append(aggregation, fn(selector)) } - selector := sgb.sqlQuery() + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*sgb.flds)+len(sgb.fns)) + for _, f := range *sgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*sgb.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := sgb.driver.Query(ctx, query, args, rows); err != nil { + if err := sgb.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() return sql.ScanSlice(rows, v) } -func (sgb *SprayGroupBy) sqlQuery() *sql.Selector { - selector := sgb.sql.Select() - aggregation := make([]string, 0, len(sgb.fns)) - for _, fn := range sgb.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(sgb.fields)+len(sgb.fns)) - for _, f := range sgb.fields { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - return selector.GroupBy(selector.Columns(sgb.fields...)...) -} - // SpraySelect is the builder for selecting fields of Spray entities. type SpraySelect struct { *SprayQuery selector - // intermediate query (i.e. traversal path). - sql *sql.Selector } // Aggregate adds the given aggregation functions to the selector query. @@ -620,26 +600,27 @@ func (ss *SpraySelect) Aggregate(fns ...AggregateFunc) *SpraySelect { // 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 { return err } - ss.sql = ss.SprayQuery.sqlQuery(ctx) - return ss.sqlScan(ctx, v) + return scanWithInterceptors[*SprayQuery, *SpraySelect](ctx, ss.SprayQuery, ss, ss.inters, v) } -func (ss *SpraySelect) sqlScan(ctx context.Context, v any) error { +func (ss *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 = append(aggregation, fn(ss.sql)) + aggregation = append(aggregation, fn(selector)) } switch n := len(*ss.selector.flds); { case n == 0 && len(aggregation) > 0: - ss.sql.Select(aggregation...) + selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: - ss.sql.AppendSelect(aggregation...) + selector.AppendSelect(aggregation...) } rows := &sql.Rows{} - query, args := ss.sql.Query() + query, args := selector.Query() if err := ss.driver.Query(ctx, query, args, rows); err != nil { return err } diff --git a/ent/spray_update.go b/ent/spray_update.go index 3350950..c5d0030 100644 --- a/ent/spray_update.go +++ b/ent/spray_update.go @@ -80,34 +80,7 @@ func (su *SprayUpdate) ClearMatchPlayers() *SprayUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (su *SprayUpdate) Save(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(su.hooks) == 0 { - affected, err = su.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*SprayMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - su.mutation = mutation - affected, err = su.sqlSave(ctx) - mutation.done = true - return affected, err - }) - for i := len(su.hooks) - 1; i >= 0; i-- { - if su.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = su.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, su.mutation); err != nil { - return 0, err - } - } - return affected, err + return withHooks[int, SprayMutation](ctx, su.sqlSave, su.mutation, su.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -139,16 +112,7 @@ func (su *SprayUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *SprayUpd } func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: spray.Table, - Columns: spray.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: spray.FieldID, - }, - }, - } + _spec := sqlgraph.NewUpdateSpec(spray.Table, spray.Columns, sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt)) if ps := su.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -209,6 +173,7 @@ func (su *SprayUpdate) sqlSave(ctx context.Context) (n int, err error) { } return 0, err } + su.mutation.done = true return n, nil } @@ -270,6 +235,12 @@ func (suo *SprayUpdateOne) ClearMatchPlayers() *SprayUpdateOne { return suo } +// Where appends a list predicates to the SprayUpdate builder. +func (suo *SprayUpdateOne) Where(ps ...predicate.Spray) *SprayUpdateOne { + suo.mutation.Where(ps...) + return suo +} + // 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 { @@ -279,40 +250,7 @@ func (suo *SprayUpdateOne) Select(field string, fields ...string) *SprayUpdateOn // Save executes the query and returns the updated Spray entity. func (suo *SprayUpdateOne) Save(ctx context.Context) (*Spray, error) { - var ( - err error - node *Spray - ) - if len(suo.hooks) == 0 { - node, err = suo.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*SprayMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - suo.mutation = mutation - node, err = suo.sqlSave(ctx) - mutation.done = true - return node, err - }) - for i := len(suo.hooks) - 1; i >= 0; i-- { - if suo.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = suo.hooks[i](mut) - } - v, err := mut.Mutate(ctx, suo.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*Spray) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from SprayMutation", v) - } - node = nv - } - return node, err + return withHooks[*Spray, SprayMutation](ctx, suo.sqlSave, suo.mutation, suo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -344,16 +282,7 @@ func (suo *SprayUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *Spra } func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: spray.Table, - Columns: spray.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: spray.FieldID, - }, - }, - } + _spec := sqlgraph.NewUpdateSpec(spray.Table, spray.Columns, sqlgraph.NewFieldSpec(spray.FieldID, field.TypeInt)) id, ok := suo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Spray.id" for update`)} @@ -434,5 +363,6 @@ func (suo *SprayUpdateOne) sqlSave(ctx context.Context) (_node *Spray, err error } return nil, err } + suo.mutation.done = true return _node, nil } diff --git a/ent/weapon.go b/ent/weapon.go index 91d5bc1..b3d7825 100644 --- a/ent/weapon.go +++ b/ent/weapon.go @@ -120,14 +120,14 @@ func (w *Weapon) assignValues(columns []string, values []any) error { // QueryStat queries the "stat" edge of the Weapon entity. func (w *Weapon) QueryStat() *MatchPlayerQuery { - return (&WeaponClient{config: w.config}).QueryStat(w) + return NewWeaponClient(w.config).QueryStat(w) } // 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 (&WeaponClient{config: w.config}).UpdateOne(w) + return NewWeaponClient(w.config).UpdateOne(w) } // Unwrap unwraps the Weapon entity that was returned from a transaction after it was closed, @@ -163,9 +163,3 @@ func (w *Weapon) String() string { // Weapons is a parsable slice of Weapon. type Weapons []*Weapon - -func (w Weapons) config(cfg config) { - for _i := range w { - w[_i].config = cfg - } -} diff --git a/ent/weapon/where.go b/ent/weapon/where.go index bb52c61..b608e7c 100644 --- a/ent/weapon/where.go +++ b/ent/weapon/where.go @@ -10,357 +10,227 @@ import ( // ID filters vertices based on their ID field. func ID(id int) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) + return predicate.Weapon(sql.FieldEQ(FieldID, id)) } // IDEQ applies the EQ predicate on the ID field. func IDEQ(id int) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldID), id)) - }) + return predicate.Weapon(sql.FieldEQ(FieldID, id)) } // IDNEQ applies the NEQ predicate on the ID field. func IDNEQ(id int) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldID), id)) - }) + return predicate.Weapon(sql.FieldNEQ(FieldID, id)) } // IDIn applies the In predicate on the ID field. func IDIn(ids ...int) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - v := make([]any, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.In(s.C(FieldID), v...)) - }) + return predicate.Weapon(sql.FieldIn(FieldID, ids...)) } // IDNotIn applies the NotIn predicate on the ID field. func IDNotIn(ids ...int) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - v := make([]any, len(ids)) - for i := range v { - v[i] = ids[i] - } - s.Where(sql.NotIn(s.C(FieldID), v...)) - }) + return predicate.Weapon(sql.FieldNotIn(FieldID, ids...)) } // IDGT applies the GT predicate on the ID field. func IDGT(id int) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldID), id)) - }) + return predicate.Weapon(sql.FieldGT(FieldID, id)) } // IDGTE applies the GTE predicate on the ID field. func IDGTE(id int) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldID), id)) - }) + return predicate.Weapon(sql.FieldGTE(FieldID, id)) } // IDLT applies the LT predicate on the ID field. func IDLT(id int) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldID), id)) - }) + return predicate.Weapon(sql.FieldLT(FieldID, id)) } // IDLTE applies the LTE predicate on the ID field. func IDLTE(id int) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldID), id)) - }) + return predicate.Weapon(sql.FieldLTE(FieldID, id)) } // Victim applies equality check predicate on the "victim" field. It's identical to VictimEQ. func Victim(v uint64) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldVictim), v)) - }) + return predicate.Weapon(sql.FieldEQ(FieldVictim, v)) } // Dmg applies equality check predicate on the "dmg" field. It's identical to DmgEQ. func Dmg(v uint) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldDmg), v)) - }) + return predicate.Weapon(sql.FieldEQ(FieldDmg, v)) } // EqType applies equality check predicate on the "eq_type" field. It's identical to EqTypeEQ. func EqType(v int) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldEqType), v)) - }) + return predicate.Weapon(sql.FieldEQ(FieldEqType, v)) } // HitGroup applies equality check predicate on the "hit_group" field. It's identical to HitGroupEQ. func HitGroup(v int) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldHitGroup), v)) - }) + return predicate.Weapon(sql.FieldEQ(FieldHitGroup, v)) } // VictimEQ applies the EQ predicate on the "victim" field. func VictimEQ(v uint64) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldVictim), v)) - }) + return predicate.Weapon(sql.FieldEQ(FieldVictim, v)) } // VictimNEQ applies the NEQ predicate on the "victim" field. func VictimNEQ(v uint64) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldVictim), v)) - }) + return predicate.Weapon(sql.FieldNEQ(FieldVictim, v)) } // VictimIn applies the In predicate on the "victim" field. func VictimIn(vs ...uint64) predicate.Weapon { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldVictim), v...)) - }) + return predicate.Weapon(sql.FieldIn(FieldVictim, vs...)) } // VictimNotIn applies the NotIn predicate on the "victim" field. func VictimNotIn(vs ...uint64) predicate.Weapon { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldVictim), v...)) - }) + return predicate.Weapon(sql.FieldNotIn(FieldVictim, vs...)) } // VictimGT applies the GT predicate on the "victim" field. func VictimGT(v uint64) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldVictim), v)) - }) + return predicate.Weapon(sql.FieldGT(FieldVictim, v)) } // VictimGTE applies the GTE predicate on the "victim" field. func VictimGTE(v uint64) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldVictim), v)) - }) + return predicate.Weapon(sql.FieldGTE(FieldVictim, v)) } // VictimLT applies the LT predicate on the "victim" field. func VictimLT(v uint64) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldVictim), v)) - }) + return predicate.Weapon(sql.FieldLT(FieldVictim, v)) } // VictimLTE applies the LTE predicate on the "victim" field. func VictimLTE(v uint64) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldVictim), v)) - }) + return predicate.Weapon(sql.FieldLTE(FieldVictim, v)) } // DmgEQ applies the EQ predicate on the "dmg" field. func DmgEQ(v uint) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldDmg), v)) - }) + return predicate.Weapon(sql.FieldEQ(FieldDmg, v)) } // DmgNEQ applies the NEQ predicate on the "dmg" field. func DmgNEQ(v uint) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldDmg), v)) - }) + return predicate.Weapon(sql.FieldNEQ(FieldDmg, v)) } // DmgIn applies the In predicate on the "dmg" field. func DmgIn(vs ...uint) predicate.Weapon { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldDmg), v...)) - }) + return predicate.Weapon(sql.FieldIn(FieldDmg, vs...)) } // DmgNotIn applies the NotIn predicate on the "dmg" field. func DmgNotIn(vs ...uint) predicate.Weapon { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldDmg), v...)) - }) + return predicate.Weapon(sql.FieldNotIn(FieldDmg, vs...)) } // DmgGT applies the GT predicate on the "dmg" field. func DmgGT(v uint) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldDmg), v)) - }) + return predicate.Weapon(sql.FieldGT(FieldDmg, v)) } // DmgGTE applies the GTE predicate on the "dmg" field. func DmgGTE(v uint) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldDmg), v)) - }) + return predicate.Weapon(sql.FieldGTE(FieldDmg, v)) } // DmgLT applies the LT predicate on the "dmg" field. func DmgLT(v uint) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldDmg), v)) - }) + return predicate.Weapon(sql.FieldLT(FieldDmg, v)) } // DmgLTE applies the LTE predicate on the "dmg" field. func DmgLTE(v uint) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldDmg), v)) - }) + return predicate.Weapon(sql.FieldLTE(FieldDmg, v)) } // EqTypeEQ applies the EQ predicate on the "eq_type" field. func EqTypeEQ(v int) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldEqType), v)) - }) + return predicate.Weapon(sql.FieldEQ(FieldEqType, v)) } // EqTypeNEQ applies the NEQ predicate on the "eq_type" field. func EqTypeNEQ(v int) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldEqType), v)) - }) + return predicate.Weapon(sql.FieldNEQ(FieldEqType, v)) } // EqTypeIn applies the In predicate on the "eq_type" field. func EqTypeIn(vs ...int) predicate.Weapon { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldEqType), v...)) - }) + return predicate.Weapon(sql.FieldIn(FieldEqType, vs...)) } // EqTypeNotIn applies the NotIn predicate on the "eq_type" field. func EqTypeNotIn(vs ...int) predicate.Weapon { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldEqType), v...)) - }) + return predicate.Weapon(sql.FieldNotIn(FieldEqType, vs...)) } // EqTypeGT applies the GT predicate on the "eq_type" field. func EqTypeGT(v int) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldEqType), v)) - }) + return predicate.Weapon(sql.FieldGT(FieldEqType, v)) } // EqTypeGTE applies the GTE predicate on the "eq_type" field. func EqTypeGTE(v int) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldEqType), v)) - }) + return predicate.Weapon(sql.FieldGTE(FieldEqType, v)) } // EqTypeLT applies the LT predicate on the "eq_type" field. func EqTypeLT(v int) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldEqType), v)) - }) + return predicate.Weapon(sql.FieldLT(FieldEqType, v)) } // EqTypeLTE applies the LTE predicate on the "eq_type" field. func EqTypeLTE(v int) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldEqType), v)) - }) + return predicate.Weapon(sql.FieldLTE(FieldEqType, v)) } // HitGroupEQ applies the EQ predicate on the "hit_group" field. func HitGroupEQ(v int) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.EQ(s.C(FieldHitGroup), v)) - }) + return predicate.Weapon(sql.FieldEQ(FieldHitGroup, v)) } // HitGroupNEQ applies the NEQ predicate on the "hit_group" field. func HitGroupNEQ(v int) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.NEQ(s.C(FieldHitGroup), v)) - }) + return predicate.Weapon(sql.FieldNEQ(FieldHitGroup, v)) } // HitGroupIn applies the In predicate on the "hit_group" field. func HitGroupIn(vs ...int) predicate.Weapon { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.In(s.C(FieldHitGroup), v...)) - }) + return predicate.Weapon(sql.FieldIn(FieldHitGroup, vs...)) } // HitGroupNotIn applies the NotIn predicate on the "hit_group" field. func HitGroupNotIn(vs ...int) predicate.Weapon { - v := make([]any, len(vs)) - for i := range v { - v[i] = vs[i] - } - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.NotIn(s.C(FieldHitGroup), v...)) - }) + return predicate.Weapon(sql.FieldNotIn(FieldHitGroup, vs...)) } // HitGroupGT applies the GT predicate on the "hit_group" field. func HitGroupGT(v int) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.GT(s.C(FieldHitGroup), v)) - }) + return predicate.Weapon(sql.FieldGT(FieldHitGroup, v)) } // HitGroupGTE applies the GTE predicate on the "hit_group" field. func HitGroupGTE(v int) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.GTE(s.C(FieldHitGroup), v)) - }) + return predicate.Weapon(sql.FieldGTE(FieldHitGroup, v)) } // HitGroupLT applies the LT predicate on the "hit_group" field. func HitGroupLT(v int) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.LT(s.C(FieldHitGroup), v)) - }) + return predicate.Weapon(sql.FieldLT(FieldHitGroup, v)) } // HitGroupLTE applies the LTE predicate on the "hit_group" field. func HitGroupLTE(v int) predicate.Weapon { - return predicate.Weapon(func(s *sql.Selector) { - s.Where(sql.LTE(s.C(FieldHitGroup), v)) - }) + return predicate.Weapon(sql.FieldLTE(FieldHitGroup, v)) } // HasStat applies the HasEdge predicate on the "stat" edge. @@ -368,7 +238,6 @@ func HasStat() predicate.Weapon { return predicate.Weapon(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), - sqlgraph.To(StatTable, FieldID), sqlgraph.Edge(sqlgraph.M2O, true, StatTable, StatColumn), ) sqlgraph.HasNeighbors(s, step) diff --git a/ent/weapon_create.go b/ent/weapon_create.go index bf9701f..e53d350 100644 --- a/ent/weapon_create.go +++ b/ent/weapon_create.go @@ -70,49 +70,7 @@ func (wc *WeaponCreate) Mutation() *WeaponMutation { // Save creates the Weapon in the database. func (wc *WeaponCreate) Save(ctx context.Context) (*Weapon, error) { - var ( - err error - node *Weapon - ) - if len(wc.hooks) == 0 { - if err = wc.check(); err != nil { - return nil, err - } - node, err = wc.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*WeaponMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - if err = wc.check(); err != nil { - return nil, err - } - wc.mutation = mutation - if node, err = wc.sqlSave(ctx); err != nil { - return nil, err - } - mutation.id = &node.ID - mutation.done = true - return node, err - }) - for i := len(wc.hooks) - 1; i >= 0; i-- { - if wc.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = wc.hooks[i](mut) - } - v, err := mut.Mutate(ctx, wc.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*Weapon) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from WeaponMutation", v) - } - node = nv - } - return node, err + return withHooks[*Weapon, WeaponMutation](ctx, wc.sqlSave, wc.mutation, wc.hooks) } // SaveX calls Save and panics if Save returns an error. @@ -155,6 +113,9 @@ func (wc *WeaponCreate) check() error { } func (wc *WeaponCreate) sqlSave(ctx context.Context) (*Weapon, error) { + if err := wc.check(); err != nil { + return nil, err + } _node, _spec := wc.createSpec() if err := sqlgraph.CreateNode(ctx, wc.driver, _spec); err != nil { if sqlgraph.IsConstraintError(err) { @@ -164,19 +125,15 @@ 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 return _node, nil } func (wc *WeaponCreate) createSpec() (*Weapon, *sqlgraph.CreateSpec) { var ( _node = &Weapon{config: wc.config} - _spec = &sqlgraph.CreateSpec{ - Table: weapon.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: weapon.FieldID, - }, - } + _spec = sqlgraph.NewCreateSpec(weapon.Table, sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt)) ) if value, ok := wc.mutation.Victim(); ok { _spec.SetField(weapon.FieldVictim, field.TypeUint64, value) diff --git a/ent/weapon_delete.go b/ent/weapon_delete.go index 512097e..714a2a9 100644 --- a/ent/weapon_delete.go +++ b/ent/weapon_delete.go @@ -4,7 +4,6 @@ package ent import ( "context" - "fmt" "entgo.io/ent/dialect/sql" "entgo.io/ent/dialect/sql/sqlgraph" @@ -28,34 +27,7 @@ func (wd *WeaponDelete) Where(ps ...predicate.Weapon) *WeaponDelete { // Exec executes the deletion query and returns how many vertices were deleted. func (wd *WeaponDelete) Exec(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(wd.hooks) == 0 { - affected, err = wd.sqlExec(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*WeaponMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - wd.mutation = mutation - affected, err = wd.sqlExec(ctx) - mutation.done = true - return affected, err - }) - for i := len(wd.hooks) - 1; i >= 0; i-- { - if wd.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = wd.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, wd.mutation); err != nil { - return 0, err - } - } - return affected, err + return withHooks[int, WeaponMutation](ctx, wd.sqlExec, wd.mutation, wd.hooks) } // ExecX is like Exec, but panics if an error occurs. @@ -68,15 +40,7 @@ func (wd *WeaponDelete) ExecX(ctx context.Context) int { } func (wd *WeaponDelete) sqlExec(ctx context.Context) (int, error) { - _spec := &sqlgraph.DeleteSpec{ - Node: &sqlgraph.NodeSpec{ - Table: weapon.Table, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: weapon.FieldID, - }, - }, - } + _spec := sqlgraph.NewDeleteSpec(weapon.Table, sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt)) if ps := wd.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -88,6 +52,7 @@ func (wd *WeaponDelete) sqlExec(ctx context.Context) (int, error) { if err != nil && sqlgraph.IsConstraintError(err) { err = &ConstraintError{msg: err.Error(), wrap: err} } + wd.mutation.done = true return affected, err } @@ -96,6 +61,12 @@ type WeaponDeleteOne struct { wd *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 +} + // Exec executes the deletion query. func (wdo *WeaponDeleteOne) Exec(ctx context.Context) error { n, err := wdo.wd.Exec(ctx) @@ -111,5 +82,7 @@ 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) { - wdo.wd.ExecX(ctx) + if err := wdo.Exec(ctx); err != nil { + panic(err) + } } diff --git a/ent/weapon_query.go b/ent/weapon_query.go index 063f267..fa23882 100644 --- a/ent/weapon_query.go +++ b/ent/weapon_query.go @@ -18,11 +18,9 @@ import ( // WeaponQuery is the builder for querying Weapon entities. type WeaponQuery struct { config - limit *int - offset *int - unique *bool + ctx *QueryContext order []OrderFunc - fields []string + inters []Interceptor predicates []predicate.Weapon withStat *MatchPlayerQuery withFKs bool @@ -38,26 +36,26 @@ func (wq *WeaponQuery) Where(ps ...predicate.Weapon) *WeaponQuery { return wq } -// Limit adds a limit step to the query. +// Limit the number of records to be returned by this query. func (wq *WeaponQuery) Limit(limit int) *WeaponQuery { - wq.limit = &limit + wq.ctx.Limit = &limit return wq } -// Offset adds an offset step to the query. +// Offset to start from. func (wq *WeaponQuery) Offset(offset int) *WeaponQuery { - wq.offset = &offset + wq.ctx.Offset = &offset return wq } // 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.unique = &unique + wq.ctx.Unique = &unique return wq } -// Order adds an order step to the query. +// Order specifies how the records should be ordered. func (wq *WeaponQuery) Order(o ...OrderFunc) *WeaponQuery { wq.order = append(wq.order, o...) return wq @@ -65,7 +63,7 @@ func (wq *WeaponQuery) Order(o ...OrderFunc) *WeaponQuery { // QueryStat chains the current query on the "stat" edge. func (wq *WeaponQuery) QueryStat() *MatchPlayerQuery { - query := &MatchPlayerQuery{config: wq.config} + query := (&MatchPlayerClient{config: wq.config}).Query() query.path = func(ctx context.Context) (fromU *sql.Selector, err error) { if err := wq.prepareQuery(ctx); err != nil { return nil, err @@ -88,7 +86,7 @@ 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(ctx) + nodes, err := wq.Limit(1).All(setContextOp(ctx, wq.ctx, "First")) if err != nil { return nil, err } @@ -111,7 +109,7 @@ func (wq *WeaponQuery) FirstX(ctx context.Context) *Weapon { // Returns a *NotFoundError when no Weapon ID was found. func (wq *WeaponQuery) FirstID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = wq.Limit(1).IDs(ctx); err != nil { + if ids, err = wq.Limit(1).IDs(setContextOp(ctx, wq.ctx, "FirstID")); err != nil { return } if len(ids) == 0 { @@ -134,7 +132,7 @@ func (wq *WeaponQuery) FirstIDX(ctx context.Context) int { // 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(ctx) + nodes, err := wq.Limit(2).All(setContextOp(ctx, wq.ctx, "Only")) if err != nil { return nil, err } @@ -162,7 +160,7 @@ func (wq *WeaponQuery) OnlyX(ctx context.Context) *Weapon { // Returns a *NotFoundError when no entities are found. func (wq *WeaponQuery) OnlyID(ctx context.Context) (id int, err error) { var ids []int - if ids, err = wq.Limit(2).IDs(ctx); err != nil { + if ids, err = wq.Limit(2).IDs(setContextOp(ctx, wq.ctx, "OnlyID")); err != nil { return } switch len(ids) { @@ -187,10 +185,12 @@ 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 { return nil, err } - return wq.sqlAll(ctx) + qr := querierAll[[]*Weapon, *WeaponQuery]() + return withInterceptors[[]*Weapon](ctx, wq, qr, wq.inters) } // AllX is like All, but panics if an error occurs. @@ -203,9 +203,12 @@ 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) ([]int, error) { - var ids []int - if err := wq.Select(weapon.FieldID).Scan(ctx, &ids); err != nil { +func (wq *WeaponQuery) IDs(ctx context.Context) (ids []int, err error) { + if wq.ctx.Unique == nil && wq.path != nil { + wq.Unique(true) + } + ctx = setContextOp(ctx, wq.ctx, "IDs") + if err = wq.Select(weapon.FieldID).Scan(ctx, &ids); err != nil { return nil, err } return ids, nil @@ -222,10 +225,11 @@ 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 { return 0, err } - return wq.sqlCount(ctx) + return withInterceptors[int](ctx, wq, querierCount[*WeaponQuery](), wq.inters) } // CountX is like Count, but panics if an error occurs. @@ -239,10 +243,15 @@ 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) { - if err := wq.prepareQuery(ctx); err != nil { - return false, err + ctx = setContextOp(ctx, wq.ctx, "Exist") + switch _, err := wq.FirstID(ctx); { + case IsNotFound(err): + return false, nil + case err != nil: + return false, fmt.Errorf("ent: check existence: %w", err) + default: + return true, nil } - return wq.sqlExist(ctx) } // ExistX is like Exist, but panics if an error occurs. @@ -262,22 +271,21 @@ func (wq *WeaponQuery) Clone() *WeaponQuery { } return &WeaponQuery{ config: wq.config, - limit: wq.limit, - offset: wq.offset, + ctx: wq.ctx.Clone(), order: append([]OrderFunc{}, wq.order...), + inters: append([]Interceptor{}, wq.inters...), predicates: append([]predicate.Weapon{}, wq.predicates...), withStat: wq.withStat.Clone(), // clone intermediate query. - sql: wq.sql.Clone(), - path: wq.path, - unique: wq.unique, + sql: wq.sql.Clone(), + path: wq.path, } } // 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 := &MatchPlayerQuery{config: wq.config} + query := (&MatchPlayerClient{config: wq.config}).Query() for _, opt := range opts { opt(query) } @@ -300,16 +308,11 @@ func (wq *WeaponQuery) WithStat(opts ...func(*MatchPlayerQuery)) *WeaponQuery { // Aggregate(ent.Count()). // Scan(ctx, &v) func (wq *WeaponQuery) GroupBy(field string, fields ...string) *WeaponGroupBy { - grbuild := &WeaponGroupBy{config: wq.config} - grbuild.fields = append([]string{field}, fields...) - grbuild.path = func(ctx context.Context) (prev *sql.Selector, err error) { - if err := wq.prepareQuery(ctx); err != nil { - return nil, err - } - return wq.sqlQuery(ctx), nil - } + wq.ctx.Fields = append([]string{field}, fields...) + grbuild := &WeaponGroupBy{build: wq} + grbuild.flds = &wq.ctx.Fields grbuild.label = weapon.Label - grbuild.flds, grbuild.scan = &grbuild.fields, grbuild.Scan + grbuild.scan = grbuild.Scan return grbuild } @@ -326,11 +329,11 @@ func (wq *WeaponQuery) GroupBy(field string, fields ...string) *WeaponGroupBy { // Select(weapon.FieldVictim). // Scan(ctx, &v) func (wq *WeaponQuery) Select(fields ...string) *WeaponSelect { - wq.fields = append(wq.fields, fields...) - selbuild := &WeaponSelect{WeaponQuery: wq} - selbuild.label = weapon.Label - selbuild.flds, selbuild.scan = &wq.fields, selbuild.Scan - return selbuild + wq.ctx.Fields = append(wq.ctx.Fields, fields...) + sbuild := &WeaponSelect{WeaponQuery: wq} + sbuild.label = weapon.Label + sbuild.flds, sbuild.scan = &wq.ctx.Fields, sbuild.Scan + return sbuild } // Aggregate returns a WeaponSelect configured with the given aggregations. @@ -339,7 +342,17 @@ func (wq *WeaponQuery) Aggregate(fns ...AggregateFunc) *WeaponSelect { } func (wq *WeaponQuery) prepareQuery(ctx context.Context) error { - for _, f := range wq.fields { + for _, inter := range wq.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 { + return err + } + } + } + for _, f := range wq.ctx.Fields { if !weapon.ValidColumn(f) { return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)} } @@ -412,6 +425,9 @@ func (wq *WeaponQuery) loadStat(ctx context.Context, query *MatchPlayerQuery, no } nodeids[fk] = append(nodeids[fk], nodes[i]) } + if len(ids) == 0 { + return nil + } query.Where(matchplayer.IDIn(ids...)) neighbors, err := query.All(ctx) if err != nil { @@ -434,41 +450,22 @@ func (wq *WeaponQuery) sqlCount(ctx context.Context) (int, error) { if len(wq.modifiers) > 0 { _spec.Modifiers = wq.modifiers } - _spec.Node.Columns = wq.fields - if len(wq.fields) > 0 { - _spec.Unique = wq.unique != nil && *wq.unique + _spec.Node.Columns = wq.ctx.Fields + if len(wq.ctx.Fields) > 0 { + _spec.Unique = wq.ctx.Unique != nil && *wq.ctx.Unique } return sqlgraph.CountNodes(ctx, wq.driver, _spec) } -func (wq *WeaponQuery) sqlExist(ctx context.Context) (bool, error) { - switch _, err := wq.FirstID(ctx); { - case IsNotFound(err): - return false, nil - case err != nil: - return false, fmt.Errorf("ent: check existence: %w", err) - default: - return true, nil - } -} - func (wq *WeaponQuery) querySpec() *sqlgraph.QuerySpec { - _spec := &sqlgraph.QuerySpec{ - Node: &sqlgraph.NodeSpec{ - Table: weapon.Table, - Columns: weapon.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: weapon.FieldID, - }, - }, - From: wq.sql, - Unique: true, - } - if unique := wq.unique; unique != nil { + _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.Unique = *unique + } else if wq.path != nil { + _spec.Unique = true } - if fields := wq.fields; len(fields) > 0 { + if fields := wq.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 { @@ -484,10 +481,10 @@ func (wq *WeaponQuery) querySpec() *sqlgraph.QuerySpec { } } } - if limit := wq.limit; limit != nil { + if limit := wq.ctx.Limit; limit != nil { _spec.Limit = *limit } - if offset := wq.offset; offset != nil { + if offset := wq.ctx.Offset; offset != nil { _spec.Offset = *offset } if ps := wq.order; len(ps) > 0 { @@ -503,7 +500,7 @@ func (wq *WeaponQuery) querySpec() *sqlgraph.QuerySpec { func (wq *WeaponQuery) sqlQuery(ctx context.Context) *sql.Selector { builder := sql.Dialect(wq.driver.Dialect()) t1 := builder.Table(weapon.Table) - columns := wq.fields + columns := wq.ctx.Fields if len(columns) == 0 { columns = weapon.Columns } @@ -512,7 +509,7 @@ func (wq *WeaponQuery) sqlQuery(ctx context.Context) *sql.Selector { selector = wq.sql selector.Select(selector.Columns(columns...)...) } - if wq.unique != nil && *wq.unique { + if wq.ctx.Unique != nil && *wq.ctx.Unique { selector.Distinct() } for _, m := range wq.modifiers { @@ -524,12 +521,12 @@ func (wq *WeaponQuery) sqlQuery(ctx context.Context) *sql.Selector { for _, p := range wq.order { p(selector) } - if offset := wq.offset; offset != nil { + if offset := wq.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.limit; limit != nil { + if limit := wq.ctx.Limit; limit != nil { selector.Limit(*limit) } return selector @@ -543,13 +540,8 @@ func (wq *WeaponQuery) Modify(modifiers ...func(s *sql.Selector)) *WeaponSelect // WeaponGroupBy is the group-by builder for Weapon entities. type WeaponGroupBy struct { - config selector - fields []string - fns []AggregateFunc - // intermediate query (i.e. traversal path). - sql *sql.Selector - path func(context.Context) (*sql.Selector, error) + build *WeaponQuery } // Aggregate adds the given aggregation functions to the group-by query. @@ -558,58 +550,46 @@ func (wgb *WeaponGroupBy) Aggregate(fns ...AggregateFunc) *WeaponGroupBy { return wgb } -// Scan applies the group-by query and scans the result into the given value. +// Scan applies the selector query and scans the result into the given value. func (wgb *WeaponGroupBy) Scan(ctx context.Context, v any) error { - query, err := wgb.path(ctx) - if err != nil { + ctx = setContextOp(ctx, wgb.build.ctx, "GroupBy") + if err := wgb.build.prepareQuery(ctx); err != nil { return err } - wgb.sql = query - return wgb.sqlScan(ctx, v) + return scanWithInterceptors[*WeaponQuery, *WeaponGroupBy](ctx, wgb.build, wgb, wgb.build.inters, v) } -func (wgb *WeaponGroupBy) sqlScan(ctx context.Context, v any) error { - for _, f := range wgb.fields { - if !weapon.ValidColumn(f) { - return &ValidationError{Name: f, err: fmt.Errorf("invalid field %q for group-by", f)} - } +func (wgb *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 = append(aggregation, fn(selector)) } - selector := wgb.sqlQuery() + if len(selector.SelectedColumns()) == 0 { + columns := make([]string, 0, len(*wgb.flds)+len(wgb.fns)) + for _, f := range *wgb.flds { + columns = append(columns, selector.C(f)) + } + columns = append(columns, aggregation...) + selector.Select(columns...) + } + selector.GroupBy(selector.Columns(*wgb.flds...)...) if err := selector.Err(); err != nil { return err } rows := &sql.Rows{} query, args := selector.Query() - if err := wgb.driver.Query(ctx, query, args, rows); err != nil { + if err := wgb.build.driver.Query(ctx, query, args, rows); err != nil { return err } defer rows.Close() return sql.ScanSlice(rows, v) } -func (wgb *WeaponGroupBy) sqlQuery() *sql.Selector { - selector := wgb.sql.Select() - aggregation := make([]string, 0, len(wgb.fns)) - for _, fn := range wgb.fns { - aggregation = append(aggregation, fn(selector)) - } - if len(selector.SelectedColumns()) == 0 { - columns := make([]string, 0, len(wgb.fields)+len(wgb.fns)) - for _, f := range wgb.fields { - columns = append(columns, selector.C(f)) - } - columns = append(columns, aggregation...) - selector.Select(columns...) - } - return selector.GroupBy(selector.Columns(wgb.fields...)...) -} - // WeaponSelect is the builder for selecting fields of Weapon entities. type WeaponSelect struct { *WeaponQuery selector - // intermediate query (i.e. traversal path). - sql *sql.Selector } // Aggregate adds the given aggregation functions to the selector query. @@ -620,26 +600,27 @@ func (ws *WeaponSelect) Aggregate(fns ...AggregateFunc) *WeaponSelect { // 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 { return err } - ws.sql = ws.WeaponQuery.sqlQuery(ctx) - return ws.sqlScan(ctx, v) + return scanWithInterceptors[*WeaponQuery, *WeaponSelect](ctx, ws.WeaponQuery, ws, ws.inters, v) } -func (ws *WeaponSelect) sqlScan(ctx context.Context, v any) error { +func (ws *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 = append(aggregation, fn(ws.sql)) + aggregation = append(aggregation, fn(selector)) } switch n := len(*ws.selector.flds); { case n == 0 && len(aggregation) > 0: - ws.sql.Select(aggregation...) + selector.Select(aggregation...) case n != 0 && len(aggregation) > 0: - ws.sql.AppendSelect(aggregation...) + selector.AppendSelect(aggregation...) } rows := &sql.Rows{} - query, args := ws.sql.Query() + query, args := selector.Query() if err := ws.driver.Query(ctx, query, args, rows); err != nil { return err } diff --git a/ent/weapon_update.go b/ent/weapon_update.go index 293fd0d..df1da06 100644 --- a/ent/weapon_update.go +++ b/ent/weapon_update.go @@ -113,34 +113,7 @@ func (wu *WeaponUpdate) ClearStat() *WeaponUpdate { // Save executes the query and returns the number of nodes affected by the update operation. func (wu *WeaponUpdate) Save(ctx context.Context) (int, error) { - var ( - err error - affected int - ) - if len(wu.hooks) == 0 { - affected, err = wu.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*WeaponMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - wu.mutation = mutation - affected, err = wu.sqlSave(ctx) - mutation.done = true - return affected, err - }) - for i := len(wu.hooks) - 1; i >= 0; i-- { - if wu.hooks[i] == nil { - return 0, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = wu.hooks[i](mut) - } - if _, err := mut.Mutate(ctx, wu.mutation); err != nil { - return 0, err - } - } - return affected, err + return withHooks[int, WeaponMutation](ctx, wu.sqlSave, wu.mutation, wu.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -172,16 +145,7 @@ func (wu *WeaponUpdate) Modify(modifiers ...func(u *sql.UpdateBuilder)) *WeaponU } func (wu *WeaponUpdate) sqlSave(ctx context.Context) (n int, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: weapon.Table, - Columns: weapon.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: weapon.FieldID, - }, - }, - } + _spec := sqlgraph.NewUpdateSpec(weapon.Table, weapon.Columns, sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt)) if ps := wu.mutation.predicates; len(ps) > 0 { _spec.Predicate = func(selector *sql.Selector) { for i := range ps { @@ -257,6 +221,7 @@ func (wu *WeaponUpdate) sqlSave(ctx context.Context) (n int, err error) { } return 0, err } + wu.mutation.done = true return n, nil } @@ -351,6 +316,12 @@ func (wuo *WeaponUpdateOne) ClearStat() *WeaponUpdateOne { return wuo } +// Where appends a list predicates to the WeaponUpdate builder. +func (wuo *WeaponUpdateOne) Where(ps ...predicate.Weapon) *WeaponUpdateOne { + wuo.mutation.Where(ps...) + return wuo +} + // 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 { @@ -360,40 +331,7 @@ func (wuo *WeaponUpdateOne) Select(field string, fields ...string) *WeaponUpdate // Save executes the query and returns the updated Weapon entity. func (wuo *WeaponUpdateOne) Save(ctx context.Context) (*Weapon, error) { - var ( - err error - node *Weapon - ) - if len(wuo.hooks) == 0 { - node, err = wuo.sqlSave(ctx) - } else { - var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) { - mutation, ok := m.(*WeaponMutation) - if !ok { - return nil, fmt.Errorf("unexpected mutation type %T", m) - } - wuo.mutation = mutation - node, err = wuo.sqlSave(ctx) - mutation.done = true - return node, err - }) - for i := len(wuo.hooks) - 1; i >= 0; i-- { - if wuo.hooks[i] == nil { - return nil, fmt.Errorf("ent: uninitialized hook (forgotten import ent/runtime?)") - } - mut = wuo.hooks[i](mut) - } - v, err := mut.Mutate(ctx, wuo.mutation) - if err != nil { - return nil, err - } - nv, ok := v.(*Weapon) - if !ok { - return nil, fmt.Errorf("unexpected node type %T returned from WeaponMutation", v) - } - node = nv - } - return node, err + return withHooks[*Weapon, WeaponMutation](ctx, wuo.sqlSave, wuo.mutation, wuo.hooks) } // SaveX is like Save, but panics if an error occurs. @@ -425,16 +363,7 @@ func (wuo *WeaponUpdateOne) Modify(modifiers ...func(u *sql.UpdateBuilder)) *Wea } func (wuo *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err error) { - _spec := &sqlgraph.UpdateSpec{ - Node: &sqlgraph.NodeSpec{ - Table: weapon.Table, - Columns: weapon.Columns, - ID: &sqlgraph.FieldSpec{ - Type: field.TypeInt, - Column: weapon.FieldID, - }, - }, - } + _spec := sqlgraph.NewUpdateSpec(weapon.Table, weapon.Columns, sqlgraph.NewFieldSpec(weapon.FieldID, field.TypeInt)) id, ok := wuo.mutation.ID() if !ok { return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "Weapon.id" for update`)} @@ -530,5 +459,6 @@ func (wuo *WeaponUpdateOne) sqlSave(ctx context.Context) (_node *Weapon, err err } return nil, err } + wuo.mutation.done = true return _node, nil } diff --git a/go.mod b/go.mod index 28537ea..dd27a5b 100644 --- a/go.mod +++ b/go.mod @@ -3,75 +3,79 @@ module git.harting.dev/csgowtf/csgowtfd go 1.18 require ( - entgo.io/ent v0.11.4 + entgo.io/ent v0.11.9 github.com/aclements/go-moremath v0.0.0-20210112150236-f10218a38794 github.com/an0nfunc/go-steam/v3 v3.0.6 github.com/an0nfunc/go-steamapi v1.1.0 github.com/gin-contrib/cors v1.4.0 - github.com/gin-gonic/gin v1.8.2 + github.com/gin-gonic/gin v1.9.0 github.com/go-redis/cache/v8 v8.4.4 github.com/go-redis/redis/v8 v8.11.5 github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 - github.com/jackc/pgx/v4 v4.17.2 - github.com/markus-wa/demoinfocs-golang/v3 v3.1.0 + github.com/jackc/pgx/v4 v4.18.1 + github.com/markus-wa/demoinfocs-golang/v3 v3.3.0 github.com/pkg/errors v0.9.1 - github.com/sabloger/sitemap-generator v1.2.1 github.com/sethvargo/go-retry v0.2.4 github.com/sirupsen/logrus v1.9.0 github.com/wercker/journalhook v0.0.0-20180428041537-5d0a5ae867b3 - golang.org/x/text v0.5.0 + golang.org/x/text v0.7.0 golang.org/x/time v0.3.0 google.golang.org/protobuf v1.28.1 gopkg.in/yaml.v3 v3.0.1 + somegit.dev/anonfunc/gositemap v0.1.0 ) require ( - ariga.io/atlas v0.8.3 // indirect + ariga.io/atlas v0.9.1 // indirect github.com/agext/levenshtein v1.2.3 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect + github.com/bytedance/sonic v1.8.3 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/fsnotify/fsnotify v1.5.1 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-openapi/inflect v0.19.0 // indirect - github.com/go-playground/locales v0.14.0 // indirect - github.com/go-playground/universal-translator v0.18.0 // indirect - github.com/go-playground/validator/v10 v10.11.1 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/go-playground/validator/v10 v10.11.2 // indirect github.com/goccy/go-json v0.10.0 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/google/uuid v1.3.0 // indirect - github.com/hashicorp/hcl/v2 v2.15.0 // indirect + github.com/hashicorp/hcl/v2 v2.16.1 // indirect github.com/jackc/chunkreader/v2 v2.0.1 // indirect - github.com/jackc/pgconn v1.13.0 // indirect + github.com/jackc/pgconn v1.14.0 // indirect github.com/jackc/pgio v1.0.0 // indirect github.com/jackc/pgpassfile v1.0.0 // indirect - github.com/jackc/pgproto3/v2 v2.3.1 // indirect + github.com/jackc/pgproto3/v2 v2.3.2 // indirect github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect - github.com/jackc/pgtype v1.13.0 // indirect + github.com/jackc/pgtype v1.14.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/compress v1.15.13 // indirect - github.com/leodido/go-urn v1.2.1 // indirect - github.com/markus-wa/go-unassert v0.1.2 // indirect + github.com/klauspost/compress v1.16.0 // indirect + github.com/klauspost/cpuid/v2 v2.2.4 // indirect + github.com/leodido/go-urn v1.2.2 // indirect + github.com/markus-wa/go-unassert v0.1.3 // indirect github.com/markus-wa/gobitread v0.2.3 // indirect github.com/markus-wa/godispatch v1.4.1 // indirect github.com/markus-wa/ice-cipher-go v0.0.0-20220823210642-1fcccd18c6c1 // indirect - github.com/markus-wa/quickhull-go/v2 v2.1.0 // indirect + github.com/markus-wa/quickhull-go/v2 v2.2.0 // indirect github.com/mattn/go-isatty v0.0.17 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/oklog/ulid/v2 v2.1.0 // indirect - github.com/pelletier/go-toml/v2 v2.0.6 // indirect - github.com/ugorji/go/codec v1.2.8 // indirect + github.com/pelletier/go-toml/v2 v2.0.7 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + github.com/ugorji/go/codec v1.2.10 // indirect github.com/vmihailenco/go-tinylfu v0.2.2 // indirect github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - github.com/zclconf/go-cty v1.12.1 // indirect - golang.org/x/crypto v0.4.0 // indirect - golang.org/x/mod v0.7.0 // indirect - golang.org/x/net v0.4.0 // indirect + github.com/zclconf/go-cty v1.13.0 // indirect + golang.org/x/arch v0.2.0 // indirect + golang.org/x/crypto v0.6.0 // indirect + golang.org/x/mod v0.8.0 // indirect + golang.org/x/net v0.7.0 // indirect golang.org/x/sync v0.1.0 // indirect - golang.org/x/sys v0.3.0 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect + golang.org/x/sys v0.5.0 // indirect ) diff --git a/go.sum b/go.sum index 48d0383..afd5535 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ -ariga.io/atlas v0.8.3 h1:nddOywkhr/62Cwa+UsGgO35lAhUYh52XGVsbFwGzWZM= -ariga.io/atlas v0.8.3/go.mod h1:T230JFcENj4ZZzMkZrXFDSkv+2kXkUgpJ5FQQ5hMcKU= -entgo.io/ent v0.11.4 h1:grwVY0fp31BZ6oEo3YrXenAuv8VJmEw7F/Bi6WqeH3Q= -entgo.io/ent v0.11.4/go.mod h1:fnQIXL36RYnCk/9nvG4aE7YHBFZhCycfh7wMjY5p7SE= +ariga.io/atlas v0.9.1 h1:EpoPMnwsQG0vn9c0sYExpwSYtr7bvuSUXzQclU2pMjc= +ariga.io/atlas v0.9.1/go.mod h1:T230JFcENj4ZZzMkZrXFDSkv+2kXkUgpJ5FQQ5hMcKU= +entgo.io/ent v0.11.9 h1:dbbCkAiPVTRBIJwoZctiSYjB7zxQIBOzVSU5H9VYIQI= +entgo.io/ent v0.11.9/go.mod h1:KWHOcDZn1xk3mz3ipWdKrQpMvwqa/9B69TUuAPP9W6g= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60= github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc= @@ -16,10 +16,16 @@ github.com/an0nfunc/go-steamapi v1.1.0 h1:sBOSAKO0zEmzKrkMX2bVhoFiErA+Gyx9hRl+7B github.com/an0nfunc/go-steamapi v1.1.0/go.mod h1:tInHdrGkh0gaXuPnvhMG4BoW9S5gVcWOY9gJ9gCBKOI= github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= +github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= +github.com/bytedance/sonic v1.8.3 h1:pf6fGl5eqWYKkx1RcD4qpuX+BIUaduv/wTm5ekWJ80M= +github.com/bytedance/sonic v1.8.3/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= +github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= +github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= @@ -42,21 +48,23 @@ github.com/gin-contrib/cors v1.4.0/go.mod h1:bs9pNM0x/UsmHPBWT2xZz9ROh8xYjYkiURU github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= -github.com/gin-gonic/gin v1.8.2 h1:UzKToD9/PoFj/V4rvlKqTRKnQYyz8Sc1MJlv4JHPtvY= -github.com/gin-gonic/gin v1.8.2/go.mod h1:qw5AYuDrzRTnhvusDsrov+fDIxp9Dleuu12h8nfB398= +github.com/gin-gonic/gin v1.9.0 h1:OjyFBKICoexlu99ctXNR2gg+c5pKrKMuyjgARg9qeY8= +github.com/gin-gonic/gin v1.9.0/go.mod h1:W1Me9+hsUSyj3CePGrd1/QrKJMSJ1Tu/0hFEH89961k= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4= github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4= -github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= +github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= -github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= +github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= +github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= -github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ= -github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= +github.com/go-playground/validator/v10 v10.11.2 h1:q3SHpufmypg+erIExEKUmsgmhDTyhcJ38oeKGACXohU= +github.com/go-playground/validator/v10 v10.11.2/go.mod h1:NieE624vt4SCTJtD87arVLvdmjPAeV8BQlHtMnw9D7s= github.com/go-redis/cache/v8 v8.4.4 h1:Rm0wZ55X22BA2JMqVtRQNHYyzDd0I5f+Ec/C9Xx3mXY= github.com/go-redis/cache/v8 v8.4.4/go.mod h1:JM6CkupsPvAu/LYEVGQy6UB4WDAzQSXkR0lUCbeIcKc= github.com/go-redis/redis/v8 v8.11.3/go.mod h1:xNJ9xDG09FsIPwh3bWdk+0oDWHbtF9rPN0F/oD9XeKc= @@ -93,8 +101,8 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/hashicorp/hcl/v2 v2.15.0 h1:CPDXO6+uORPjKflkWCCwoWc9uRp+zSIPcCQ+BrxV7m8= -github.com/hashicorp/hcl/v2 v2.15.0/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng= +github.com/hashicorp/hcl/v2 v2.16.1 h1:BwuxEMD/tsYgbhIW7UuI3crjovf3MzuFWiVgiv57iHg= +github.com/hashicorp/hcl/v2 v2.16.1/go.mod h1:JRmR89jycNkrrqnMmvPDMd56n1rQJ2Q6KocSLCMCXng= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= @@ -106,8 +114,8 @@ github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsU github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o= github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY= github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= -github.com/jackc/pgconn v1.13.0 h1:3L1XMNV2Zvca/8BYhzcRFS70Lr0WlDg16Di6SFGAbys= -github.com/jackc/pgconn v1.13.0/go.mod h1:AnowpAqO4CMIIJNZl2VJp+KrkAZciAkhEl0W0JIobpI= +github.com/jackc/pgconn v1.14.0 h1:vrbA9Ud87g6JdFWkHTJXppVce58qPIdP7N8y0Ml/A7Q= +github.com/jackc/pgconn v1.14.0/go.mod h1:9mBNlny0UvkgJdCDvdVHYSjI+8tD2rnKK69Wz8ti++E= github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= @@ -123,8 +131,8 @@ github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvW github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgproto3/v2 v2.3.1 h1:nwj7qwf0S+Q7ISFfBndqeLwSwxs+4DPsbRFjECT1Y4Y= -github.com/jackc/pgproto3/v2 v2.3.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= +github.com/jackc/pgproto3/v2 v2.3.2 h1:7eY55bdBeCz1F2fTzSz69QC+pG46jYq9/jtSPiJ5nn0= +github.com/jackc/pgproto3/v2 v2.3.2/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk= github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= @@ -132,15 +140,14 @@ github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01C github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM= -github.com/jackc/pgtype v1.12.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= -github.com/jackc/pgtype v1.13.0 h1:XkIc7A+1BmZD19bB2NxrtjJweHxQ9agqvM+9URc68Cg= -github.com/jackc/pgtype v1.13.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= +github.com/jackc/pgtype v1.14.0 h1:y+xUdabmyMkJLyApYuPj38mW+aAIqCe5uuBB51rH3Vw= +github.com/jackc/pgtype v1.14.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= -github.com/jackc/pgx/v4 v4.17.2 h1:0Ut0rpeKwvIVbMQ1KbMBU4h6wxehBI535LK6Flheh8E= -github.com/jackc/pgx/v4 v4.17.2/go.mod h1:lcxIZN44yMIrWI78a5CpucdD14hX0SBDbNRvjDBItsw= +github.com/jackc/pgx/v4 v4.18.1 h1:YP7G1KABtKpB5IHrO9vYwSrCOhs7p3uqhvhhQBptya0= +github.com/jackc/pgx/v4 v4.18.1/go.mod h1:FydWkUyadDmdNH/mHnGob881GawxeEm7TcMCzkb+qQE= github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= @@ -149,8 +156,11 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -github.com/klauspost/compress v1.15.13 h1:NFn1Wr8cfnenSJSA46lLq4wHCcBzKTSjnBIexDMMOV0= -github.com/klauspost/compress v1.15.13/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= +github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= +github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk= +github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -163,25 +173,26 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4= -github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= +github.com/leodido/go-urn v1.2.2 h1:7z68G0FCGvDk646jz1AelTYNYWrTNm0bEcFAo147wt4= +github.com/leodido/go-urn v1.2.2/go.mod h1:kUaIbLZWttglzwNuG0pgsh5vuV6u2YcGBYz1hIPjtOQ= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= -github.com/markus-wa/demoinfocs-golang/v3 v3.1.0 h1:4NFWPj5EhnAR84xgWGlVdFETavbQrlJr1GEbaIgI1UI= -github.com/markus-wa/demoinfocs-golang/v3 v3.1.0/go.mod h1:Nxh+AxYncPrUfx5o72ODvPwJi4aOuuettAX0TfVLN0E= -github.com/markus-wa/go-unassert v0.1.2 h1:uXWlMDa8JVtc4RgNq4XJIjyRejv9MOVuy/E0VECPxxo= -github.com/markus-wa/go-unassert v0.1.2/go.mod h1:XEvrxR+trvZeMDfXcZPvzqGo6eumEtdk5VjNRuvvzxQ= +github.com/markus-wa/demoinfocs-golang/v3 v3.3.0 h1:cXAI081cH5tDmmyPuyUzuIGeP8strtVzdtRB5VlIvL8= +github.com/markus-wa/demoinfocs-golang/v3 v3.3.0/go.mod h1:NzAkCtDshPkoSMg3hAyojkmHE4ZgnNWCM1Vv4yCPLsI= +github.com/markus-wa/go-unassert v0.1.3 h1:4N2fPLUS3929Rmkv94jbWskjsLiyNT2yQpCulTFFWfM= +github.com/markus-wa/go-unassert v0.1.3/go.mod h1:/pqt7a0LRmdsRNYQ2nU3SGrXfw3bLXrvIkakY/6jpPY= github.com/markus-wa/gobitread v0.2.3 h1:COx7dtYQ7Q+77hgUmD+O4MvOcqG7y17RP3Z7BbjRvPs= github.com/markus-wa/gobitread v0.2.3/go.mod h1:PcWXMH4gx7o2CKslbkFkLyJB/aHW7JVRG3MRZe3PINg= github.com/markus-wa/godispatch v1.4.1 h1:Cdff5x33ShuX3sDmUbYWejk7tOuoHErFYMhUc2h7sLc= github.com/markus-wa/godispatch v1.4.1/go.mod h1:tk8L0yzLO4oAcFwM2sABMge0HRDJMdE8E7xm4gK/+xM= github.com/markus-wa/ice-cipher-go v0.0.0-20220823210642-1fcccd18c6c1 h1:YH4WI14HARrM3C6mKUMFDBz93O25oWSlLEYGeL27G0w= github.com/markus-wa/ice-cipher-go v0.0.0-20220823210642-1fcccd18c6c1/go.mod h1:JIsht5Oa9P50VnGJTvH2a6nkOqDFJbUeU1YRZYvdplw= -github.com/markus-wa/quickhull-go/v2 v2.1.0 h1:DA2pzEzH0k5CEnlUsouRqNdD+jzNFb4DBhrX4Hpa5So= -github.com/markus-wa/quickhull-go/v2 v2.1.0/go.mod h1:bOlBUpIzGSMMhHX0f9N8CQs0VZD4nnPeta0OocH7m4o= +github.com/markus-wa/quickhull-go/v2 v2.2.0 h1:rB99NLYeUHoZQ/aNRcGOGqjNBGmrOaRxdtqTnsTUPTA= +github.com/markus-wa/quickhull-go/v2 v2.2.0/go.mod h1:EuLMucfr4B+62eipXm335hOs23LTnO62W7Psn3qvU2k= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= @@ -213,8 +224,8 @@ github.com/onsi/gomega v1.15.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+t github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o= github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= -github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU= -github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= +github.com/pelletier/go-toml/v2 v2.0.7 h1:muncTPStnKRos5dpVKULv2FVd4bMOhNePj9CjgDb8Us= +github.com/pelletier/go-toml/v2 v2.0.7/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -228,8 +239,7 @@ github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6po github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= -github.com/sabloger/sitemap-generator v1.2.1 h1:H/vZE0Z49ZCmcXy57FNqw6zn27UJYO6zuozSxfzm8qY= -github.com/sabloger/sitemap-generator v1.2.1/go.mod h1:vm0TjqX6syzcmQDBK2HkIZzORA0WQ3baEN8248nhHVk= +github.com/rwtodd/Go.Sed v0.0.0-20210816025313-55464686f9ef/go.mod h1:8AEUvGVi2uQ5b24BIhcr0GCcpd/RNAFWaN2CJFrWIIQ= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= github.com/sethvargo/go-retry v0.2.4 h1:T+jHEQy/zKJf5s95UkguisicE0zuF9y7+/vgz08Ocec= @@ -255,12 +265,15 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= -github.com/ugorji/go/codec v1.2.8 h1:sgBJS6COt0b/P40VouWKdseidkDgHxYGm0SAglUHfP0= -github.com/ugorji/go/codec v1.2.8/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= +github.com/ugorji/go/codec v1.2.10 h1:eimT6Lsr+2lzmSZxPhLFoOWFmQqwk0fllJJ5hEbTXtQ= +github.com/ugorji/go/codec v1.2.10/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/vmihailenco/go-tinylfu v0.2.2 h1:H1eiG6HM36iniK6+21n9LLpzx1G9R3DJa2UjUjbynsI= github.com/vmihailenco/go-tinylfu v0.2.2/go.mod h1:CutYi2Q9puTxfcolkliPq4npPuofg9N9t8JVrjzwa3Q= github.com/vmihailenco/msgpack/v5 v5.3.4/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= @@ -271,8 +284,9 @@ github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV github.com/wercker/journalhook v0.0.0-20180428041537-5d0a5ae867b3 h1:shC1HB1UogxN5Ech3Yqaaxj1X/P656PPCB4RbojIJqc= github.com/wercker/journalhook v0.0.0-20180428041537-5d0a5ae867b3/go.mod h1:XCsSkdKK4gwBMNrOCZWww0pX6AOt+2gYc5Z6jBRrNVg= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/zclconf/go-cty v1.12.1 h1:PcupnljUm9EIvbgSHQnHhUr3fO6oFmkOrvs2BAFNXXY= -github.com/zclconf/go-cty v1.12.1/go.mod h1:s9IfD1LK5ccNMSWCVFCE2rJfHiZgi7JijgeWIMfhLvA= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/zclconf/go-cty v1.13.0 h1:It5dfKTTZHe9aeppbNOda3mN7Ag7sg6QkBNm6TkyFa0= +github.com/zclconf/go-cty v1.13.0/go.mod h1:YKQzy/7pZ7iq2jNFzy5go57xdxdWoLLpaEp4u238AE0= github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= @@ -285,6 +299,9 @@ go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9E go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/arch v0.2.0 h1:W1sUEHXiJTfjaFJ5SLo0N6lZn+0eO5gWD1MFeTGqQEY= +golang.org/x/arch v0.2.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -294,16 +311,16 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8= -golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA= -golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -313,13 +330,15 @@ golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU= -golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -344,20 +363,25 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM= -golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -370,6 +394,7 @@ golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -408,3 +433,6 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= +somegit.dev/anonfunc/gositemap v0.1.0 h1:0y+YN14qUahq/08HSWZzq8BcW0MH07K8G0Cw6FV1N08= +somegit.dev/anonfunc/gositemap v0.1.0/go.mod h1:2v84uOYv0OQyfvQu9Fq1WI4zr/EjDOoxry5JrMZVEqo= diff --git a/main.go b/main.go index f487a86..aa9812b 100644 --- a/main.go +++ b/main.go @@ -23,7 +23,6 @@ import ( "github.com/go-redis/redis/v8" _ "github.com/jackc/pgx/v4/stdlib" "github.com/markus-wa/demoinfocs-golang/v3/pkg/demoinfocs/common" - "github.com/sabloger/sitemap-generator/smg" log "github.com/sirupsen/logrus" "github.com/wercker/journalhook" "golang.org/x/text/language" @@ -33,6 +32,7 @@ import ( "net/http" "os" "os/signal" + "somegit.dev/anonfunc/gositemap" "strconv" "strings" "syscall" @@ -50,6 +50,7 @@ var ( configFlag = flag.String("config", "config.yaml", "Set config file to use") journalLogFlag = flag.Bool("journal", false, "Log to systemd journal instead of stdout") sqlDebugFlag = flag.Bool("sqldebug", false, "Debug SQL queries") + siteMap *gositemap.SiteMap ) func housekeeping() { @@ -1051,53 +1052,35 @@ func getMatch(c *gin.Context) { c.JSON(http.StatusOK, mResponse) } +func getSiteMapIndex(c *gin.Context) { + res, err := siteMap.SiteMapIndex() + if err != nil { + _ = c.AbortWithError(http.StatusInternalServerError, err) + return + } + + c.Data(http.StatusOK, "application/xml", res) +} + func getSiteMap(c *gin.Context) { - now := time.Now().UTC() - sm := smg.NewSitemap(false) - sm.SetLastMod(&now) - sm.SetHostname("https://csgow.tf") + if c.Param("num") == "" { + _ = c.AbortWithError(http.StatusBadRequest, fmt.Errorf("no index specified")) + return + } - players, err := db.Player.Query().IDs(c) + id, err := strconv.Atoi(c.Param("num")) if err != nil { _ = c.AbortWithError(http.StatusInternalServerError, err) return } - for _, tPlayer := range players { - err = sm.Add(&smg.SitemapLoc{ - Loc: fmt.Sprintf("/player/%d", tPlayer), - ChangeFreq: smg.Daily, - }) - if err != nil { - _ = c.AbortWithError(http.StatusInternalServerError, err) - return - } - } - - matches, err := db.Match.Query().IDs(c) + res, err := siteMap.SiteMap(id) if err != nil { _ = c.AbortWithError(http.StatusInternalServerError, err) return } - for _, tMatch := range matches { - err = sm.Add(&smg.SitemapLoc{ - Loc: fmt.Sprintf("/match/%d", tMatch), - ChangeFreq: smg.Weekly, - }) - if err != nil { - _ = c.AbortWithError(http.StatusInternalServerError, err) - return - } - } - - readBuf := new(bytes.Buffer) - sm.Finalize() - _, err = sm.WriteTo(readBuf) - if err != nil { - log.Warningf("error writing to pipe: %v", err) - } - c.DataFromReader(http.StatusOK, int64(readBuf.Len()), "application/xml", readBuf, nil) + c.Data(http.StatusOK, "application/xml", res) } /* @@ -1205,6 +1188,29 @@ func main() { // start housekeeper go housekeeping() + // populate sitemap + siteMap = &gositemap.SiteMap{BaseURL: "csgow.tf"} + players, err := db.Player.Query().IDs(context.Background()) + if err != nil { + log.Panicf("error setting up SiteMap: %v", err) + } + + for _, tPlayer := range players { + freq := gositemap.Daily + siteMap.AddURL(fmt.Sprintf("/player/%d", tPlayer), nil, &freq, nil) + } + + matches, err := db.Match.Query().IDs(context.Background()) + if err != nil { + log.Panicf("error setting up SiteMap: %v", err) + } + + for _, tMatch := range matches { + freq := gositemap.Weekly + siteMap.AddURL(fmt.Sprintf("/match/%d", tMatch), nil, &freq, nil) + } + + // routes r := gin.New() r.Use(gin.LoggerWithFormatter(func(param gin.LogFormatterParams) string { return fmt.Sprintf("%s - - \"%s %s %s\" %d %d %q %q %s %s\n", @@ -1238,7 +1244,8 @@ func main() { r.GET("/match/:id/chat", getMatchChat) r.GET("/matches", getMatches) r.GET("/matches/next/:time", getMatches) - r.GET("/sitemap", getSiteMap) + r.GET("/sitemap_index.xml", getSiteMapIndex) + r.GET("/sitemap:num.xml", getSiteMap) log.Info("Start listening...")