updated deps; switched sitemap lib; ent regen
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user