updated deps; switched sitemap lib; ent regen
This commit is contained in:
338
ent/client.go
338
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
|
||||
}
|
||||
)
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
@@ -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)
|
||||
}
|
166
ent/ent.go
166
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)
|
||||
|
@@ -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.
|
||||
|
12
ent/match.go
12
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
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
|
@@ -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)
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -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)
|
||||
|
@@ -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)
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
|
109
ent/mutation.go
109
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
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
|
@@ -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)
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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.
|
||||
)
|
||||
|
10
ent/spray.go
10
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
|
||||
}
|
||||
}
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
}
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user